[SciPy-User] NetcdfIntepolatingFunction

Warren Weckesser warren.weckesser at enthought.com
Mon Feb 14 07:37:43 EST 2011


Johannes,

ScientificPython and SciPy are different projects.   Your question is about
the ScientificPython package:

    http://dirac.cnrs-orleans.fr/plone/software/scientificpython/
    http://sourcesup.cru.fr/projects/scientific-py/

While there is no harm in asking your question on this mailing list, you
might also consider asking your question in the ScientificPython forums:

    https://sourcesup.cru.fr/forum/?group_id=180


Warren


On Mon, Feb 14, 2011 at 5:10 AM, Johannes Korn <korn at freisingnet.de> wrote:

> 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
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110214/57f698c9/attachment.html>


More information about the SciPy-User mailing list