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

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

cdms2.getGrid()/setGrid() doesn't work #1707

durack1 opened this issue Nov 25, 2015 · 6 comments
Assignees
Milestone

Comments

@durack1
Copy link
Member

@durack1 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
@chaosphere2112
Copy link
Contributor

@chaosphere2112 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
Copy link
Member Author

@durack1 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
Copy link
Contributor

@dnadeau4 dnadeau4 commented Nov 15, 2017

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

@dnadeau4
Copy link
Contributor

@dnadeau4 dnadeau4 commented Nov 15, 2017

46b27f5cc9314da268119dee2b2d15115463439e

@dnadeau4
Copy link
Contributor

@dnadeau4 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())

@durack1
Copy link
Member Author

@durack1 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
* 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants