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/esmf/ESMF_regridding.ncl" begin fili = "2000_MPI-ESM-MR.nc" a = addfile (fili, "r") t=a->y t = lonFlip(t) printVarSummary(t) newlat=fspan(-89.50,89.50,180) ;create a sequence for the new values of lat newlon=fspan(-179.5,179.5,360) ;create a sequence for the new values of lon newlat@units = "degrees_north" newlon@units = "degrees_east" opt = True opt@DstGridLat = newlat opt@DstGridLon = newlon opt@ForceOverwrite = True opt@InterpMethod = "bilinear" t_regrid_bilinear = ESMF_regrid(t,opt) opt@InterpMethod = "neareststod" t_regrid_nearest = ESMF_regrid(t,opt) opt@InterpMethod = "conserve" t_regrid_conserve = ESMF_regrid(t,opt) printMinMax(t,0) printMinMax(t_regrid_bilinear,0) printMinMax(t_regrid_conserve,0) printMinMax(t_regrid_nearest,0) filo = "Regrid."+fili system("/bin/rm -f "+filo) fout=addfile(filo,"c") fout@creation_date = systemfunc("date") fout@title="Regrid_1*1 of "+fili fout->regrid=t_regrid_conserve ;---------------------------------------------------------------------- ; Plotting section ; ; This section creates filled contour plots of both the original ; data and the regridded data, and panels them. ;---------------------------------------------------------------------- wks = gsn_open_wks("x11","rect_to_rect") res = True res@gsnMaximize = True res@gsnDraw = False res@gsnFrame = False res@cnFillOn = True res@cnLinesOn = False res@cnLineLabelsOn = False res@cnFillMode = "RasterFill" res@lbLabelBarOn = False ; Turn on later in panel res@mpMinLatF = min(t&lat) res@mpMaxLatF = max(t&lat) res@mpMinLonF = min(t&lon) res@mpMaxLonF = max(t&lon) ; Use these four values to zoom in further. ; res@mpMinLatF = -30. ; res@mpMaxLatF = 15. ; res@mpMinLonF = 0. ; res@mpMaxLonF = 60. mnmxint = nice_mnmxintvl( min(t), max(t), 18, False) res@cnLevelSelectionMode = "ManualLevels" res@cnMinLevelValF = mnmxint(0) res@cnMaxLevelValF = mnmxint(1) res@cnLevelSpacingF = mnmxint(2) ;---Resources for plotting regridded data res@gsnAddCyclic = False dims = tostring(dimsizes(t_regrid_conserve)) res@tiMainString = "New rectilinear grid (" + \ str_join(dims," x ") + ") (bilinear)" plot_regrid_bilinear = gsn_csm_contour_map(wks,t_regrid_bilinear,res) res@tiMainString = "New rectilinear grid (" + \ str_join(dims," x ") + ") (nearest)" plot_regrid_nearest = gsn_csm_contour_map(wks,t_regrid_nearest,res) res@tiMainString = "New rectilinear grid (" + \ str_join(dims," x ") + ") (conserve)" plot_regrid_conserve = gsn_csm_contour_map(wks,t_regrid_conserve,res) ;---Resources for plotting original data dims = tostring(dimsizes(t)) res@tiMainString = "Original rectilinear grid (" + \ str_join(dims," x ") + ")" plot_orig = gsn_csm_contour_map(wks,t,res) ;---Compare the plots in a panel pres = True pres@gsnMaximize = True pres@gsnPanelLabelBar = True gsn_panel(wks,(/plot_orig,plot_regrid_bilinear,\ plot_regrid_nearest,plot_regrid_conserve/),(/2,2/),pres) end