[gradsusr] issue in exporting and expression, change it in Python and import back
K Jackon
oukjweather at gmail.com
Wed Nov 20 08:21:16 EST 2013
Hi Arlindo,
I am experiencing the same problem with python returning AttributeError:
'NoneType' object has no attribute 't'. I'm on the latest version of
pygrads version 1.1.8.
I'm trying to work through the following example.
[] ga-> clear
[] ga-> uv = ga.exp('ua*ua+va*va')
[] ga-> speed = sqrt(uv)
[] ga-> dd speed
I looked into it and I believe the issue is when you execute the
speed = sqrt(uv) command of the example. I believe the sqrt function is not
properly instantiating the GaGrid object by not passing it the GaHandle
object or by not setting the meta data after instantiating the GaGrid
object.
If you look at the uv object you see that the associated meta data is set,
but when you look at the speed object its not set. Here is an example of
what I am seeing.
Successfully opened <Contents/Resources/SampleDatasets/model.ctl> as File 1
[1] ga-> uv = ga.exp('ua*ua+va*va')
/usr/lib/python2.6/site-packages/pygrads-1.1.8-py2.6.egg/grads/numtypes.py:131:
DeprecationWarning: object.__init__() takes no parameters
ma.MaskedArray.__init__(self,data, **kwargs)
[2] ga-> speed = sqrt(uv)
[3] ga-> uv.grid
Out[3]: <grads.numtypes.GaGrid at 0x29fe890>
[4] ga-> speed.grid
Out[4]: <grads.numtypes.GaGrid at 0x29fea10>
[5] ga-> uv.grid.denv
Out[5]:
<grads.gahandle.GaHandle object at 0x29fe990>
==================================
Handle name = dims
==================================
xi = (1, 73)
ei = (1, 1)
zi = (1, 1)
rank = 2
e_state = fixed
ti = (1, 1)
tyme = [datetime.datetime(1987, 1, 1, 0, 0), datetime.datetime(1987, 1,
1, 0, 0)]
lon = (0.0, 360.0)
ne = 1
nx = 73
ny = 46
nz = 1
ens = ('1', '1')
rc = 0
dfile = 1
nt = 1
yi = (1, 46)
t_state = fixed
z_state = fixed
x_state = varying
lev = (1000.0, 1000.0)
lat = (-90.0, 90.0)
y_state = varying
e = (1, 1)
name = dims
t = (1, 1)
time = ('00Z01JAN1987', '00Z01JAN1987')
y = (1.0, 46.0)
x = (1.0, 73.0)
z = (1, 1)
[6] ga-> speed.grid.denv
[7] ga-> uv.grid.lat
Out[7]:
array([-90., -86., -82., -78., -74., -70., -66., -62., -58., -54., -50.,
-46., -42., -38., -34., -30., -26., -22., -18., -14., -10., -6.,
-2., 2., 6., 10., 14., 18., 22., 26., 30., 34., 38.,
42., 46., 50., 54., 58., 62., 66., 70., 74., 78., 82.,
86., 90.], dtype=float32)
[8] ga-> speed.grid.lat
[9] ga->
Thus when you try to import speed it crashes because the meta data it needs
to do the import is missing.
Kenneth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20131120/86ed615b/attachment.html
More information about the gradsusr
mailing list