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.averager should print an error message when called with 'irregular' data #5

Open
chaosphere2112 opened this issue Nov 23, 2016 · 3 comments
Labels
kind/bug Bug in the software
Milestone

Comments

@chaosphere2112
Copy link

cdutil.averager should print an explicit error message when the data is on a grid it can't handle

Ideally, of course, cdutil.averager should be able to handle data on non-rectilinear grids!

One of our post-docs got the following when trying to get a global average of a CMIP5 file on the ORCA ocean grid. The sample data file (and other files with non rectilinear grids) can be downloaded from: https://files.lsce.ipsl.fr/public.php?service=files&t=ca134197a67c3cd311df6ede04747f6f

>>> import cdms2, cdutil

>>> f = cdms2.open('ORCA_grid_sample.nc')
Warning: bounds variable not found in ORCA_grid_sample.nc: time_centered_bounds
Warning: bounds variable not found in ORCA_grid_sample.nc: time_centered_bounds

>>> v = f('sosstsst', squeeze=1)

>>> v.shape
(149, 182)

>>> v.info()
*** Description of Slab sosstsst ***
id: sosstsst
shape: (149, 182)
filename: 
missing_value: 1e+20
comments: 
grid_name: grid_2
grid_type: CurvilinearGrid
time_statistic: 
long_name: sea surface temperature
units: degC
_FillValue: [  1.00000002e+20]
autoApiInfo: <AutoAPI.AutoAPI.Info instance at 0x7fa4dd4a8e60>
interval_write: 1mo
tileIndex: None
coordinates: time_centered nav_lon nav_lat
online_operation: average
cell_methods: time_counter: mean
interval_operation: 3600s
Grid has Python id 0x7fa4dd930850.
** Dimension 1 **
   id: y
   units:  
   Length: 149
   First:  0.0
   Last:   148.0
   Python id:  0x7fa4dd930890
** Dimension 2 **
   id: x
   units:  
   Length: 182
   First:  0.0
   Last:   181.0
   Python id:  0x7fa4dd930910
*** End of description for sosstsst ***

>>> global_average = cdutil.averager(v, axis='yx')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/install/cdat/versions/cdat_install_uv-2.1.0_x86_64_gcc4_VB_13/lib/python2.7/site-packages/genutil/averager.py", line 1042, in averager
    axis_order = _check_axisoptions(V, axis)
  File "/usr/local/install/cdat/versions/cdat_install_uv-2.1.0_x86_64_gcc4_VB_13/lib/python2.7/site-packages/genutil/averager.py", line 25, in _check_axisoptions
    raise AveragerError, 'Error: You have specified an invalid axis= option.'
genutil.averager.AveragerError: ('E', 'r', 'r', 'o', 'r', ':', ' ', 'Y', 'o', 'u', ' ', 'h', 'a', 'v', 'e', ' ', 's', 'p', 'e', 'c', 'i', 'f', 'i', 'e', 'd', ' ', 'a', 'n', ' ', 'i', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'a', 'x', 'i', 's', '=', ' ', 'o', 'p', 't', 'i', 'o', 'n', '.')

>>> global_average = cdutil.averager(v, axis='12')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/install/cdat/versions/cdat_install_uv-2.1.0_x86_64_gcc4_VB_13/lib/python2.7/site-packages/genutil/averager.py", line 1042, in averager
    axis_order = _check_axisoptions(V, axis)
  File "/usr/local/install/cdat/versions/cdat_install_uv-2.1.0_x86_64_gcc4_VB_13/lib/python2.7/site-packages/genutil/averager.py", line 25, in _check_axisoptions
    raise AveragerError, 'Error: You have specified an invalid axis= option.'
genutil.averager.AveragerError: ('E', 'r', 'r', 'o', 'r', ':', ' ', 'Y', 'o', 'u', ' ', 'h', 'a', 'v', 'e', ' ', 's', 'p', 'e', 'c', 'i', 'f', 'i', 'e', 'd', ' ', 'a', 'n', ' ', 'i', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'a', 'x', 'i', 's', '=', ' ', 'o', 'p', 't', 'i', 'o', 'n', '.')

Migrated from: CDAT/cdat#1464

@doutriaux1 doutriaux1 added this to the Next Release milestone Mar 29, 2018
@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 Aug 27, 2020
@durack1
Copy link
Member

durack1 commented Aug 27, 2020

@jasonb5 this is another issue which will require the same tweaks as CDAT/genutil#6

@github-actions github-actions bot removed the stale label Aug 27, 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 26, 2020
@jasonb5 jasonb5 added kind/bug Bug in the software and removed stale labels 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

4 participants