| Author |
Topic  |
|
|
cheyenne
Italy
Posts |
Posted - 02/01/2005 : 05:04:36 AM
|
Origin Version (Select Help-->About Origin): 7.5 Operating System: XP
Dear friends of the Forum,
Thank to the extremely valuable advices of Mike and Greg I managed to write down a script who does what I want, and saves me a lot of time in analyzing magnetization and magnetic susceptibility data coming straight from the cryostat...but a few problems raised in the last hours:
1) how can I implement my script in order to map the color of the curves to the temperature column (set as categorical)!
2) how can I plot an extra graph which plots the derivative of column 4...the magnetization...?
3) Why the script takes a long time to execute the loop that gets rid of those data rows with non numerical values of magnetization?..where is it wasting time?
Here is my script:
//Move temperature column to the worksheet beginning %A=wks.col3.name$; //get the name of column 3 wo -i 0; //insert a column at the beginning copy col(4) col(1); //copy contents of column 4 (was col 3) to the first column del col(4); //delete column4 wo -n 1 %A; //rename the first column //Move magnetization column to the worksheet beginning %A=wks.col7.name$; //get the name of column 7 wo -i 0; //insert a column at the beginning copy col(8) col(1); //copy contents of column 8 (was col 7) to the first column del col(8); //delete column4 wo -n 1 %A; //rename the first column //Move magnetic field column to the worksheet beginning %A=wks.col5.name$; //get the name of column 5 wo -i 0; //insert a column at the beginning copy col(6) col(1); //copy contents of column 6 (was col 5) to the first column del col(6); //delete column4 wo -n 1 %A; //rename the first column wks.col$(1).type=4; //set magnetic field as x-type wks.col$(2).type=1; //set magnetization as y-type wks.col$(3).type=2; //disregard temperature column %H!wks.colsel(3,1); //activate temperature column Col(TemperatureK)=nint(col(TemperatureK)); //takes the integer part of temperature values
//purge the worksheet of empty data rows at the end of file doc -e W {nRows=%H!wks.maxRows;set %H -er $(nRows);} //purge the worksheet of those rows with no magnetization data nRows=%H!wks.maxRows; %H!wks.colsel(2,1); loop(ii,1,nRows) {if(%H!cell(ii,2)==NANUM) {mark -d %C -b ii -e ii}}; //sort the whole worksheet on ascent temperature values sort -wa %H col(TimeStampsec); wo -i 0; //insert a column at the beginning col(1)=col(MDCemu)^2; //define column values wo -i 0; col(1)=col(3)/col(4); wks.col$(1).type=4; //set H/M as x-type wks.col$(2).type=1; //set Msquared as y-type wo -n 1 "H/M"; //rename the first column wo -n 2 "M^2"; //rename the first column set %E_TemperatureK -dc 1; //set temperature as categorical
//The Arrott Plot win -a %E; %A=wks.col2.name$; win -t plot Template_wks_Dennis.otp Arrot; layer -i %E_%A; layer -a; run.section(Plot,general,201);
//%H!wks.colsel(2,1); //run.section(Plot,Scatter); //layer -a;
//Simple Magnetization vs Field win -a %E; %B=wks.col4.name$; win -t plot Template_wks_Dennis.otp MvsH; layer -i %E_%B; layer -a; run.section(Plot,general,201); //%H!wks.colsel(4,1); //run.section(Plot,Scatter); //layer -a
|
|
|
Mike Buess
USA
3037 Posts |
Posted - 02/01/2005 : 08:52:29 AM
|
1) It's difficult to follow your column numbering with all of those insertions, moves and renamings. :) Therefore, I'll just refer you to LabTalk's set command with the -c option. The comments explain how to do what you want if I understand correctly.
2)
//find and plot derivative of col(4) wo -i wks.ncols Derivative; // add col at end col(Derivative)=col(4); // copy from col(4) derivative col(Derivative); // replace with derivative loop (i,1,wks.ncols) {wks.colsel(i,0)}; // deselect all columns wks.colsel(wks.ncols,1); // select last column wo -p 200; // plot as line
3) Looking at the column one cell at a time is not an efficient way to do this. Since you are sorting the worksheet later against another column anyway here is a much faster method...
//purge the worksheet of empty data rows at the end of file //doc -e W {nRows=%H!wks.maxRows;set %H -er $(nRows);} //This will be taken care of in next step.
//purge the worksheet of those rows with no magnetization data sort -w %H col(2); // sort wks against col(2) ascending... puts all NANUM at the bottom sum(col(2)); // puts the number of actual values in sum.n set %H -er sum.n; // resize wks to number of actual values in col(2)
//sort the whole worksheet on ascent temperature values sort -w %H col(TimeStampsec);
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 02/01/2005 10:31:33 AM |
 |
|
|
cheyenne
Italy
Posts |
Posted - 02/01/2005 : 11:03:01 AM
|
Dear Mike, your advices are incredibly useful to me, I started writing script only 3 days ago, I'm a truly beginner...I couldn't find any useful information for color mapping by script...and I wonder whether my pdf labtalk and Origin C guides are the right ones...i have to bother you simply because I cannot find in guide what i'm looking for...and this is seriously annoying...
Here it comes another question...
1) I tried to associated my script to worksheet menu commands, but I cannot understand why these setting vanish everytime I open a new Origin session!..i'd like these menus,submenus and menu command to stay where i want forever, and be there even after closing the Origin session.
menu -w menu 11 (Cheyenne Scripts) menu (M vs H) {run.section(MvsH.OGS,main)}; menu -i 2 (M vs T) {run.section(MvsT.OGS,main)}; |
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 02/01/2005 : 11:53:23 AM
|
Looks like you're catching on fast. Almost everything you need to know about LabTalk is in the programming guide...
Help->Programming->LabTalk Language Reference
Admittedly it's sometimes hard to find the appropriate command, function or object. The Search function on OriginLab's home page is very good at finding stuff in the Forums and online documentation.
>Menu commands. You need to add your menu commands to a configuration file that runs at startup. If you are the sole user in a standalone workstation installation of Origin just find the file FullMenu.cnf in Origin's program folder, open it in CodeBuilder or Notepad and paste your menu commands at the end. If there are other users on the workstation and you want to keep your menus to yourself you can add your own menu level like this...
1. Create a text file on your User path and rename it Cheyenne.cnf. 2. Paste your menu commands in the file and save. 3. Close Origin and open Origin.ini on your User path. Edit the top of the file (Config section) like this... (My comments are in red.)
[Config] ; keep ShowState like it is in your Origin.ini - Mike ShowState=3 ; Initial Origin window state ; Leave blank for default or one of the followings ; #define SW_HIDE 0 ; #define SW_SHOWNORMAL 1 ; #define SW_SHOWMINIMIZED 2 ; #define SW_SHOWMAXIMIZED 3
; NumLevels is probably 2, need to bump it to 3 - Mike NumLevels=3 ; Origin can have multiple menu sets, which are called levels. ; You can choose between the different levels ; from the Change Menu command in the Format menu. ; Each level is defined below by a Title and a File list. ; Number of levels defined is specified in the parameter above.
Title1=Full Menus File1=Macros FullMenu ; The names in this list are config file names. ; They are assumed to have the file extension .CNF. ; Config files must be ASCII files written in the LabTalk script language. ; MACROS.CNF : basic macros used by other config files ; FULLMENU.CNF : adds to the menu structure for each child window
Title2=Short Menus File2=Macros Short ; SHORT.CNF : Cut down on Origin's generic menus.
; Control display of bitmaps on menus ShowBitmapsOnMenus=1
; Add your level here - Mike Title3=Cheyenne's Menus File3=Macros FullMenu Cheyenne
4. Save Origin.ini and start Origin. 5. Select Format->Menu->Cheyenne's Menus. That's it!
If you close Origin while Cheyenne's Menus are active they will be active when you restart.
Mike Buess Origin WebRing Member |
 |
|
|
cheyenne
Italy
Posts |
Posted - 02/01/2005 : 12:13:16 PM
|
Thanks Mike,
I've just done as you suggested, everything is working well now, except the color mapping...it's driving me crazy..i cannot find any useful reference in the programming guide...i'm a truly beginner even in looking up things in the guide maybe!... It would be great if I could access all the options in the plot details window associated to each curve/layer by Labtalk script...I'm sure there must be an instruction there on the color mapping.
Thank you very much indeed for your patience...
|
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 02/01/2005 : 12:58:55 PM
|
Using a column as colormap as described in the set -c documentation worked fine for me. My worksheet Data1 looked like this... A(X) B(Y) C(Y) and the color indices were in column C. I created a scatter plot of column B and entered this command in the script window...
set Data1_B -c 102; // 102 = 101 + 1 column to the right
The plot symbol colors matched the indices in column C as expected. Note that indices > 24 are ignored (those symbols are black).
...Note also that I did not set col C as categorical. When I do set it as categorical it still works as a color map but the symbol colors change. Not sure what's happening there but I suggest you try it with a non-categorical column.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 02/01/2005 2:06:11 PM |
 |
|
| |
Topic  |
|
|
|