Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full averaging weirdness #757

Closed
doutriaux1 opened this issue Oct 7, 2014 · 0 comments · Fixed by #861
Closed

full averaging weirdness #757

doutriaux1 opened this issue Oct 7, 2014 · 0 comments · Fixed by #861
Assignees
Milestone

Comments

@doutriaux1
Copy link
Contributor

Hi Charles,

I’m trying to produce a spatial average over a region of a variable, after doing a temporal average.

This works for almost all of the regions defined in the NCAR scripts.

However, one region in particular (Antarctica) makes cdutil.averager barf.

f = cdms2.open('/Users/bs1/data/co2-2yr.xml')
v = f('FCTR')
vt = cdutil.averager(v, axis='t')
vt.shape
(360, 720)
vsub = vt(latitude=(-90, -65), longitude=(-180, 180))
vsub.shape
(50, 720)
va = cdutil.averager(vsub, axis='xy')
Traceback (most recent call last):
File "", line 1, in
File "/Users/bs1/uvcdat-devel/build/install/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/genutil/averager.py", line 1118, in averager
V, sumwts = average_engine(V, filled_wtoptions[i])
File "/Users/bs1/uvcdat-devel/build/install/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/genutil/averager.py", line 662, in average_engine
y, return_wts = MV2.average(x, weights=wts, returned=1, axis=0)
File "/Users/bs1/uvcdat-devel/build/install/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cdms2/MV2.py", line 405, in average
if returned: maresult, wresult = maresult
TypeError: iteration over a 0-d array

However, this works ok:
vs2 = vt(latitude=(-10, 10), longitude=(90, 150))
vs2.shape
(40, 120)
va2 = cdutil.averager(vs2, axis='xy')
va2.shape
() ##### that is expected; I want a single value when I’m done
va2.data
array(73.2100605668346)

Other regions similar to Antarctica work ok (e.g. all of the Southern Hemisphere - -90, 0 to -180, 180.). Also, things that go negative to negative (e.g. Australia at -30, -20, 110, 145) work fine.

Thoughts? Am I doing something incorrect and getting lucky for the rest of the regions or is there something special about this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant