|
1 | 1 | --- |
2 | 2 | title: Regrid |
3 | 3 | subtitle: Tools for regridding MPAS-A output to regular lat-lon grids |
| 4 | +label: regrid |
4 | 5 | --- |
5 | 6 |
|
6 | 7 | # Options |
7 | 8 |
|
| 9 | +(pyremap)= |
| 10 | + |
8 | 11 | ## pyremap |
9 | 12 |
|
10 | 13 | [pyremap](https://mpas-dev.github.io/pyremap/main/remapper/index.html) |
@@ -43,13 +46,65 @@ provides many facilities for regridding. |
43 | 46 |
|
44 | 47 | ### Examples |
45 | 48 |
|
| 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 | + |
46 | 95 | ```bash |
47 | 96 | # Automatically generate a 1-degree target grid |
48 | 97 | # 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 |
50 | 99 |
|
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 |
53 | 108 | ``` |
54 | 109 |
|
55 | 110 | ### Notes |
@@ -124,5 +179,6 @@ convert_mpas x1.10242.init.nc diag.*.nc |
124 | 179 | Otherwise: |
125 | 180 |
|
126 | 181 | - [](#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 |
128 | 184 | - [](#pyremap) for applying weights |
0 commit comments