;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Convert_WRF_to_CFSR.ncl ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/popRemap.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" begin ; First we will just read in and look at one file to get the lat/lon information of the wrf domain foo = addfile("data/t2_maxmin_daily_jja_2000_rtty.nc","r") wrflat = foo->XLAT wrflon = foo->XLONG wrflon = wrflon + 360. delete(foo) ; Now we are reading in the lat/lon information from one file of CFSR foo = addfile("data/tmax.gdas.198001.grb2","r") lat_0 = foo->lat_0 lon_0 = foo->lon_0 delete(foo) ; What years and ensembles we care about years = (/"1990","1991","1992","1993","1994","1995","1996","1997","1999","2000"/) Ens = (/"rtty"/) ; Loop through ensembles and years do iens = 0,dimsizes(Ens)-1 do iyr = 0,dimsizes(years)-1 ; Open up the original file and create the new file. Also read in the variables we care about. fili = (/"data/t2_maxmin_daily_jja_"+years(iyr)+"_"+Ens(iens)+".nc"/) filo = (/"t2_maxmin_daily_jja_"+years(iyr)+"_"+Ens(iens)+"_CFSR.nc"/) fi = addfile (fili, "r") fo = addfile (filo, "c") T2MAX = fi->T2MAX(:,:,:) T2MIN = fi->T2MIN(:,:,:) ; Write the new lat/lon from CFSR to the output file fo->lat_0 = lat_0 fo->lon_0 = lon_0 print ("Working on file " + iens + " case " + Ens(iens) ) ; Use the function rcm2rgrid to regrid the WRF data to the CFSR grid VAR_on_OBS_Grid = rcm2rgrid(wrflat,wrflon,T2MAX,lat_0,lon_0,1) VAR_on_OBS_Grid!0 = "Time" VAR_on_OBS_Grid!1 = "lat_0" VAR_on_OBS_Grid!2 = "lon_0" VAR_on_OBS_Grid&lat_0 = lat_0 VAR_on_OBS_Grid&lon_0 = lon_0 fo->T2MAX = VAR_on_OBS_Grid delete(VAR_on_OBS_Grid) delete(T2MAX) VAR_on_OBS_Grid = rcm2rgrid(wrflat,wrflon,T2MIN,lat_0,lon_0,1) VAR_on_OBS_Grid!0 = "Time" VAR_on_OBS_Grid!1 = "lat_0" VAR_on_OBS_Grid!2 = "lon_0" VAR_on_OBS_Grid&lat_0 = lat_0 VAR_on_OBS_Grid&lon_0 = lon_0 fo->T2MIN = VAR_on_OBS_Grid delete(VAR_on_OBS_Grid) delete(T2MIN) end do end do end