I've been a WRF user for almost 5 years now, and contributed code to a recent public release. I am not aware that WPS (WRF Preprocessing System) has such a tool that takes in the grid and point coordinates and returns the appropriate index. However, it is very straightforward to do so yourself. Some suggest using an external library, I think that may be an overkill for such a simple task. Here is what you need to do:
1) Rungeogrid.exe
to generate the parent grid. Since you don't know the exact location of the nest yet, setmax_dom = 1
innamelist.wps
. This will generate a file calledgeo_em.d01.nc
.
2) Look at thegeo_em.d01.nc
file to find the right indices for your child domain.i_parent_start
andj_parent_start
refer to the x and y indices on the parent grid at which the southwest corner of the child grid will be positioned.XLONG_M
andXLAT_M
are the longitude and latitude grids of the mass (pressure) points. Using a programming language of choice, find the grid cell that is closest to your desired location for the child nest corner. This is typically done by looking for the minimum value of distance between desired location and all the points on the grid. For example, in Fortran, you can do something like:
integer :: i_parent_start,j_parent_start integer,dimension(2) :: coords coords = minloc((lon0-xlong_m)**2+(lat0-xlat_m)**2) i_parent_start = coords(1) j_parent_start = coords(2)
wherexlong_m
andxlat_m
are 2-dimensional arrays that you read from the grid, andlat0
andlon0
are the desired coordinates of the child nest southwest corner. Similarly, if you use Python, you could do:
import numpy as np j_parent_start,i_parent_start = np.unravel_index(\ np.argmin((lon0-xlong_m)**2+(lat0-xlat_m)**2),xlon_m.shape) # Add one because WRF indices start from 1 i_parent_start += 1 j_parent_start += 1
3) Now editnamelist.wps
again, set thei_parent_start
andj_parent_start
to the values that you calculated in step 3, setmax_dom = 2
, and re-rungeogrid.exe
. The child domain filegeo_em.d02.nc
should be created.
4) Look at thegeo_em.d02.nc
file. Repeat the procedure until happy with the domain location.
About theparent_grid_ratio
parameter. This is an integer factor of child grid refinement relative to the parent grid. For example, if set to 3, and parent grid resolution is 12 km, the child grid resolution will be 4 km. Odd values forparent_grid_ratio
(3, 5, etc.) are recommended because for even values, interpolation errors arise due to the nature of Arakawa C-grid staggering.parent_grid_ratio = 3
is the most commonly used value, and recommended by myself.