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

cdms2.setAutoBounds('off') problem (OK with 'on') #98

Open
jypeter opened this issue Feb 28, 2017 · 2 comments
Open

cdms2.setAutoBounds('off') problem (OK with 'on') #98

jypeter opened this issue Feb 28, 2017 · 2 comments
Assignees
Milestone

Comments

@jypeter
Copy link
Member

jypeter commented Feb 28, 2017

@dnadeau4 and @doutriaux1 I'm using 2.8.0 and if I run the script at the end of this issue with the setAutoBounds line commented out, it works fine. But when the line is not commented, I get the following exception:

Processing year 1851 Tue Feb 28 17:23:05 2017
  Opening http://portal.nersc.gov/pydap/20C_Reanalysis_version2c_ensemble/first_guess.derived/t2m/t2m_1851.daily.nc
Traceback (most recent call last):
  File "/home/users/jypeter/CDAT/Progs/Devel/carmen/download_NERSC_data.py", line 36, in <module>
    longitude=longitude_range)
  File "/home/share/unix_files/cdat/miniconda2/envs/cdatm14/lib/python2.7/site-packages/cdms2/cudsinterface.py", line 33, in __call__
    return v(*args, **kwargs)
  File "/home/share/unix_files/cdat/miniconda2/envs/cdatm14/lib/python2.7/site-packages/cdms2/avariable.py", line 162, in __call__
    grid=grid)
  File "/home/share/unix_files/cdat/miniconda2/envs/cdatm14/lib/python2.7/site-packages/cdms2/selectors.py", line 176, in unmodified_select
    fetched = result.subRegion(*specifications)
  File "/home/share/unix_files/cdat/miniconda2/envs/cdatm14/lib/python2.7/site-packages/cdms2/avariable.py", line 931, in subRegion
    b = axis.getBounds(isGeneric) - delta_beg_wrap_dimvalue
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

If I specify 'on' instead of 'off', it works fine as well...

Can you check what's wrong? Thanks!

#!/usr/bin/env python

import time
import cdms2

var_name = 't2m'

time_select = slice(0, 1) # First time step
ensemble_select = slice(0, 1) # First member
#ensemble_select = slice(None, None) # ALL members
latitude_range = (22, 70)
longitude_range = (-80, 50)

year_start, year_end = 1851, 1853

download_url = 'http://portal.nersc.gov/pydap/20C_Reanalysis_version2c_ensemble/first_guess.derived'
save_path = '/home/scratch01/jypeter'

# Write NetCDF3 Classic
value = 0
cdms2.setNetcdfShuffleFlag(value) ## where value is either 0 or 1
cdms2.setNetcdfDeflateFlag(value) ## where value is either 0 or 1
cdms2.setNetcdfDeflateLevelFlag(value) ## where value is a integer between 0 and 9 included

cdms2.setAutoBounds('off')

for year in range(year_start, year_end + 1):
    print "Processing year", year, time.asctime()
    path_in = '%s/%s/%s_%i.daily.nc' % (download_url, var_name, var_name, year)
    print "  Opening", path_in
    f_in = cdms2.open(path_in)
    var_dap = f_in(var_name,
                   time=time_select,
                   ensemble_member=ensemble_select,
                   latitude=latitude_range,
                   longitude=longitude_range)
    f_in.close()

    path_out = '%s/%s_%i.extracted.daily.nc' % (save_path, var_name, year)
    f_out = cdms2.open(path_out, 'w')
    f_out.history = 'Data extracted by John Doe from %s' % (path_in,)
    f_out.write(var_dap)
    f_out.close()

# The end
@doutriaux1
Copy link
Contributor

hum... the default is 2 which means no autobounds except for lat/lon

@dnadeau4
Copy link
Contributor

dnadeau4 commented Mar 2, 2017

@jypeter netcdf4 is normal by default, you need to set netcdf3 flags. cdms2.setNetcdf4Flag`

https://github.com/UV-CDAT/cdms/blob/master/Lib/dataset.py#L183

For the autobounds, this seems to be a numpy 1.11 error after the upgrade.

@doutriaux1 doutriaux1 modified the milestone: 3.0 May 5, 2017
@doutriaux1 doutriaux1 assigned dnadeau4 and unassigned dnadeau4 May 5, 2017
@doutriaux1 doutriaux1 modified the milestones: 3.0, 3.1 Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants