Open chengzhuzhang opened 5 years ago
test_data_amip_r1i1p1_mo_regrid_3x3_sgp.nc.zip
Here is the data used for testing
@chengzhuzhang it looks like the error is coming from using squeeze in-correctly. Please try replacing last line of your code as below:
var_season = cdutil.ANNUALCYCLE.climatology(var)(squeeze=1)
var.shape
--> (324, 1, 1): monthly time series on one grid (or area-averaged)
ann = cdutil.ANNUALCYCLE.climatology(var)
ann.shape
--> (12, 1, 1): annual cycle of var
var_season = cdutil.ANNUALCYCLE.climatology(var)(squeeze=1)
var_season.shape
--> (12,): annual cycle of var, lat/lon dimensions removed
Thank you @lee1043. I talked to @dnadeau4 , it seems like using asma() also works. My question is, since the same line worked for an older version cdat2.10. Is it because cdat3.10 dropped support for squeeze() ?
@chengzhuzhang you're right it might needs a cleanup at the cdms level. @dnadeau4 what do you think?
@chengzhuzhang in my understanding asma
returns numpy array instead of transient variable; so you lose coordinate information. I think it might be still useful to keep var
type as transient variable.
>>> type(var)
<class 'cdms2.tvariable.TransientVariable'>
>>> var_season = cdutil.ANNUALCYCLE.climatology(var).asma()
>>> var_season.shape
(12, 1, 1)
>>> type(var_season)
<class 'numpy.ma.core.MaskedArray'>
I agree usage of squeeze seems not very clear in the current documents, for example: https://cdms.readthedocs.io/en/latest/search.html?q=squeeze&check_keywords=yes&area=default https://cdms.readthedocs.io/en/latest/generated/MV2.squeeze.html?highlight=squeeze
@doutriaux1 this could be a candidate for migration into the https://github.com/CDAT/cdutil issue list
Marking issue as stale, since there has been no activity in 30 days.
Unless the issue is updated or the 'stale' tag is removed, this issue will be closed in 7 days.
@jasonb5 I think this is still a valid bug? no
As discussed in an email with @doutriaux1 and @dnadeau4 the same function works in cdutil 2.10, while failed in cdutil 3.1.0
Below is the code:
Below is the error: