python, strange result [message #91721] |
Fri, 14 August 2015 08:22  |
Dae-Kyu Shin
Messages: 25 Registered: February 2015
|
Junior Member |
|
|
Here is example code
pro test4
compile_opt idl2
x = indgen(4)
y = indgen(3)
z = indgen(4, 3)
python.run, 'from scipy import interpolate'
f = python.interpolate.interp2d(x, y, z)
print, f(x, y)
end
The output of "f" is
0.00000000 4.0000000 8.0000000 1.0000000
5.0000000 9.0000000 2.0000000 6.0000000
10.000000 3.0000000 7.0000000 11.000000
What happend?
Exact answer is "z".
|
|
|
Re: python, strange result [message #91750 is a reply to message #91721] |
Thu, 20 August 2015 10:51  |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
On Friday, August 14, 2015 at 9:22:50 AM UTC-6, Dae-Kyu Shin wrote:
> Here is example code
>
> pro test4
>
> compile_opt idl2
>
> x = indgen(4)
> y = indgen(3)
> z = indgen(4, 3)
>
>
>
> python.run, 'from scipy import interpolate'
> f = python.interpolate.interp2d(x, y, z)
> print, f(x, y)
>
>
> end
>
>
>
> The output of "f" is
> 0.00000000 4.0000000 8.0000000 1.0000000
> 5.0000000 9.0000000 2.0000000 6.0000000
> 10.000000 3.0000000 7.0000000 11.000000
>
> What happend?
> Exact answer is "z".
You might need to take the transpose(z) before you pass it into interp2d. IDL is column major while Python is row major.
Cheers,
Chris
|
|
|