begin ; o=original data, b=regridded bilinear c=regridded patch fname_o = "ndvi3g_1982_nasa.nc" ; Original data file fname_b = "ndvi3d_1982_r0.75x0.75_bilinear.nc" ; Regridded data fname_p = "ndvi3d_1982_r0.75x0.75_patch.nc" ;---Open three files and read ndvi fo = addfile(fname_o,"r") fb = addfile(fname_b,"r") fp = addfile(fname_p,"r") ndvi_o = fo->ndvi ndvi_b = fb->ndvi ndvi_p = fp->ndvi ndvi_b = ndvi_b * ndvi_b@scale ndvi_p = ndvi_p * ndvi_p@scale ; ; The original input file coordinate arrays are lacking metadata, ; so fix here. This is for plotting purposes later. ; ndvi_o&lat@units = "degrees_north" ndvi_o&lon@units = "degrees_east" ;---Debug information printVarSummary(ndvi_o) printVarSummary(ndvi_b) printVarSummary(ndvi_p) printMinMax(ndvi_o,0) printMinMax(ndvi_b,0) printMinMax(ndvi_p,0) ;---Open file to send graphics to wtype = "png" wtype@wkWidth = 2500 wtype@wkHeight = 2500 wks = gsn_open_wks(wtype,"ndvi_compare") ;---Set some resources res = True ; res@gsnMaximize = True ; maximize plot in frame , not necessary if paneling later res@gsnFrame = False res@gsnDraw = False res@cnFillOn = True ; turn on contour fill res@cnLinesOn = False ; turn off contour lines res@cnLineLabelsOn = False ; turn off line labels res@cnFillMode = "RasterFill" ; faster contouring res@lbLabelBarOn = False ; will turn on in panel mnmxint = nice_mnmxintvl( min(ndvi_o), max(ndvi_o), 18, False) res@cnLevelSelectionMode = "ManualLevels" res@cnMinLevelValF = mnmxint(0) res@cnMaxLevelValF = mnmxint(1) res@cnLevelSpacingF = mnmxint(2)/2. ; twice as many contour levels res_o = res ; Copy common resources to new resource res_b = res ; lists for each plot. res_p = res ;---Set titles for original data plot, regridded data plots, and paneled plots. dims_o = str_join(""+dimsizes(ndvi_o(0,:,:))," x ") dims_b = str_join(""+dimsizes(ndvi_b(0,:,:))," x ") dims_p = str_join(""+dimsizes(ndvi_p(0,:,:))," x ") res_o@gsnCenterString = "Original data: " + dims_o res_b@gsnCenterString = "Regridded (bilinear) : " + dims_b res_p@gsnCenterString = "Regridded (patch) : " + dims_p panel_title_pfx = ndvi_b@long_name + ", time = " ; ; Metadata is lacking on original file, and wrong on regridded file, ; so remove it for now. ; delete(ndvi_o@units) delete(ndvi_b@long_name) delete(ndvi_b@units) delete(ndvi_p@long_name) delete(ndvi_p@units) pres = True ; resource list for gsn_panel pres@gsnMaximize = True pres@gsnPanelLabelBar = True ; turn on panel labelbar pres@gsnPanelRowSpec = True ; dims will represent # plots per row ;---Loop through each time step and create a panel plot of original and regridded data ntime = dimsizes(ndvi_b(:,0,0)) do nt=0,ntime-1 ;---Debug prints print("======================================================================") print(" Timestep : " + ndvi_b&time(nt)) print(" Original data min/max : " + min(ndvi_o(nt,:,:)) + "/" + \ max(ndvi_o(nt,:,:))) print(" Regridded (bilinear) min/max : " + min(ndvi_b(nt,:,:)) + "/" + \ max(ndvi_b(nt,:,:))) print(" Regridded (patch) min/max : " + min(ndvi_p(nt,:,:)) + "/" + \ max(ndvi_p(nt,:,:))) ;---Create the three plots and panel them plot_o = gsn_csm_contour_map(wks,ndvi_o(nt,:,:),res_o) plot_b = gsn_csm_contour_map(wks,ndvi_b(nt,:,:),res_b) plot_p = gsn_csm_contour_map(wks,ndvi_p(nt,:,:),res_p) pres@gsnPanelMainString = panel_title_pfx + ndvi_b&time(nt) gsn_panel(wks,(/plot_o,plot_b,plot_p/),(/1,2/),pres) end do print("======================================================================") ;---Create animated GIF cmd = "convert -delay 25 ndvi_compare.00*.png ndvi_animate_compare.gif" system(cmd) end