Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Regridding / Convert Lambert projection of WRF outputs to Lat-lon projection + MASKING according to Shape file


New member
Hi, I have run the WRF simulation using Lambert projection.

For verification, I have to convert the projection to lat-lon projection and have to mask it according to my shape file for ease of comparison.

For this, I have used the rcm2rgrid function in NCL. where I can convert my grid, but masking according to shapefile creates a hinderance as the new variable created lacks coordinates of lat and long.

The code I used is given below:

files1 = systemfunc("ls /home/(path to folder)/wrfout_d01_2016-04-*"); listing of output files to files

lat1=fspan( 3.625,38.625,141)

do i=0, dimsizes(files1)-2
d = str_get_cols(files1(i+1),43,44)
h = str_get_cols(files1(i+1),46,47)

a1 = addfile(files1(i),"r")

a2 = addfile(files1(i+1),"r")
latw = wrf_user_getvar(a1,"XLAT",0)
lonw = wrf_user_getvar(a1,"XLONG",0)

landmask = wrf_user_getvar(a1,"LANDMASK",0)

rain_exp_a1 = wrf_user_getvar(a1,"RAINNC",0)
rain_con_a1 = wrf_user_getvar(a1,"RAINC",0)
rain_s_a1 = wrf_user_getvar(a1,"RAINSH",0)
rain_tot_a1 = rain_exp_a1 + rain_con_a1 + rain_s_a1
rain_exp_a2 = wrf_user_getvar(a2,"RAINNC",0)
rain_con_a2 = wrf_user_getvar(a2,"RAINC",0)
rain_s_a2 = wrf_user_getvar(a2,"RAINSH",0)
rain_tot_a2 = rain_exp_a2 + rain_con_a2 + rain_s_a2
rain = rain_tot_a2 - rain_tot_a1

n = addfile("g_ts1_nuf_"+d+h+".nc","c")
r = rcm2rgrid(latw, lonw, rain, lat1, lon1, 1)
l = rcm2rgrid(latw, lonw, landmask, lat1, lon1, 1)

n->r_edit=r ;rainfall_edited
n->lm_edit=l ;landmask_edited

end do