The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Unstack data on reaching a certain value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

electrochemist2017

Germany
4 Posts

Posted - 09/27/2017 :  07:54:01 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2016G (32-bit) Sr1
Operating System: Win10 (64-bit)

Hello together,

I am working with electrochemical cycling data in ASCII format.
The cells are alternately charged and discharged, where the voltage of the cell is recorded in column C7(Y) and the corresponding capacity is in column C4(Y) until the next charge or discharge starts.

What I would like to do is split or unstack every charging and discharging part (Column C7(Y)) and the corresponding capacity (column C4(Y)) into extra columns by use of column C9(Y), where each charging or discharging block starts with 0 and ends with 133.



Is there a possibility to automate this so I can transfer it into an origin template?

Thank you in advance for any help

Hideo Fujii

USA
1582 Posts

Posted - 09/27/2017 :  10:27:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi electrochemist2017,

You can add a column (say, column D), and set the following formula in the Set Column Value tool:
i==1?1:col(ES)[i]==0?wcol(_ThisColNum)[i-1]+1:wcol(_ThisColNum)[i-1]
You can put the unstack x-function in the Script Panel of the worksheet, then save it as a template:
wunstackcol irng1:=1!1:end irng2:=col(D);
Hope this helps.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 09/27/2017 12:28:33 PM
Go to Top of Page

electrochemist2017

Germany
4 Posts

Posted - 09/27/2017 :  1:39:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hey Hideo Fujii,

thanks for the quick reply!

I tried your code and optimized my imported data using the import assistent, which leads to the result in the picture below:



Is it possible to remove the blocks with State = R and State = S in advance, as they are unnecessary resting steps and create extra columns i dont need.

Except from that the code runs smooth :)

[Edit]

I tried a bit around and created a little script:


win -a Book1;
For (I = 1; I <= wks.nRows; I +=1)
{
	If ( Cell(I, col(D))$ = "R")
	{
		Wks.deleteRows(I)
	}
	If ( Cell(I, col(D))$ = "S")
	{
		Wks.deleteRows(I)
	}
};




I don´t know whats wrong with my code, is there maybe something wrong with my syntax?


Best,
electrochemist2017

Edited by - electrochemist2017 on 09/29/2017 03:46:49 AM
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 09/29/2017 :  04:54:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Check that:

win -a Book1;
for (int ii = 1; ii <= wks.maxRows; ii++)
{
if (col(D)[ii]$ == "R" || col(D)[ii]$ == "S") {Wks.deleteRows($(ii)); ii--;}
}

do not use i, it's reserved for origin as I know. Do not forget ";" at the end of statements. For "if" use "==". Best,

Nikolay
Go to Top of Page

electrochemist2017

Germany
4 Posts

Posted - 03/04/2018 :  09:41:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Unfortunately I still have issues with a proper automation.
As I changed the device lately, the syntax of my file got a bit easier:



As you can see in the picture I have a column for Cycle number (Col(B)) and I would like to split that file into single files for each cycle present and rename them to something like filename_cycle1, filename_cycle2 or similar.

What I tried in addition is the unstacking tool, but this gave me only to columns with random looking data.

I successfully created an import filter which does some mathematical operations on the imported data, but the file splitting remains a big secret to me.

I would really appreciate any help regarding the scripting :)

Best,
electrochemist2017
Go to Top of Page

electrochemist2017

Germany
4 Posts

Posted - 03/06/2018 :  2:19:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello again

I tried now playing around with wunstackcol with the following script:
wunstackcol irng1:=(1:12) irng2:=col(2) sort:=data ow:=Sheet!1;
This in general recognizes the splitting condition correctly and but gives me just a single file like this:


Is it possible to use wunstackcol and put each stack in a new sheet?

Best,
Electrochemist2017
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000