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

timeAxis.clone() loses units #263

Closed
durack1 opened this issue Aug 8, 2018 · 4 comments
Closed

timeAxis.clone() loses units #263

durack1 opened this issue Aug 8, 2018 · 4 comments
Assignees
Milestone

Comments

@durack1
Copy link
Member

durack1 commented Aug 8, 2018

In [22]: f = '/work/durack1/Shared/obs_data/Argo/UCSD/180719_UCSD_monthly_TAndS_200401-201806_2p5-1975db.nc'
In [23]: fH = cdm.open(f)
In [24]: testAxes = fH['to'] <- This is a file handle reference
In [25]: timeAx = testAxes.getTime()
In [26]: timeAx
Out[26]: 
   id: time
   Designated a time axis.
   units:  days since 2004-1-1
   Length: 174
   First:  15.5
   Last:   5280.0
   Other axis attributes:
      long_name: time
      standard_name: time
      calendar: gregorian
      axis: T
   Python id:  0x7fe90c0a4490
In [27]: timeAx2 = timeAx.clone()
In [28]: timeAx2
Out[28]: 
   id: time
   Designated a time axis.
   units:  
   Length: 174
   First:  15.5
   Last:   5280.0
   Other axis attributes:
      realtopology: linear
      long_name: time
      standard_name: time
      calendar: gregorian
      axis: T
   Python id:  0x7fe90c1124d0

And file variable reference vs file variable load seems to be the issue:

In [34]: testAxes = fH('to') <- This is a file load, actual read, rather than reference
In [35]: timeAx = testAxes.getTime()
In [36]: type(timeAx)
Out[36]: cdms2.axis.TransientAxis
In [37]: timeAx
Out[37]: 
   id: time
   Designated a time axis.
   units:  days since 2004-1-1
   Length: 174
   First:  15.5
   Last:   5280.0
   Other axis attributes:
      realtopology: linear
      long_name: time
      standard_name: time
      calendar: gregorian
      axis: T
   Python id:  0x7fe90efa60d0
In [38]: timeAx2 = timeAx.clone()
In [39]: timeAx2
Out[39]: 
   id: time
   Designated a time axis.
   units:  days since 2004-1-1
   Length: 174
   First:  15.5
   Last:   5280.0
   Other axis attributes:
      realtopology: linear
      long_name: time
      standard_name: time
      calendar: gregorian
      axis: T
   Python id:  0x7fe90c112850

Conda env info:

(cdat80py2) duro@ocean:[8800]> ls anaconda2/envs/cdat80py2/conda-meta/cdtime*
anaconda2/envs/cdat80py2/conda-meta/cdtime-3.0-py27h6091dcd_1.json
(cdat80py2) duro@ocean:[8801]> ls anaconda2/envs/cdat80py2/conda-meta/cdms2*
anaconda2/envs/cdat80py2/conda-meta/cdms2-3.0.1-py27h6091dcd_1.json

As a quick debug, the little demo case works:

In [31]: data=[1,2,3,4]
    ...: t=cdm.createAxis(data,id="time")
    ...: t.units="days since 2001-01-01"
    ...: 
In [32]: b=t.clone()
    ...: b.units
    ...: 
Out[32]: 'days since 2001-01-01'
@dnadeau4
Copy link
Contributor

@durack1 It works with python 3.6

@durack1
Copy link
Member Author

durack1 commented Aug 15, 2018

@dnadeau4 does it work in python 2.7.15?

@dnadeau4
Copy link
Contributor

fix with #246

@durack1
Copy link
Member Author

durack1 commented Aug 16, 2018

Fixed by #267

cdms2: 3.0.2018.08.16.01.16.g9537541-py27h14c3975_0 cdat/label/unstable
cdms2: 3.0.2018.08.16.01.16.g9537541-py36h14c3975_0 cdat/label/unstable

@durack1 durack1 closed this as completed Aug 16, 2018
@doutriaux1 doutriaux1 added this to the 3.1 milestone Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants