Skip to content
Snippets Groups Projects
Commit cd51247d authored by Nils Brüggemann's avatar Nils Brüggemann
Browse files

pyicon/view/pyicon_view_xr.py: Try to identify grid first by uuidOfHGrid,...

pyicon/view/pyicon_view_xr.py: Try to identify grid first by uuidOfHGrid, allow for specifying coordinates to enable plotting vertex variables, allow for plev (pressure levels) dimension.
parent b7a4da77
No related branches found
No related tags found
No related merge requests found
...@@ -91,6 +91,7 @@ class hplot_xr(object): ...@@ -91,6 +91,7 @@ class hplot_xr(object):
do_mask_big_triangles=False, do_mask_big_triangles=False,
title='auto', title='auto',
do_mask_zeros=True, do_mask_zeros=True,
coordinates='clat clon',
): ):
""" """
Parameters Parameters
...@@ -124,6 +125,8 @@ class hplot_xr(object): ...@@ -124,6 +125,8 @@ class hplot_xr(object):
do_mask_zeros: bool do_mask_zeros: bool
If set to 'True' then all data values which are exactly zero are masked. This is helpful for If set to 'True' then all data values which are exactly zero are masked. This is helpful for
plotting ocean data where land values are always zero. plotting ocean data where land values are always zero.
coordinates: str
Specify whether variable is defined on cell centers (default: 'clat clon'), on edges ('elat elon') or on vertices ('vlat vlon')
""" """
# ------------------------------------------------------------ # ------------------------------------------------------------
...@@ -137,6 +140,7 @@ class hplot_xr(object): ...@@ -137,6 +140,7 @@ class hplot_xr(object):
self.var = self.varnames[0] self.var = self.varnames[0]
self.title = title self.title = title
self.do_mask_zeros = do_mask_zeros self.do_mask_zeros = do_mask_zeros
self.coordinates = coordinates
# --- location # --- location
self.iz = 0 self.iz = 0
self.step_snap = 0 self.step_snap = 0
...@@ -150,7 +154,11 @@ class hplot_xr(object): ...@@ -150,7 +154,11 @@ class hplot_xr(object):
self.use_tgrid = True self.use_tgrid = True
else: else:
self.use_tgrid = False self.use_tgrid = False
Dgrid = pyic.identify_grid(path_grid, self.ds) try:
uuidOfHGrid = ds.attrs['uuidOfHGrid']
except:
uuidOfHGrid = 'none'
Dgrid = pyic.identify_grid(path_grid, self.ds, uuidOfHGrid=uuidOfHGrid)
self.Dgrid = Dgrid self.Dgrid = Dgrid
if fpath_ckdtree=='auto': if fpath_ckdtree=='auto':
if 'res0.30_180W-180E_90S-90N' in Dgrid['Drectgrids'].keys(): if 'res0.30_180W-180E_90S-90N' in Dgrid['Drectgrids'].keys():
...@@ -169,8 +177,8 @@ class hplot_xr(object): ...@@ -169,8 +177,8 @@ class hplot_xr(object):
else: else:
self.fpath_tgrid = fpath_tgrid self.fpath_tgrid = fpath_tgrid
self.do_mask_big_triangles = do_mask_big_triangles self.do_mask_big_triangles = do_mask_big_triangles
#if self.use_tgrid: if self.use_tgrid:
if True: #if True:
#self.make_triangulation() #self.make_triangulation()
ds_tgrid = xr.open_dataset(self.fpath_tgrid) ds_tgrid = xr.open_dataset(self.fpath_tgrid)
self.ind_reg, self.Tri = pyic.triangulation( self.ind_reg, self.Tri = pyic.triangulation(
...@@ -345,6 +353,9 @@ class hplot_xr(object): ...@@ -345,6 +353,9 @@ class hplot_xr(object):
elif 'height_2' in arr.dims: elif 'height_2' in arr.dims:
arr = arr.isel(height_2=self.iz) arr = arr.isel(height_2=self.iz)
self.lev_name = 'height_2' self.lev_name = 'height_2'
elif 'plev' in arr.dims:
arr = arr.isel(plev=self.iz)
self.lev_name = 'plev'
else: else:
self.lev_name = 'none' self.lev_name = 'none'
# --- mask land values (necessary for ocean data) # --- mask land values (necessary for ocean data)
...@@ -356,7 +367,7 @@ class hplot_xr(object): ...@@ -356,7 +367,7 @@ class hplot_xr(object):
if self.grid_type=='igrid': if self.grid_type=='igrid':
self.diag_out('interp_to_rectgrid') self.diag_out('interp_to_rectgrid')
try: try:
arr = pyic.interp_to_rectgrid_xr(arr, self.fpath_ckdtree, lon_reg=self.lon_reg, lat_reg=self.lat_reg) arr = pyic.interp_to_rectgrid_xr(arr, self.fpath_ckdtree, lon_reg=self.lon_reg, lat_reg=self.lat_reg, coordinates=self.coordinates)
self.diag_out('no error with interpolation') self.diag_out('no error with interpolation')
except: except:
self.diag_out('error with interpolation') self.diag_out('error with interpolation')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment