;====================================================================== ; ESMF_wgts_13.ncl ; ; Concepts illustrated: ; - Interpolating from one grid to another using ESMF_regrid_with_weights ; - Interpolating from one grid to another using an existing weights file ; - Interpolating data from an EASE grid to a 0.25 degree grid ;====================================================================== ; This example is identical to ESMF_regrid_13.ncl, except it assumes ; the weights file already exists, and does regridding using ; "ESMF_regrid_with_weights". This is the best method to use if you ; already have the weights. ;====================================================================== ; This example uses the ESMF application "ESMF_RegridWeightGen" to ; generate the weights. ; ; For more information about ESMF: ; ; http://www.earthsystemmodeling.org/ ;====================================================================== ; ; These files are loaded by default in NCL V6.2.0 and newer ; 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" ; ; This file still has to be loaded manually load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" begin ease_file = addfile("EASE.nc","r") lat2d = ease_file->latitude lon2d = ease_file->longitude ;---Get date of interest: we will just regrid one time step. yyyymm = 200502 date = ease_file->date nt = ind(date.eq.yyyymm) swe2d = ease_file->SWE(nt,:,:) swe_regrid = ESMF_regrid_with_weights(swe2d,"EASE_2_NH_patch.nc",False) printVarSummary(swe_regrid) ;---------------------------------------------------------------------- ; Plotting section ;---------------------------------------------------------------------- wks = gsn_open_wks("png","ESMF_wgts") ; send graphics to PNG file res = True ; Plot mods desired. res@gsnMaximize = True ; Maximize plot res@gsnDraw = False res@gsnFrame = False res@cnFillOn = True ; color plot desired res@cnFillPalette = "amwg" ; set color map res@cnLinesOn = False ; turn off contour lines res@cnLineLabelsOn = False ; turn off contour labels res@cnFillMode = "RasterFill" ; turn raster on res@cnLevelSelectionMode= "ExplicitLevels" ; set explicit contour levels res@cnLevels = (/-300,-250,-200,-150,-100, \ 0,1,5,10,25,100,200,300,400/) res@lbLabelBarOn = False ; turn on in panel res@trGridType = "TriangularMesh" ; allow missing coordinates res@gsnPolar = "NH" ; specify the hemisphere res@mpMinLatF = 35 ;---Plot original data. res@gsnAddCyclic = False res@sfXArray = lon2d res@sfYArray = lat2d res@tiMainString = "Original EASE grid (" + str_join(dimsizes(lat2d),",") + ")" plot_orig = gsn_csm_contour_map_polar(wks,swe2d,res) delete(res@sfXArray) delete(res@sfYArray) ;---Plot regridded data. res@gsnAddCyclic = True dims = tostring(dimsizes(swe_regrid)) res@tiMainString = "Regridded to 0.25 degree grid (" + \ str_join(dims," x ") + ")" plot_regrid = gsn_csm_contour_map_polar(wks,swe_regrid,res) ;---Compare the plots in a panel pres = True pres@gsnMaximize = True pres@gsnPanelLabelBar = True pres@lbLabelFontHeightF = 0.01 pres@pmLabelBarWidthF = 0.8 gsn_panel(wks,(/plot_orig,plot_regrid/),(/1,2/),pres) end