[proFit-list] problem with SetDefaultCols

proFit Support profit at quansoft.com
Sun Jul 17 01:43:38 CDT 2011


Fernando

You are correct to say that, in this case, Spline sticks to the old values. The reason for that has to do with the inner workings of the Spline function, which updates itself to a new dataset only when pro Fit is idle, i.e. after your program returns. We will have to look at this. For the time being, one thing you can do is trick Spline into updating itself explicitly by modifying your last script as follows:

program test3;

begin

	SetDefaultCols(1,2,0,0) ;
	Transform (operation functionOp, function 'Spline', xColumn 5, yColumn 6) ;

	Analyze(function 'Spline', type findDerivative, xValue 0, parameter 1);

	SetDefaultCols(0,0,0,0) ;
	SetDefaultCols(3,4,0,0) ;
	Transform (operation functionOp, function 'Spline', xColumn 5, yColumn 7) ;

end;

The call to Analyze does not serve any mathematical purpose in that case, but it forces Spline to update itself.

Alternatively, you may want to consider using Python scripting. If you have scipy installed (see www.scipy.org), you can use the module interpolate within scipy for advanced interpolation. The following is a Python script that does the same as the above Pascal script but uses scipy:

from scipy import interpolate

x = pf.GetData(pf.RowRange(), 1)
y = pf.GetData(pf.RowRange(), 2)
f = interpolate.interp1d(x, y, kind = 'quadratic', bounds_error = False)
y = f(pf.GetData(pf.RowRange(), 5))
pf.SetData(1, 6, (y,))

x = pf.GetData(pf.RowRange(), 3)
y = pf.GetData(pf.RowRange(), 4)
f = interpolate.interp1d(x, y, kind = 'quadratic', bounds_error = False)
y = f(pf.GetData(pf.RowRange(), 5))
pf.SetData(1, 7, (y,))

Best regards

Kurt Sutter
QuantumSoft


On 15. Jul 2011, at 9:57, Fernando Bartolome wrote:

> Dear Kurt and pro Fit users,
> 
> you're right, the test you sent me back works. I see now that I explained very badly the actual problem in my first email. 
> (the fact that your test works is what I meant by  "Of course if I do this with one column it works... or if I do it by hand! ")
> 
> It is the repetition of that which gives a problem. It appears like one of two possibilities:
> 
> a) a subsequent SetDefaultCols is doing nothing (although it actually moves the indicators in the data window and changes the Preview Panel)
> or 
> b) it is Transform who is not taking the new default columns to calculate the Spline values, keeping the first ones it received.
> 
> I'll try to put three examples:
> 
> Your test program works, but this simple "iterative" version doesn't:
> 
> program test;
> var
> i,ik:integer;
> 
> begin
> for i:=1 to 2 do {increasing for loop}
> begin
> 	ik:=2*i ;
> 	SetDefaultCols(ik-1,ik,0,0) ;
> 	Transform (operation functionOp, function 'Spline', xColumn 5, yColumn 5+i) ;
> end;
> end;
> 
> to be tested with, for example, the attached "test_1.data".
> The "splined" curve in column 7 is identical to that in column 6, which should not be the case, I think.
> 
> Even more, the simplest example, eliminating the "for" and explicitely writing it down ( := twice your test)
> does not work either. It yields the same results as if the sentence SetDefaultCols(3,4,0,0); is not there.
> 
> program test2;
> 
> var
> i,ik:integer;
> 
> begin
> 
> 	SetDefaultCols(1,2,0,0) ;
> 	Transform (operation functionOp, function 'Spline', xColumn 5, yColumn 6) ;
> 
> 	SetDefaultCols(3,4,0,0) ;
> 	Transform (operation functionOp, function 'Spline', xColumn 5, yColumn 7) ;
> 
> end;
>  
> 
> Finally, if you "undefine" the default cols before defining them again, that's worthless:
> 
> program test3;
> 
> var
> i,ik:integer;
> 
> begin
> 
> 	SetDefaultCols(1,2,0,0) ;
> 	Transform (operation functionOp, function 'Spline', xColumn 5, yColumn 6) ;
> 
> 	SetDefaultCols(0,0,0,0) ;
> 	SetDefaultCols(3,4,0,0) ;
> 	Transform (operation functionOp, function 'Spline', xColumn 5, yColumn 7) ;
> 
> end;
> 
> columns 6 and 7 are identical, which I think is wrong.
> That keeps going on if you do some other different Transform in the middle (functionOp with a different function, formulaOp or whatever). It keeps working with the only Default Cols you feed it first. No way to change them later. It's strange, isn't it?
> 
> In any case, thank you very much for your interest and fast answer, and for maintaining pro Fit, a fantastic piece of software.
> 
> Fernando
> 
> _________________________________________
> 
> Fernando Bartolomé
> Instituto de Ciencia de Materiales de Aragón
> CSIC - UZ
> 
> tel: +34 976 762459
> fax: +34 976 761229
> email: bartolom at unizar.es
> http://fmc.unizar.es/people/bartolom/
> 
> 
> 
> <test_1.data>
> 
> El 15/07/2011, a las 06:59, Kurt Sutter escribió:
> 
>> Dear Fernando
>> 
>> I cannot say what is wrong with your example. I have just tried here. I have put one experiment in columns 3 and 4, and the x-coordinates of the other experiment in column 5. Then I ran
>> 
>> program test;
>> begin
>> 	SetDefaultCols(3,4,0,0) ;
>> 	Transform (operation functionOp, function 'Spline', xColumn 5, yColumn 6);
>> end;
>> 
>> The results were as expected. Are you sure your code works properly. If yes, we need more information.
>> 
>> Best regards
>> 
>> Kurt Sutter
>> QuantumSoft
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://quantum-soft.com/pipermail/profit-list_quantum-soft.com/attachments/20110717/cb1836ad/attachment-0001.html>


More information about the proFit-list mailing list