[SciPy-User] NetcdfIntepolatingFunction
Johannes Korn
korn at freisingnet.de
Mon Feb 14 06:10:26 EST 2011
Hi,
I´d like to use "NetcdfIntepolatingFunction" to obtain values from an
ECMWF-Reanalysis file interpolated in time and space.
I tried:
In [88]:
a=Scientific.Functions.Interpolation.NetCDFInterpolatingFunction('output2.nc',['longitude','latitude','time'],'u10',default=-99.)
In [90]: a(0,0,899940)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/users/rein_be/cloudprops/compare_albedos/tmp/<ipython console> in
<module>()
/usr/local/lib/python2.6/site-packages/Scientific/Functions/Interpolation.pyc
in __call__(self, *points)
90 pass
91 try:
---> 92 neighbours = map(_lookup, points, self.axes,
self.period)
93 except ValueError, text:
94 if self.default is not None:
/usr/local/lib/python2.6/site-packages/Scientific/Functions/Interpolation.pyc
in _lookup(point, axis, period)
436 raise ValueError('Point outside grid of values')
437 i = j-1
--> 438 weight = (point-axis[i])/(axis[j]-axis[i])
439 return index_expression[i:j+1:1], weight
440 else:
TypeError: illegal subscript type
Interestingly if I swap the axes ('time' now on 1st position) I´m able
to call 'a':
In [91]:
a=Scientific.Functions.Interpolation.NetCDFInterpolatingFunction('output2.nc',['time','longitude','latitude'],'u10',default=-99.)
In [92]: a(0,0,899940)
Out[92]: -99.0
However, if I also swap axes in the calling command:
In [93]: a(899940,0,0)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/users/rein_be/cloudprops/compare_albedos/tmp/<ipython console> in
<module>()
/usr/local/lib/python2.6/site-packages/Scientific/Functions/Interpolation.pyc
in __call__(self, *points)
90 pass
91 try:
---> 92 neighbours = map(_lookup, points, self.axes,
self.period)
93 except ValueError, text:
94 if self.default is not None:
/usr/local/lib/python2.6/site-packages/Scientific/FunctionsIn [93]:
a(899940,0,0)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/users/rein_be/cloudprops/compare_albedos/tmp/<ipython console> in
<module>()
/usr/local/lib/python2.6/site-packages/Scientific/Functions/Interpolation.pyc
in __call__(self, *points)
90 pass
91 try:
---> 92 neighbours = map(_lookup, points, self.axes,
self.period)
93 except ValueError, text:
94 if self.default is not None:
/usr/local/lib/python2.6/site-packages/Scientific/Functions/Interpolation.pyc
in _lookup(point, axis, period)
436 raise ValueError('Point outside grid of values')
437 i = j-1
--> 438 weight = (point-axis[i])/(axis[j]-axis[i])
439 return index_expression[i:j+1:1], weight
440 else:
TypeError: illegal subscript type
/Interpolation.pyc in _lookup(point, axis, period)
436 raise ValueError('Point outside grid of values')
437 i = j-1
--> 438 weight = (point-axis[i])/(axis[j]-axis[i])
439 return index_expression[i:j+1:1], weight
440 else:
TypeError: illegal subscript type
Am I doing things wrong or is this a bug?
Kind regards!
Johannes
More information about the SciPy-User
mailing list