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

cdutil.ANNUALCYCLE.climatology() failed in cdutil 3.1.0 #44

Open
chengzhuzhang opened this issue Feb 8, 2019 · 10 comments
Open

cdutil.ANNUALCYCLE.climatology() failed in cdutil 3.1.0 #44

chengzhuzhang opened this issue Feb 8, 2019 · 10 comments
Labels
kind/bug Bug in the software

Comments

@chengzhuzhang
Copy link

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:

import cdms2
import cdutil

filename = 'test_data_amip_r1i1p1_mo_regrid_3x3_sgp.nc'
fin = cdms2.open(filename)
var = fin('tas')
cdutil.setTimeBoundsMonthly(var)
var_season = cdutil.ANNUALCYCLE.climatology(var).squeeze()

Below is the error:

Traceback (most recent call last):
  File "cdutil_test.py", line 8, in <module>
    var_season = cdutil.ANNUALCYCLE.climatology(var).squeeze()
  File "/Users/zhang40/anaconda2/envs/arm_diags_env_0207_1/lib/python2.7/site-packages/cdms2/avariable.py", line 1706, in squeeze
    return(MV.squeeze(self))
  File "/Users/zhang40/anaconda2/envs/arm_diags_env_0207_1/lib/python2.7/site-packages/cdms2/MV2.py", line 352, in squeeze
    maresult, axes=axes, attributes=attributes, grid=grid, id=id)
  File "/Users/zhang40/anaconda2/envs/arm_diags_env_0207_1/lib/python2.7/site-packages/cdms2/tvariable.py", line 203, in __init__
    self.initDomain(axes, copyaxes=copyaxes)
  File "/Users/zhang40/anaconda2/envs/arm_diags_env_0207_1/lib/python2.7/site-packages/cdms2/tvariable.py", line 357, in initDomain
    raise CDMSError("Wrong number of axes to initialize domain.")
cdms2.error.CDMSError: Wrong number of axes to initialize domain.

@chengzhuzhang
Copy link
Author

chengzhuzhang commented Feb 8, 2019

test_data_amip_r1i1p1_mo_regrid_3x3_sgp.nc.zip

Here is the data used for testing

@lee1043
Copy link

lee1043 commented Feb 19, 2019

@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)

@lee1043
Copy link

lee1043 commented Feb 19, 2019

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

@chengzhuzhang
Copy link
Author

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() ?

@doutriaux1
Copy link
Contributor

@chengzhuzhang you're right it might needs a cleanup at the cdms level. @dnadeau4 what do you think?

@lee1043
Copy link

lee1043 commented Feb 19, 2019

@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'>

@lee1043
Copy link

lee1043 commented Feb 19, 2019

@durack1
Copy link
Member

durack1 commented Mar 18, 2019

@doutriaux1 this could be a candidate for migration into the https://github.com/CDAT/cdutil issue list

@jasonb5 jasonb5 transferred this issue from CDAT/cdat Aug 18, 2020
@github-actions
Copy link

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.

@github-actions github-actions bot added the stale label Sep 17, 2020
@durack1
Copy link
Member

durack1 commented Sep 17, 2020

@jasonb5 I think this is still a valid bug? no

@github-actions github-actions bot removed the stale label Sep 18, 2020
@jasonb5 jasonb5 added the kind/bug Bug in the software label Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bug in the software
Projects
None yet
Development

No branches or pull requests

5 participants