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

cdscan xml from multiple files dropped time axis bounds --> cdutil.YEAR fails #1646

Open
bhayes84 opened this issue Oct 28, 2015 · 2 comments
Assignees
Labels

Comments

@bhayes84
Copy link

This is on a Ubuntu 14.04.3 system with uvcdat 2.1.0.
I see the same failure on a vm with Ubuntu 13.10 with uvcdat 1.5.0-rc5.

When I used cdscan for two .nc files, the resulting xml no longer contains time axis bounds which makes the cdutil.YEAR function fail:

ev_mean = cdutil.YEAR(ev)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/uvcdat/2.1.0/lib/python2.7/site-packages/cdutil/times.py", line 1286, in get
s.append(TimeSlicer.get(self,slab,season,criteriaarg,statusbar=statusbar,sum=sum))
File "/usr/local/uvcdat/2.1.0/lib/python2.7/site-packages/cdutil/times.py", line 383, in get
slices,bounds,norm=self.slicer(tim,slicerarg)
File "/usr/local/uvcdat/2.1.0/lib/python2.7/site-packages/cdutil/times.py", line 631, in monthBasedSlicer
b0=cdtime.reltime(bnds[i][0],units)
TypeError: 'NoneType' object has no attribute 'getitem'

I am able to use cdutil.YEAR on each of the .nc files individually (and confirmed that they have bounds on their time axes).

I include output below showing the xml failure and the success on the two .nc files.
I also show the var info for the two individual .nc files.

------------ example code ----------------------------

bhayes@dge-calc:.../CESM1-CAM5/r1i1p1$ cdscan -x ev.xml evspsbl_Amon*
Finding common directory ...
Common directory:
Scanning files ...
evspsbl_Amon_CESM1-CAM5_rcp26_r1i1p1_200601-210012.nc
Setting reference time units to days since 2006-01-01 00:00:00
evspsbl_Amon_CESM1-CAM5_rcp26_r1i1p1_210101-230012.nc
Setting reference time units to days since 2006-01-01 00:00:00
ev.xml written

bhayes@dge-calc:.../CESM1-CAM5/r1i1p1$ cdat
Python 2.7.8 (default, Jan 14 2015, 10:22:34)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import cdms2 as cdms
import cdutil
f = cdms.open('ev.xml')
f.variables.keys()
['time_bnds', 'lat_bnds', 'evspsbl', 'lon_bnds']
ev = f('evspsbl')
ev.shape
(3540, 192, 288)
ev_mean = cdutil.YEAR(ev)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/uvcdat/2.1.0/lib/python2.7/site-packages/cdutil/times.py", line 1286, in get
s.append(TimeSlicer.get(self,slab,season,criteriaarg,statusbar=statusbar,sum=sum))
File "/usr/local/uvcdat/2.1.0/lib/python2.7/site-packages/cdutil/times.py", line 383, in get
slices,bounds,norm=self.slicer(tim,slicerarg)
File "/usr/local/uvcdat/2.1.0/lib/python2.7/site-packages/cdutil/times.py", line 631, in monthBasedSlicer
b0=cdtime.reltime(bnds[i][0],units)
TypeError: 'NoneType' object has no attribute 'getitem'

ta = ev.getAxis(0)
ta.shape
(3540,)
tab = ta.getBounds()
type(tab)
<type 'NoneType'>

----------- mean for file 1 ---------

f1 = cdms.open('evspsbl_Amon_CESM1-CAM5_rcp26_r1i1p1_200601-210012.nc')
ev1 = f1('evspsbl')
ev1_mean = cdutil.YEAR(ev1)
ev1_mean.shape
(95, 192, 288)

f1.close()
ta1 = ev1.getAxis(0)
tab1 = ta1.getBounds()
type(tab1)
<type 'numpy.ndarray'>
tab1.shape
(1140, 2)

----------------- mean for file 2 -----

f2 = cdms.open('evspsbl_Amon_CESM1-CAM5_rcp26_r1i1p1_210101-230012.nc')
ev2 = f2('evspsbl')
ev2.shape
(2400, 192, 288)
ev2_means = cdutil.YEAR(ev2)
ev2_means.shape
(200, 192, 288)
ta2 = ev2.getAxis(0)
tab2 = ta2.getBounds()
type(tab2)
<type 'numpy.ndarray'>
tab2.shape
(2400, 2)

-------------- ev1 info ------------------

ev1.info()
*** Description of Slab evspsbl ***
id: evspsbl
shape: (1140, 192, 288)
filename:
missing_value: 1e+20
comments:
grid_name:
grid_type: generic
time_statistic:
long_name: Evaporation
units: kg m-2 s-1
comment: QFLX no change, CMIP5_table_comment: at surface; flux of water into the atmosphere due to conversion of both liquid and solid phases to vapor (from underlying surface and vegetation)
_FillValue: [ 1.00000002e+20]
autoApiInfo: <AutoAPI.AutoAPI.Info instance at 0x7efcc240ef38>
tileIndex: None
original_name: QFLX
associated_files: baseURL: http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile: gridspec_atmos_fx_CESM1-CAM5_rcp26_r0i0p0.nc areacella: areacella_fx_CESM1-CAM5_rcp26_r0i0p0.nc
standard_name: water_evaporation_flux
cell_methods: time: mean (interval: 30 days)
cell_measures: area: areacella
original_units: kg/m2/s
history: 2012-06-08T23:37:19Z altered by CMOR: Converted units from 'kg/m2/s' to 'kg m-2 s-1'. 2012-06-08T23:37:19Z altered by CMOR: Reordered dimensions, original order: lat lon time. 2012-06-08T23:37:19Z altered by CMOR: replaced missing value flag (-1e+32) with standard missing value (1e+20).
Grid has Python id 0x7efcc241b050.
Gridtype: generic
Grid shape: (192, 288)
Order: yx
** Dimension 1 **
id: time
Designated a time axis.
units: days since 2006-01-01 00:00:00
Length: 1140
First: 15.5
Last: 34659.5
Other axis attributes:
long_name: time
standard_name: time
calendar: noleap
axis: T
Python id: 0x7efcc241b890
** Dimension 2 **
id: lat
Designated a latitude axis.
units: degrees_north
Length: 192
First: -90.0
Last: 90.0
Other axis attributes:
long_name: latitude
standard_name: latitude
axis: Y
Python id: 0x7efcc241b910
** Dimension 3 **
id: lon
Designated a longitude axis.
units: degrees_east
Length: 288
First: 0.0
Last: 358.75
Other axis attributes:
modulo: 360.0
long_name: longitude
standard_name: longitude
axis: X
topology: circular
Python id: 0x7efcc241b990
*** End of description for evspsbl ***

---------- ev2 info ---------------------

...
ev2.info()
*** Description of Slab evspsbl ***
id: evspsbl
shape: (2400, 192, 288)
filename:
missing_value: 1e+20
comments:
grid_name:
grid_type: generic
time_statistic:
long_name: Evaporation
units: kg m-2 s-1
comment: QFLX no change, CMIP5_table_comment: at surface; flux of water into the atmosphere due to conversion of both liquid and solid phases to vapor (from underlying surface and vegetation)
_FillValue: [ 1.00000002e+20]
autoApiInfo: <AutoAPI.AutoAPI.Info instance at 0x7efcc24236c8>
tileIndex: None
original_name: QFLX
associated_files: baseURL: http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile: gridspec_atmos_fx_CESM1-CAM5_rcp26_r0i0p0.nc areacella: areacella_fx_CESM1-CAM5_rcp26_r0i0p0.nc
standard_name: water_evaporation_flux
cell_methods: time: mean (interval: 30 days)
cell_measures: area: areacella
original_units: kg/m2/s
history: 2012-06-15T22:28:22Z altered by CMOR: Converted units from 'kg/m2/s' to 'kg m-2 s-1'. 2012-06-15T22:28:22Z altered by CMOR: Reordered dimensions, original order: lat lon time. 2012-06-15T22:28:22Z altered by CMOR: replaced missing value flag (-1e+32) with standard missing value (1e+20).
Grid has Python id 0x7efcc241bf50.
Gridtype: generic
Grid shape: (192, 288)
Order: yx
** Dimension 1 **
id: time
Designated a time axis.
units: days since 2100-01-01 00:00:00
Length: 2400
First: 380.5
Last: 73349.5
Other axis attributes:
long_name: time
standard_name: time
calendar: noleap
axis: T
Python id: 0x7efcc241bf10
** Dimension 2 **
id: lat
Designated a latitude axis.
units: degrees_north
Length: 192
First: -90.0
Last: 90.0
Other axis attributes:
long_name: latitude
standard_name: latitude
axis: Y
Python id: 0x7efcc241b850
** Dimension 3 **
id: lon
Designated a longitude axis.
units: degrees_east
Length: 288
First: 0.0
Last: 358.75
Other axis attributes:
modulo: 360.0
long_name: longitude
standard_name: longitude
axis: X
topology: circular
Python id: 0x7efcc2437150
*** End of description for evspsbl ***

@doutriaux1
Copy link
Contributor

confirmed in master here as well.

In the mean time please use cdutil.setTimeBoundsMonthly(ev2)

@doutriaux1 doutriaux1 added this to the 2.4 milestone Oct 28, 2015
@doutriaux1
Copy link
Contributor

@dnadeau4 on crunchy use:

cdscan -x charles.xml /cmip5_css02/data/cmip5/output1/NCAR/CCSM4/amip/mon/atmos/Amon/r7i1p1/evspsbl/1/*.nc

@painter1 painter1 assigned painter1 and unassigned dnadeau4 Oct 28, 2015
@doutriaux1 doutriaux1 modified the milestones: 2.6, 2.4 Jan 4, 2016
@doutriaux1 doutriaux1 modified the milestones: 3.0, 2.6 May 25, 2016
@doutriaux1 doutriaux1 modified the milestones: 3.0, 3.2 Mar 29, 2019
@downiec downiec removed this from the 8.2 milestone Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants