Skip to content

Commit 2545749

Browse files
committed
Add CDO example
1 parent 35ba88c commit 2545749

1 file changed

Lines changed: 57 additions & 3 deletions

File tree

04-regrid.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ and works with global and limited-area meshes.
1818

1919
pyremap [is available](https://mpas-dev.github.io/pyremap/2.1.0/quick_start.html#installation) on conda-forge.
2020

21+
In the below example, we use the data we downloaded in {ref}`viz`.
22+
2123
```{include} pyremap-example.py
2224
:lang: python
2325

2426
```
2527

28+
(nco)=
29+
2630
## NCO
2731

2832
[NCO](https://nco.sourceforge.net/) [ncremap](https://nco.sourceforge.net/nco.html#ncremap-netCDF-Remapper)
@@ -33,11 +37,11 @@ provides many facilities for regridding.
3337
the TempestRemap CLI[^trcli],
3438
the MOAB CLI[^mbcli], or internal routines[^nco-internal]
3539
- ERWG and MOAB can use multiple processors with `--mpi_nbr=<n>`
36-
- To apply weights:
37-
- `ncks -m map.nc --rgr`
40+
- To apply weights, there are multiple ways, but `ncremap` is the most straightforward:
3841
- `ncremap -P mpasa -m map.nc in.nc out.nc`
3942
- `-P mpasa` (not always necessary) was added in NCO v5.2.6 (2024-06-20)
4043
- `ncremap --pdq=Time,nVertLevels,nIsoLevelsT,nIsoLevelsZ,nCells -m map.nc in.nc out.nc`
44+
- `ncks -m map.nc --rgr` (a variant of this command gets called by `ncremap`)
4145

4246
[^trcli]:
4347
`GenerateOverlapMesh` (overlay the source and destination meshes and compute intersections),
@@ -51,6 +55,8 @@ provides many facilities for regridding.
5155
`-a nco_con` (first-order conservative),
5256
`-a nco_idw` (inverse distance weighting, can extrapolate)
5357

58+
(nco-examples)=
59+
5460
### Examples
5561

5662
On Casper/Derecho:
@@ -69,7 +75,18 @@ ln -s x1.2562.static.nc static.nc
6975
[MPAS-Tools](https://github.com/MPAS-Dev/MPAS-Tools)
7076
provides multiple ways to convert grid specs in the MPAS format to SCRIP format.
7177

72-
`scrip_from_mpas` is available when you install the `mpas_tools` conda-forge package.
78+
`scrip_from_mpas` is available when you install the `mpas_tools` conda-forge package [^cf].
79+
80+
[^cf]: On Casper/Derecho:
81+
82+
```bash
83+
module load conda/latest
84+
```
85+
86+
```bash
87+
mamba create -n mpas_tools -c conda-forge mpas_tools
88+
conda activate mpas_tools
89+
```
7390

7491
```bash
7592
# scrip_from_mpas requires [0, 2π) longitudes
@@ -143,6 +160,28 @@ or [MOAB](https://sigma.mcs.anl.gov/category/moab/) directly instead of through
143160
144161
## CDO
145162
163+
On Casper/Derecho:
164+
165+
```bash
166+
module load cdo
167+
```
168+
169+
Global regridding with CDO is straightforward.
170+
As in the [NCO example](#nco-examples), we can use the data from {ref}`viz`,
171+
aliased to `grid.nc` and `static.nc`.
172+
173+
```bash
174+
# Generate weights for a 0.25-degree regular lat-lon grid (SCRIP format)
175+
# (lon centers 0--359.75; lat centers -89.875--89.875)
176+
cdo gencon,r1440x720 -setgrid,mpas:grid.nc -selgrid,1 grid.nc map_con.nc
177+
178+
# Apply weights
179+
cdo remap,r1440x720,map_con.nc -selvar,ter -setgrid,mpas:grid.nc static.nc out_con.nc
180+
```
181+
182+
`genbil` (bilinear) doesn't support unstructured grids.
183+
But `gennn` (nearest neighbor) does.
184+
146185
(convert_mpas)=
147186

148187
## convert_mpas
@@ -154,8 +193,23 @@ to convert to a 0.5°x0.5° regular lat-lon grid (or other rectangular lat-lon g
154193
Provided by the MPAS-A lead developer,
155194
and used in [the official virtual tutorial](https://www2.mmm.ucar.edu/projects/mpas/tutorial/Virtual2025/).
156195

196+
To obtain it:
197+
198+
```bash
199+
git clone https://github.com/mgduda/convert_mpas
200+
cd convert_mpas
201+
make
202+
export PATH="$PWD:$PATH"
203+
```
204+
205+
Now we can use the `convert_mpas` command[^rc].
206+
207+
[^rc]: For the current shell session. Add an `export` line to your `.bashrc` to make it permanent.
208+
157209
### Examples
158210

211+
Here we use the data from our global run in {ref}`run`.
212+
159213
```bash
160214
# Default 0.5-degree global, one file
161215
convert_mpas x1.10242.init.nc diag.2017-09-20_12.00.00.nc

0 commit comments

Comments
 (0)