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.getGrid()/setGrid() doesn't work #1707

Closed
durack1 opened this Issue Nov 25, 2015 · 6 comments

Comments

Projects
None yet
3 participants
@durack1
Member

durack1 commented Nov 25, 2015

(Pdb) print s.getGrid()
<CurveGrid, id: grid_37, shape: (384, 320)>
(Pdb) heatContent.setGrid(s.getGrid())
*** CDMSError: grid does not match axes for variable variable_524300
(Pdb) heatContent.shape
(60, 384, 320)
(Pdb) print s.shape
(60, 384, 320)
(Pdb) print s.getGrid().shape
(384, 320)
(Pdb) print cdm.createGenericGrid(s.getLatitude(),s.getLongitude(),order='yx')
*** ValueError: could not broadcast input array from shape (384,320) into shape (384)
(Pdb) print cdm.createGenericGrid(s.getLatitude(),s.getLongitude(),order='xy')
*** ValueError: could not broadcast input array from shape (384,320) into shape (384)
(Pdb) print s.getGrid().clone()
<CurveGrid, id: grid_37, shape: (384, 320)>
(Pdb) heatContent.setGrid(s.getGrid().clone())
*** CDMSError: grid does not match axes for variable variable_524300

@durack1 durack1 added cdms2 Bug labels Nov 25, 2015

@durack1 durack1 added this to the 3.0 milestone Nov 25, 2015

@chaosphere2112

This comment has been minimized.

Contributor

chaosphere2112 commented Nov 15, 2016

@dnadeau4 @durack1 createGenericGrid is a lie; it's actually creating a rectangular grid. The reason setGrid doesn't work is because clone() instantiates new axes, and the setGrid() function checks that the axes on the grid are the same python objects as the ones on the variable. I feel like just making sure they're the same shape should be enough, but no scientist am I.

@durack1

This comment has been minimized.

Member

durack1 commented Nov 15, 2016

@chaosphere2112 I'm not sure I get all the subtleties in the above, however in addition to a shape check a min/max bounds check of both grid lats/lons would be a good way to sanity check things.. happy to provide more in depth feedback if you like

@dnadeau4

This comment has been minimized.

Contributor

dnadeau4 commented Nov 15, 2017

@durack1 can you give me a file with these grids.

@dnadeau4

This comment has been minimized.

Contributor

dnadeau4 commented Nov 15, 2017

46b27f5cc9314da268119dee2b2d15115463439e

@dnadeau4

This comment has been minimized.

Contributor

dnadeau4 commented Nov 15, 2017

import cdms2
import numpy
f=cdms2.open("/software/anaconda3/envs/cdms3/share/uvcdat/sample_data/so_Omon_ACCESS1-0_historical_r1i1p1_185001-185412_2timesteps.nc")
f.listvariables()
data=f('so')

grid=data.getGrid()
bb=numpy.zeros((300,360))
bb=cdms2.tvariable.TransientVariable(bb)
bb.setGrid(cdms2.hgrid.TransientCurveGrid(data.getLatitude(), data.getLongitude()))
curvgrid=cdms2.hgrid.TransientCurveGrid(data.getLatitude(), data.getLongitude())

@dnadeau4 dnadeau4 referenced this issue Nov 15, 2017

Merged

fix setGrid #193

@durack1

This comment has been minimized.

Member

durack1 commented Nov 16, 2017

@dnadeau4 great, so all fixed? I assume you've run this across a couple of the test data - the so_Omon* file should have a bunch of others alongside it.

@dnadeau4 dnadeau4 reopened this Nov 29, 2017

dnadeau4 added a commit to CDAT/cdms that referenced this issue Nov 30, 2017

dnadeau4 added a commit to CDAT/cdms that referenced this issue Nov 30, 2017

@dnadeau4 dnadeau4 closed this Nov 30, 2017

dnadeau4 added a commit to CDAT/cdms that referenced this issue Nov 30, 2017

Issue 1707 curvsetaxis (#199)
* fix setGrid

* add squeeze array to MV2

* pinned libnetcdf=4.4.1.1=9

* pinned libnetcdf=4.4.1.1=9 for MAC

* fix documentation for squeeze

* fix ci machines

* flake8

* fix squeeze CDAT/cdat/issues/1707

* fix squeeze CDAT/cdat/issues/1707

* fix ci netcdf-fortran

* fix ci netcdf-fortran to number 4.4.4=5

* flake8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment