Updated:
Try NCL. It It has a package for WRF-related functions, including the bidirectional grid-coordinates conversion routine.
To convert coordinate pairs to grid indices, follow the documentation here: wrf_user_ll_to_ij. A backward (i.e. gird to coordinate) routine can be found here: wrf_user_ij_to_ll
They. They are quite handy.
For your scenario, you may load your parent domain files (either 'geo_em'geo_em
or 'wrfout' ncwrfout
NetCDF files), and then specify the child domain starting coordinate, you will get the results.
Here are some examples from the official documentation:
conversion from coordinate to grid indices:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl" a = addfile("wrfout_d01_2000-01-24_12:00:00.nc","r") loc = wrf_user_ij_to_ll(a, 10., 30., True) print("lon location is: " + loc(0)) print("lat location is: " + loc(1))
Conversion from coordinate to grid indices:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
a = addfile("wrfout_d01_2000-01-24_12:00:00.nc","r")
loc = wrf_user_ij_to_ll(a, 10., 30., True)
print("lon location is: " + loc(0))
print("lat location is: " + loc(1))
2.conversionConversion from grid indices to coordinate:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
a = addfile("wrfout_d01_2000-01-24_12:00:00.nc","r")
res = True
res@returnInt = False ; return real values
loc = wrf_user_ll_to_ij(a, -100.0, 40.0, res)
print("X/Y location is: " + loc)