cubic spline fitting [message #89684] |
Thu, 13 November 2014 18:18  |
iansmith@bigpond.net.
Messages: 4 Registered: October 2014
|
Junior Member |
|
|
I am trying to use the IDL routines
spl_init and spl_interp
to do a cubic spline fit to variables that are vectors with 45 elements.
ie y is not a function of x.
I am getting 2 compilation errors where it seems to be objecting to using a vector for y instead of y being a function of x.
IDL> .compile -v 'C:\Ian_Plots\complines 27102014 FYZ Clumps SiO 2-1 and 5-4 Peak Tbs dV30.pro'
% Compiled module: LOAD_MOLDATA.
spl_init,(x_nH_5,y_Tb13N_5,double)
^
% Syntax error.
At: C:\Ian_Plots\complines 27102014 FYZ Clumps SiO 2-1 and 5-4 Peak Tbs dV30.pro, Line 476
spl_interp,(x_nH_5,y_Tb13N_5,x2_nH_5,y2_13N_5,double)
^
% Syntax error.
At: C:\Ian_Plots\complines 27102014 FYZ Clumps SiO 2-1 and 5-4 Peak Tbs dV30.pro, Line 481
% 2 Compilation error(s) in module $MAIN$.
Is my diagnosis correct?
Is there a way around this problem ?
I would appreciate some help.
Regards
Ian Smith
Dept of Science and Engineering
Macquarie University
|
|
|
Re: cubic spline fitting [message #89685 is a reply to message #89684] |
Thu, 13 November 2014 18:50   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
The documentation gives an example of how to call spl_init and spl_interp
X = (FINDGEN(21)/20.0) * 2.0 * !PI
Y = SIN(X)
; Calculate interpolating cubic spline:
Y2 = SPL_INIT(X, Y)
; Define the X values P at which we desire interpolated Y values:
X2= FINDGEN(11)/11.0 * !PI
; Calculate the interpolated Y values corresponding to X2[i]:
result = SPL_INTERP(X, Y, Y2, X2)
PRINT, result
Note that
(1) there is no comma prior to the parentheses
(2) one must set the output equal to a variable e.g. Y = SPL_INTERP(X,Y,Y2,X2)
The confusion may be due to the fact that IDL has both procedure calls and function calls, with quite different syntax.
On Thursday, November 13, 2014 9:18:36 PM UTC-5, ian....@mq.edu.au wrote:
> I am trying to use the IDL routines
>
> spl_init and spl_interp
>
> to do a cubic spline fit to variables that are vectors with 45 elements.
> ie y is not a function of x.
>
> I am getting 2 compilation errors where it seems to be objecting to using a vector for y instead of y being a function of x.
>
> IDL> .compile -v 'C:\Ian_Plots\complines 27102014 FYZ Clumps SiO 2-1 and 5-4 Peak Tbs dV30.pro'
> % Compiled module: LOAD_MOLDATA.
>
> spl_init,(x_nH_5,y_Tb13N_5,double)
> ^
> % Syntax error.
> At: C:\Ian_Plots\complines 27102014 FYZ Clumps SiO 2-1 and 5-4 Peak Tbs dV30.pro, Line 476
>
> spl_interp,(x_nH_5,y_Tb13N_5,x2_nH_5,y2_13N_5,double)
> ^
> % Syntax error.
> At: C:\Ian_Plots\complines 27102014 FYZ Clumps SiO 2-1 and 5-4 Peak Tbs dV30.pro, Line 481
> % 2 Compilation error(s) in module $MAIN$.
>
|
|
|
Re: cubic spline fitting [message #89708 is a reply to message #89685] |
Tue, 18 November 2014 20:22  |
iansmith@bigpond.net.
Messages: 4 Registered: October 2014
|
Junior Member |
|
|
Thank you for your help. I can report that your suggested approach works even where the Y variable in the SPL_INIT procedure is an array of discrete values and not a function of X
On Friday, November 14, 2014 1:51:01 PM UTC+11, wlandsman wrote:
> The documentation gives an example of how to call spl_init and spl_interp
>
> X = (FINDGEN(21)/20.0) * 2.0 * !PI
> Y = SIN(X)
> ; Calculate interpolating cubic spline:
> Y2 = SPL_INIT(X, Y)
> ; Define the X values P at which we desire interpolated Y values:
> X2= FINDGEN(11)/11.0 * !PI
> ; Calculate the interpolated Y values corresponding to X2[i]:
> result = SPL_INTERP(X, Y, Y2, X2)
> PRINT, result
>
> Note that
> (1) there is no comma prior to the parentheses
> (2) one must set the output equal to a variable e.g. Y = SPL_INTERP(X,Y,Y2,X2)
>
> The confusion may be due to the fact that IDL has both procedure calls and function calls, with quite different syntax.
>
>
> On Thursday, November 13, 2014 9:18:36 PM UTC-5, ian....@mq.edu.au wrote:
>> I am trying to use the IDL routines
>>
>> spl_init and spl_interp
>>
>> to do a cubic spline fit to variables that are vectors with 45 elements.
>> ie y is not a function of x.
>>
>> I am getting 2 compilation errors where it seems to be objecting to using a vector for y instead of y being a function of x.
>>
>> IDL> .compile -v 'C:\Ian_Plots\complines 27102014 FYZ Clumps SiO 2-1 and 5-4 Peak Tbs dV30.pro'
>> % Compiled module: LOAD_MOLDATA.
>>
>> spl_init,(x_nH_5,y_Tb13N_5,double)
>> ^
>> % Syntax error.
>> At: C:\Ian_Plots\complines 27102014 FYZ Clumps SiO 2-1 and 5-4 Peak Tbs dV30.pro, Line 476
>>
>> spl_interp,(x_nH_5,y_Tb13N_5,x2_nH_5,y2_13N_5,double)
>> ^
>> % Syntax error.
>> At: C:\Ian_Plots\complines 27102014 FYZ Clumps SiO 2-1 and 5-4 Peak Tbs dV30.pro, Line 481
>> % 2 Compilation error(s) in module $MAIN$.
>>
|
|
|