Skip to content

Commit ff40e31

Browse files
committed
A working NCO example
same data as in the Viz nb
1 parent 99ccb79 commit ff40e31

4 files changed

Lines changed: 79 additions & 18 deletions

File tree

01-compile.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Build
33
subtitle: Building MPAS on NSF NCAR Derecho
4+
label: build
45
---
56

67
First we need to clone the model repository.

02-run.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Run
33
subtitle: Running MPAS on NSF NCAR Derecho
4+
label: run
45
---
56

67
# Global

03-viz.ipynb

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"---\n",
1515
"title: Viz\n",
1616
"subtitle: Visualizing native-grid output in Python\n",
17+
"label: viz\n",
1718
"---"
1819
]
1920
},
@@ -80,6 +81,22 @@
8081
"_ = xr.set_options(display_expand_data=False)"
8182
]
8283
},
84+
{
85+
"cell_type": "markdown",
86+
"id": "ee1cdea6-92e7-4e1d-9cd9-f0e1023f3679",
87+
"metadata": {
88+
"editable": true,
89+
"slideshow": {
90+
"slide_type": ""
91+
},
92+
"tags": []
93+
},
94+
"source": [
95+
"First we fetch an example global mesh: `x1.2562` (~ 480-km resolution;\n",
96+
"chosen for its small file size and quickness to plot).\n",
97+
"Note that the uniform global meshes are really _quasi_-uniform."
98+
]
99+
},
83100
{
84101
"cell_type": "code",
85102
"execution_count": null,
@@ -121,20 +138,6 @@
121138
" return p_grid, p_static"
122139
]
123140
},
124-
{
125-
"cell_type": "markdown",
126-
"id": "ee1cdea6-92e7-4e1d-9cd9-f0e1023f3679",
127-
"metadata": {
128-
"editable": true,
129-
"slideshow": {
130-
"slide_type": ""
131-
},
132-
"tags": []
133-
},
134-
"source": [
135-
"The uniform global meshes are only mostly uniform (_quasi_-uniform)."
136-
]
137-
},
138141
{
139142
"cell_type": "code",
140143
"execution_count": null,

04-regrid.md

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
---
22
title: Regrid
33
subtitle: Tools for regridding MPAS-A output to regular lat-lon grids
4+
label: regrid
45
---
56

67
# Options
78

9+
(pyremap)=
10+
811
## pyremap
912

1013
[pyremap](https://mpas-dev.github.io/pyremap/main/remapper/index.html)
@@ -43,13 +46,65 @@ provides many facilities for regridding.
4346

4447
### Examples
4548

49+
On Casper/Derecho:
50+
51+
```bash
52+
module load nco
53+
```
54+
55+
Let's use the grid data we downloaded in {ref}`viz`.
56+
57+
```bash
58+
ln -s x1.2562.grid.nc grid.nc
59+
ln -s x1.2562.static.nc static.nc
60+
```
61+
62+
[MPAS-Tools](https://github.com/MPAS-Dev/MPAS-Tools)
63+
provides multiple ways to convert grid specs in the MPAS format to SCRIP format.
64+
65+
`scrip_from_mpas` is available when you install the `mpas_tools` conda-forge package.
66+
67+
```bash
68+
# scrip_from_mpas requires [0, 2π) longitudes
69+
# but our grid file has [-π, π) longitudes
70+
PI=3.14159265359
71+
ncap2 -s "where(lonCell < 0) lonCell = lonCell + 2*$PI;
72+
where(lonVertex < 0) lonVertex = lonVertex + 2*$PI;
73+
where(lonEdge < 0) lonEdge = lonEdge + 2*$PI" grid.nc grid_0to2pi.nc
74+
75+
# Create the SCRIP file (scrip.nc by default, use -s to change)
76+
scrip_from_mpas -m grid_0to2pi.nc
77+
```
78+
79+
`mpas2esmf` is not included in the conda-forge package
80+
(you must compile it from within [this directory](https://github.com/MPAS-Dev/MPAS-Tools/tree/master/mesh_tools/mpas2esmf)).
81+
You must supply a grid file with `sphere_radius` 1,
82+
but unlike `scrip_from_mpas`, it's fine with negative longitudes.
83+
84+
```bash
85+
# Create SCRIP file (mpas_scrip.nc) and ESMF grid file (mpas_esmf.nc)
86+
mpas2esmf grid.nc "480-km" "$(date -I)"
87+
```
88+
89+
Note that the results may be a bit different.
90+
For example, `mpas2esmf` seems to set `grid_corners` to the max `nEdgesOnCell` (generally 6),
91+
while the `scrip_from_mpas` SCRIP has `grid_corners` consistent with the original `maxEdges` dim,
92+
and these differences cause NCO to interpret them slightly differently.
93+
The `mpas2esmf` result also includes `rrfac` (regional refinement factor).
94+
4695
```bash
4796
# Automatically generate a 1-degree target grid
4897
# Generate weights with TempestRemap conservative monotone algorithm
49-
ncremap -m map.nc -s mpas_source_grid.nc -g target_grid.nc -G latlon=180,360 -a traave
98+
ncremap -m map_con.nc -s scrip.nc -g target_grid.nc -G latlon=180,360 -a traave
5099

51-
# Apply weights
52-
ncremap -P mpasa -m map.nc in.nc out.nc
100+
# Apply weights, selecting a specific variable (terrain height from the static file)
101+
ncremap -P mpasa -m map_con.nc -v ter static.nc out_con.nc
102+
```
103+
104+
```bash
105+
# Use the same target grid and regrid using ESMF bilinear interpolation
106+
ncremap -m map_bil.nc -s scrip.nc -g target_grid.nc -a bilinear
107+
ncremap -P mpasa -m map_bil.nc -v ter static.nc out_bil.nc
53108
```
54109

55110
### Notes
@@ -124,5 +179,6 @@ convert_mpas x1.10242.init.nc diag.*.nc
124179
Otherwise:
125180

126181
- [](#pyremap) for generating weights
127-
- Generate both conservative and bilinear weights to be used for different variables
182+
- Generate both conservative and bilinear weights to be used for different variables,
183+
nearest-neighbor can be useful as well
128184
- [](#pyremap) for applying weights

0 commit comments

Comments
 (0)