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:
geogrid.exe to generate the parent grid. Since you don't know the exact location of the nest yet, set
max_dom = 1 in
namelist.wps. This will generate a file called
2) Look at the
geo_em.d01.nc file to find the right indices for your child domain.
j_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.
XLAT_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)
xlat_m are 2-dimensional arrays that you read from the grid, and
lon0 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(\
# Add one because WRF indices start from 1
i_parent_start += 1
j_parent_start += 1
3) Now edit
namelist.wps again, set the
j_parent_start to the values that you calculated in step 3, set
max_dom = 2, and re-run
geogrid.exe. The child domain file
geo_em.d02.nc should be created.
4) Look at the
geo_em.d02.nc file. Repeat the procedure until happy with the domain location.
parent_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 for
parent_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.