pascal/profit scripting
pascal/profit scripting
pascal/profit scripting
pascal/profit scripting
pascal/profit scripting
pascal/profit scripting
pascal/profit scripting
pascal/profit scripting
Pascal is used by Profit as scripting language. I really like Profit and I use it for nearly all my data plotting. The Documentation within Profit is quite good so it is fairly straight forward to go ahead and make your life easy with a set of scripts.
Average a set of columns ?
Ever wanted to have new Column with the average of a set of columns inserted into you datasheet?
002
003 var wid,str,nd,i : integer;
004 var offset: real;
005 var formulos,isi,filos: string;
006
007 begin
008 wid := GetCurrentWindow(datatype);
009 i := YColumn;
010 filos := GetColumnProperty(i, name);
011 SetBoxTitle('Average Columns');
012 Input('First',str, 'Last',nd);
013 i:=0;
014 isi:='';
015 formulos:='';
016 {Do the string }
017 for i:=str+1 to nd+1 do
018 begin
019 NumberToString(i, isi, 1, 0);
020 formulos := formulos + '+' + 'c' + isi;
021 end;
022 NumberToString(nd-str+1, isi, 1, 0);
023 formulos := '(' + formulos + ')/' + isi;
024 writeln(formulos);
025 InsertColumns(window wid, at str);
026 SelectColumn(col str);
027 Transform(window wid, operation formulaOp, xColumn 0, yColumn str,
formula formulos, makePermanent true);
028 SetDefaultCols(1,str,0,0);
029 filos := filos[1]+filos[2]+filos[3] + '.avg.';
030 SetColumnProperties(col str, name filos);
031 end;
type:profit [ download ]
Descriptin to come ...
Kinetic data handeling
In the JBC 2007 paper, fluorescence yield traces did not have a sufficently high resolution in the early part of the experiment but at the same time, data could not be collect faster than 5 hz. A way around this was problem to measure four experiments with a shifted time base at early times and to average and merge these experiments in the correct way. This script was used to get the merged datasets. Please find more inforamtion about the experiments and the different sets in the JBC 2007 paper.
002 var wid,twid,sets,specs,points,rws,i,x,y,c,nullpunkt,str,nd,pl,sou,
scwid,n : integer;
003 var offset,max: real;
004 var filos,tmp,name_set,formulos : string;
005
006 procedure OpenNewWindow(x);
007 begin
008 NumberToString(x+1, tmp, 1, 0);
009 name_set := filos + ' Set '+ tmp;
010 NewDataWindow(nrRows rws, name name_set, info tmp);
011 twid := FrontmostWindow(datatype);
012 end;
013
014 procedure GetTimeBase(x);
015 begin
016 nullpunkt := x*specs*points;
017 SelectWindow(wid);
018 SetCurrentWindow(wid);
019 SelectCell(fromRow nullpunkt+1, toRow nullpunkt+points, col 1);
020 DoMenu('Edit:Copy');
021 SelectWindow(twid);
022 SetCurrentWindow(twid);
023 SelectCell(fromRow 1, toRow 51, col 2);
024 DoMenu('Edit:Paste');
025 SelectColumn(col 1);
026 c:=x*specs*pl;
027 NumberToString(c, tmp, 1, 0);
028 tmp := 'c2-' + tmp;
029 Transform(window twid, operation formulaOp, xColumn 0, yColumn 1,
formula tmp, makePermanent false);
030 SetColumnProperties(col 1, name 'Time [s]');
031 end;
032
033 procedure CopySingleSpectrum(x,twid);
034 begin
035 nullpunkt := x*specs*points;
036 i:= 0;
037 repeat
038 str := nullpunkt+i*points+1;
039 nd := nullpunkt+i*points+points;
040 SelectWindow(wid);
041 SetCurrentWindow(wid);
042 SelectCell(fromRow str, toRow nd, col sou);
043 DoMenu('Edit:Copy');
044 SelectWindow(twid);
045 SetCurrentWindow(twid);
046 SelectCell(fromRow 1, toRow 51, col i+2);
047 DoMenu('Edit:Paste');
048 i:=i+1;
049 until i>=specs;
050 SetColumnProperties(col 1, name 'Time [s]');
051 end;
052
053 procedure AddEmptyRows(x,twid); {Frameshift over 8 Datapoints}
054 begin
055 for i:=15 downto 8 do {Data to spread are in line 8-15}
056 begin
057 InsertRows(window twid, at i+1, count 3-x);
058 InsertRows(window twid, at i, count x);
059 end;
060 end;
061
062 procedure LazyAverage(twid);
063 begin
064 InsertColumns(window twid, at 2, count 2);
065 Transform(window twid, operation formulaOp, xColumn 0, yColumn 3,
formula '(c4+c5+c6)/3', makePermanent true);
066 tmp := name_set + ' (av)';
067 SetColumnProperties(col 3, name tmp);
068 end;
069
070 procedure LazyNormalize(twid);
071 {Col was already at LazyAverage inserted - coz otherwise it went cr
azy }
072 begin
073 SelectWindow(twid);
074 SetCurrentWindow(twid);
075 SelectRow(fromRow 1, toRow 7);
076 Fit(window twid, function 'lIn3ar', algorithm levenberg, xColumn
1, yColumn 3, selRowsOnly true, printResults false);
077 offset:=GetResult(fittedParameter, 1);
078 NumberToString(offset, tmp, 0, 7);
079 formulos := '(c3 - (' + tmp + '))';
080 {Normalize by t=4sec - t= 5sec }
081 {
082 SelectRow(fromRow 40, toRow 50);
083 Statistics(window twid, column 3, withMedian false, withSkew fals
e, selRowsOnly true, printResults false);
084 max := GetResult(statMean);
085 NumberToString(max, tmp, 0, 7);
086 formulos := formulos + '/' + tmp;
087 writeln(x+1, ' ', max);
088 }
089 SelectColumn(col 2);
090 Transform(window twid, operation formulaOp, xColumn 0, yColumn 2,
formula formulos, makePermanent false);
091 SetDefaultCols(1,2,0,0);
092 tmp := name_set + '.(av&z)';
093 SetColumnProperties(col 2, name tmp);
094 DoMenu('Edit:Copy');
095 end;
096
097 procedure PasteOverCollecta(x,scwid);
098 begin
099 SelectWindow(scwid);
100 SetCurrentWindow(scwid);
101 SelectColumn(col x+3);
102 DoMenu('Edit:Paste');
103 end;
104
105 procedure AddPoints(scwid);
106 begin
107 x:=0;
108 n:=8;
109 SelectWindow(scwid);
110 SetCurrentWindow(scwid);
111 repeat
112 for y:=1 to 4 do
113 begin
114 SelectCell(row n, col y+2);
115 Copy;
116 for i:=1 to 4 do {increasing for loop}
117 begin
118 SelectCell(row n, col i+2);
119 Paste;
120 end;
121 n:=n+1;
122 end;
123 x:=x+1;
124 until x>7;
125 end;
126
127 procedure AverageSCWID;
128 begin
129 SetColumnProperties(col 2, name filos+'.av');
130 Transform(window scwid, operation formulaOp, xColumn 0, yColumn 2
, formula '(c3+c4+c5+c6)/4', makePermanent false);
131 SetDefaultCols(1,2,0,0);
132 end;
133 procedure DoubleSlowPts;
134 begin
135 SelectRow(fromRow 40, toRow 75);
136 Copy;
137 SelectRow(row 76);
138 Paste;
139 SelectRow(fromRow 8, toRow 111);
140 end;
141 begin {----------> MAIN <----------}
142 writeln('==[Choppa V1.0]=================');
143 wid := GetCurrentWindow(datatype);
144 i := YColumn;
145 filos := GetColumnProperty(i, name);
146 x:= 0;
147 twid:=0;
148
149 {Delete pre-defined vars -->}
150 sets:=4;specs:=3;points:=51;pl:=40;
151
152 SetBoxTitle('Series-Sets-Specs-Points?');
153 Input('Which column', sou, 'How many Sets',sets,'How many Specs/Set
?',specs,'How many points/spec?',points, 'Peroidlenght [s] ?', pl);
154
155 {Counting DataRows and check input}
156 Statistics(window wid, column 1);
157 rws:= GetResult(statCount);
158
159 {Checking input}
160 if points*specs*sets <> rws then
161 begin
162 Alert('Dude! - Data imput type mismatch. Selecting your first spe
ctra and exiting');
163 SelectRow(fromRow 0, toRow points);
164 exit;
165 end;
166
167 {Preparing collecta window}
168 if scwid = 0 then
169 begin
170 NewDataWindow;
171 scwid := FrontmostWindow(datatype);
172 end;
173 tmp := 'merged Collecta window - SAVE ME!';
174 SetWindowProperties(window scwid, name tmp);
175 SetWindowProperties(window scwid, boundsLeft 704, boundsTop 394, b
oundsRight 1262, boundsBottom 723);
176
177 {Looping over sets}
178 repeat
179 OpenNewWindow(x);
180 GetTimeBase(x);
181 CopySingleSpectrum(x,twid);
182 AddEmptyRows(x,twid);
183 LazyAverage(twid);
184 LazyNormalize(twid);
185 PasteOverCollecta(x,scwid);
186 CloseWindow(window twid, saveOption dontSave);
187
188 x:=x+1;
189 until x>=sets;
190 AddPoints(scwid);
191 AverageSCWID;
192 DoubleSlowPts;
193 SaveWindow(window scwid, file '/Volumes/Users/fu/Documents/_2002 -
2005 Saclay Doktorarbeit/Kinetix/zzz_working/'+ filos);
194
195 end;
type:profit [ download ]