Forums » Operator News »
reducegrid - limit fields to a horizontal mask
Added by Ralf Mueller over 8 years ago
- Table of contents
- Reducing to subgrid - based on topography
- Reducing to subgrid - based on coordinates
- Reducing to subgrid - based on temperature
- Data reduction
- reduce data files
- create new grids out of existing ones
Reducing to subgrid - based on topography¶
Lets start with an example on a regular grid: Suppose there is data on a horizontal grid and only the land points are relevant. Hence 2/3 of the grid points are superfluous.
For better visibility I choose a very coarse grid: r18x9. The input must be on the same grid - I use the internal topography for this
cdo -f nc -topo,r18x9 topo_r18x9.nc
Same for the mask
cdo -f nc -gtc,0 -topo,r18x9 mask_r18x9.ncNow lets reduce the topography to the non-zero values, i.e. the land locations of the input file
cdo -reducegrid,mask_r18x9.nc topo_r18x9.nc reduced_topo_r18x9.ncThis look like this:
Looks strange, but the south pole is visible, whereas the north pole is pure water.
Reducing to subgrid - based on coordinates¶
The next input grid is a more realistic: A global 160km ICON grid. The mask is created wrt. to coordinates with the expr
operator
cdo -f nc -expr,'mask=sin(clon(const)); mask=(abs(mask) > 0.5)' -remapnn,iconModelOutput.nc -const,0,r1400x720 imask.nc
Now I reduce a temperature field to that grid with
cdo -C -v -reducegrid,imask.nc iconGlobalTemp.nc maskedIconTemperature.ncIn paraview this looks like this
Reducing to subgrid - based on temperature¶
The last example is based on the GME grid, a hexagonal grid used for weather prediction at DWD. Again I use temperture for data
cdo -temp,ni96 temp_gme.grb
But the mask is based on that data: I want to cut out all locations with zero or negative temperature
cdo -gtc,0 temp_gme.grb mask_gme.grb
The reduction is called just like in the other examples. But the output format has to set to NetCDF, because general unstructured grids cannot be stored in GRIB1 or GRIB2 format.
cdo -f nc reducegrid,mask_gme.grb temp_gme.grb masked_temp_gme.nc
The resulting fields looks like this
Data reduction¶
For pure data reduction, user can decide to avoid coordinate bounds or coordinates at all:
- coordinates are completely ignored in the output, if nocoords is given
cdo -v reducegrid,<mask>,nocoords <ifile> <ofile>
- if only the bounds should be suppressed, but coordinates are needed, use nobounds instead
cdo -v reducegrid,<mask>,nobounds <ifile> <ofile>
NOTE, that this limits the usability of the output files: Without coordinates or bounds operations that involve data location are no longer possible, e.g. spacial averaging, geographical selection, ... If needed, the grid can be added later with the setgrid
operator.
If you have any other ideas on how to use this operator, please share!
cheers
ralf
topo_reduced.png (25.7 KB) topo_reduced.png | |||
icon_reduced.png (103 KB) icon_reduced.png | |||
gme_reduced.png (228 KB) gme_reduced.png | |||
gme_reduced2Land.png (86.3 KB) gme_reduced2Land.png | |||
gme_reduced2Land_zoom.png (168 KB) gme_reduced2Land_zoom.png | |||
icon_reduced_zoom.png (132 KB) icon_reduced_zoom.png |