;====================================================================== ; ESMF_regrid_zoomed_8.ncl ; ; Concepts illustrated: ; - Interpolating from one grid to another using ESMF_regrid ; - Interpolating swath data to a rectilinear grid read off a file ; - Drawing the lat/lon grid using gsn_coordinates ; - Zooming in on a particular area on a map to see more detail ;====================================================================== ; This example is identical to ESMF_regrid_8, except that ; it zooms in on a specific location. ;====================================================================== ; 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 ;---Read data off source file srcFileName = "AusSnow_Source.nc" ; source grid sfile = addfile(srcFileName,"r") madis = sfile->masked_madiS madis@lat2d = sfile->lat2d madis@lon2d = sfile->lon2d ;---0 is treated as a missing value, so fix this madis = where(madis.eq.0, madis@_FillValue, madis) ;---Read data off destination file dfile = addfile("AusSnow_Dest.nc","r") lat = dfile->lat ; Need these for coordinate arrays lon = dfile->lon ; for regridding ;---Options for regridding Opt = True Opt@SrcFileName = "AusSnow_src_SCRIP.nc" Opt@DstFileName = "AusSnow_dst_SCRIP.nc" Opt@ForceOverwrite = True Opt@SrcTitle = srcFileName ; source grid Opt@SrcMask2D = where(ismissing(madis),0,1) Opt@SrcRegional = True Opt@DstTitle = "Australia Rectilinear Grid" ; destination grid Opt@DstGridLat = lat Opt@DstGridLon = lon Opt@DstRegional = True ;;Opt@PrintTimings = True Opt@InterpMethod = "bilinear" ; bilinear interpolation Opt@WgtFileName = "AUS_Swath_2_Rect_bilinear.nc" madis_regrid_b = ESMF_regrid(madis,Opt) Opt@InterpMethod = "patch" ; patch interpolation Opt@WgtFileName = "AUS_Swath_2_Rect_patch.nc" madis_regrid_p = ESMF_regrid(madis,Opt) Opt@InterpMethod = "conserve" ; interpolation Opt@WgtFileName = "AUS_Swath_2_Rect_conserve.nc" madis_regrid_c = ESMF_regrid(madis,Opt) ;---------------------------------------------------------------------- ; Plotting section ;---------------------------------------------------------------------- wks = gsn_open_wks("png","ESMF_regrid_zoomed") ; send graphics to PNG file res = True ; Plot mods desired. res@gsnMaximize = True res@gsnDraw = False res@gsnFrame = False res@mpDataBaseVersion = "MediumRes" res@mpDataSetName = "Earth..4" res@mpFillOn = False res@mpOutlineOn = True res@mpOutlineBoundarySets = "AllBoundaries" res@mpCenterLonF = 148.5 res@mpMinLatF = -36.1 ; -36.25 ; min(madis@lat2d) res@mpMaxLatF = -35.9 ; -35.75 ; max(madis@lat2d) res@mpMinLonF = 148.3 ; 148.25 ; min(madis@lon2d) res@mpMaxLonF = 148.5 ; 148.75 ; max(madis@lon2d) res@cnLinesOn = False res@cnFillMode = "RasterFill" res@cnLineLabelsOn = False res@cnFillOn = True res@cnFillPalette = "BlAqGrYeOrRe" ; set color map res@cnLevelSelectionMode = "ExplicitLevels" res@cnLevels = ispan(10,75,5) res@pmTickMarkDisplayMode = "Always" res@gsnAddCyclic = False ; don't add cyclic longitude point res@tiMainFont = "helvetica" res@tiMainFontHeightF = 0.02 res@lbLabelBarOn = False res@tiMainString = "Original data (zoomed in)" plot = gsn_csm_contour_map(wks,madis,res) ;---bilinear res@tiMainString = "Regridded data - bilinear" plot_b = gsn_csm_contour_map(wks,madis_regrid_b,res) ;---patch res@tiMainString = "Regridded data - patch" plot_p = gsn_csm_contour_map(wks,madis_regrid_p,res) ;---conserve res@tiMainString = "Regridded data - conserve" plot_c = gsn_csm_contour_map(wks,madis_regrid_c,res) ;---Add lat/lon grid lines to all four plots lnres = True lnres@gsnCoordsAttach = True lnres@gsnCoordsAsLines = True lnres@gsLineThicknessF = 0.5 gsn_coordinates(wks,plot,madis,lnres) gsn_coordinates(wks,plot_b,madis_regrid_b,lnres) gsn_coordinates(wks,plot_p,madis_regrid_p,lnres) gsn_coordinates(wks,plot_c,madis_regrid_c,lnres) ;---Panel all four plots pres = True pres@gsnPanelMainString = "Zoomed in on map for more detail and added a lat/lon grid" pres@gsnPanelMainFont = "helvetica-bold" pres@gsnPanelLabelBar = True pres@pmLabelBarWidthF = 0.8 pres@lbLabelFontHeightF = 0.01 gsn_panel(wks,(/plot,plot_b,plot_p,plot_c/),(/2,2/),pres) end