regional masks not supported? #25
-
|
I've been working on adding a regional mask for a Gulf of Mexico RRM to do some statistical analysis. My goal is to plot the masked output with mosaic as a QC check, which fails. See below a successful example with Preliminaries: The contents of the mask file look like: Working example with scatter: Plot with mosaic |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Hey @dylanschlichting! Thanks for using Yes, So, all you'd need to change is the reading in of the dataset bloc of code to be something like: #GoM regional mask
pathm = '/usr/projects/climate/dschlichting/repos/analysis_notebooks/gom1pt5/gom1pt5_gom_mask.nc'
mask = xr.open_dataset(pathm)
iGoM = mask.regionCellMasks[:, 0] == 1
# indices of cells within regional mask
idxGoM = mask.nCells.where(iGoM, drop=True).astype(int)
#HF output
path = '/lustre/scratch5/dschlichting/E3SM/scratch/chicoma-cpu/Tl319_GoM1pt5_GMPAS-IAF_norivers/run/Tl319_GoM1pt5_GMPAS-IAF.mpaso.hist.am.highFrequencyOutput.1997-0*-01_00.00.00.nc'
ds = xr.open_mfdataset(glob.glob(path), concat_dim="Time", combine = 'nested')
ds = ds.sortby(ds.xtime)
ds = ds.isel(nCells = idxGoM)
ds
#Initial condition
pathi = '/lustre/scratch5/dschlichting/runs/gom1pt5r2/ocean/global_ocean/GoM5/WOA23/init/initial_state/initial_state.nc'
dsi = xr.open_dataset(pathi)
dsi = dsi.isel(nCells = idxGoM)where I've moved the reading in of the mask to the top, and added one final step where the region mask gets converted to an index array of cells within the region ( Then the mosaic block you have above should pretty much work as expected, all you'd need to do is remove the masking of data array in the call to ...
m1 = mosaic.polypcolor(ax, descriptor, rv.isel(Time=t),
antialiaseds=False, cmap = cmo.balance, vmin = -1, vmax = 1)
... |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for bringing this up! While
|
Beta Was this translation helpful? Give feedback.
-
|
Here are some existing region masks: |
Beta Was this translation helpful? Give feedback.



Hey @dylanschlichting! Thanks for using
mosaicand putting it through it's paces.Yes,
mosaicis capable of doing the regional plotting you're looking for but, it does not per se support regional masks. Instead it supports regionally masked datasets. In short, you'll need to make theDescriptorobject from a masked dataset, so that the descriptor and the data array being plotted have the same dimensions (i.e. samenVertices).So, all you'd need to change is the reading in of the dataset bloc of code to be something like: