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 #42

Open
chaosphere2112 opened this issue Nov 22, 2016 · 1 comment
Open

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

chaosphere2112 opened this issue Nov 22, 2016 · 1 comment
Assignees

Comments

@chaosphere2112
Copy link
Contributor

(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

Migrated from: CDAT/cdat#1707

@durack1
Copy link
Member

durack1 commented Apr 26, 2017

@dnadeau4 @doutriaux1 it seems the following also fails, because grid is lost during the MV2.where operation:

import cdms2 as cdm
import MV2 as mv
# Load basinmask4
fB = cdm.open(modBMatch)
basinmask = fB('basinmask4')
atlMask = basinmask
atlMask = mv.where(basinmask==1,1,0)
pacMask = mv.where(basinmask==2,1,0)
# Load areacella
fA = cdm.open(modAMatch)
areacella = fA('areacella')
atlArea = areacella*atlMask <- this operation loses the grid

atlMask.getGrid()
Out[28]: 
Grid has Python id 0x7f16768b7a90.
Gridtype: generic
Grid shape: (145, 192)
Order: yx

atlArea.getGrid()
Out[29]:

And as a consequence I get the following error:

import vcs
x = vcs.init()
x.meshfill(atlArea)
Traceback (most recent call last):
  File "<ipython-input-27-fef7fa5b5005>", line 1, in <module>
    x.meshfill(atlArea)
  File "/export/durack1/anaconda2/envs/uvcdat280/lib/python2.7/site-packages/vcs/Canvas.py", line 1323, in meshfill
    arglist = _determine_arg_list('meshfill', args)
  File "/export/durack1/anaconda2/envs/uvcdat280/lib/python2.7/site-packages/vcs/Canvas.py", line 251, in _determine_arg_list
    raise vcsError("Meshfill requires 2 slab if first slab doesn't have a "
vcsError: Meshfill requires 2 slab if first slab doesn't have a Rectilinear, Curvilinear or Generic Grid type

@doutriaux1 doutriaux1 modified the milestone: 3.0 May 5, 2017
@doutriaux1 doutriaux1 assigned dnadeau4 and unassigned dnadeau4 May 5, 2017
@doutriaux1 doutriaux1 removed this from the 3.0 milestone 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

4 participants