;*********************************************** ; This program plots sets of instantaneous precipitation maps, as a set of 6 panels and figures. ; The number of figures depends on how many maps/files you make/have. ; The data is from the NOAA Weather & Climate Tool (level iii), and is saved in the native NetCDF. ; The data is obtained from a single radar location ; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" undef("set_res2_list") function set_res2_list() begin res = True res@cnFillOn = True res@cnLinesOn = False res@cnLineLabelsOn = False res@lbLabelBarOn = False res@gsnDraw = False ; don't draw res@gsnFrame = False ; don't advance frame res@cnLevelSelectionMode = "ExplicitLevels" ; use explicit levels cmap = read_colormap_file("NCV_rainbow2") cmap(0,:) = 1. ; Make first color white res@cnFillPalette = cmap ; res@cnFillPalette="NCV_rainbow2" res@cnLevels = (/0,0.25,0.5,0.75,1.0,1.25,1.50,1.75,2.0,\ 2.5,3.0,3.5,4.0,4.5,5.0,7.5,10.0/) res@cnFillColors = (/0,90,80,70,63,55,108,115,122,129,157,161,169,176,183,190,197,204,211, \ 218,225,232,239,247,252/) return(res) end begin wks = gsn_open_wks("png","obs_prec") ; calc_kdp = True plots_dbz = new ( 6, graphic ) diri = "./" all_files = systemfunc("ls " + diri + "KOKX_DPR_20*nc") n_files = dimsizes(all_files) print("all_files = " + all_files) print("n_files = " + n_files) n_figures = n_files/6 ii_file = 0 do i_fig = 0,n_figures-1 ; do i_file = 0,n_files-1 do i_file = 0,5,1 ; do i_file = 0,0,1 f = addfile(all_files(ii_file),"r") filename=all_files(ii_file) ii_file = ii_file + 1 ; print(f) elevation = f->elevation ; longitude = f->longitude rays_time = f->rays_time dipr_raw = f->DigitalInstantaneousPrecipitationRate_RAW dipr = f->DigitalInstantaneousPrecipitationRate print(getfilevarnames(f)) printVarSummary(elevation) printVarSummary(rays_time) print("raw..") printVarSummary(dipr_raw) printMinMax(dipr_raw,False) printVarSummary(dipr) printMinMax(dipr,False) dipr@_FillValue = default_fillvalue(typeof(dipr)) replace_ieeenan (dipr,dipr@_FillValue,0) printMinMax(dipr,False) ; dimsvar = dimsizes(dipr) print("dimsvar = " + dimsvar) ; copy_VarAtts(var,dipr) angles = f->azimuth(:) dims_ang = dimsizes(angles) j_s = 0 j_e = dims_ang(0)-1 dsizes_dbz = dimsizes(dipr) print("dsizes_dbz = " + dsizes_dbz) i_s = 0 i_e = 4*dsizes_dbz(1)/5 dbz_sub = dipr(j_s:j_e,i_s:i_e) printMinMax(dbz_sub,False) ; dbz_o = dipr ;---To see a list of all the variables on the file ; if (i_file .eq. 0)then ; print(getfilevarnames(f)) ; end if ; angles=90-angles angles_sub = angles(j_s:j_e) DEGTORAD = 0.017453292519943 xcenter = 0.0 ycenter = 0.0 ; Create 2D coordinate arrays. ; distanceR_HI = longitude ; x=->distanceR_HI x =f->gate print("Longitude MinMax") printMinMax(x,False) x_sub = x(i_s:i_e) angles2d = conform(dbz_sub,angles_sub,0) x2d = conform(dbz_sub,x_sub,1)/1000 ; convert to km ; x2d = conform(dbz_sub,x_sub,1) ; convert to km xarr = xcenter + x2d * cos(DEGTORAD * angles2d) yarr = ycenter + x2d * sin(DEGTORAD * angles2d) dbres = True dbres@gsnDraw = False dbres@gsnFrame = False dbres@cnInfoLabelOn = False dbres@lbLabelBarOn = False dbres@gsnMaximize = True dbres@sfXArray = xarr dbres@sfYArray = yarr dbres@cnFillOn = True ; dbres@cnFillPalette = "NCV_jet" ; set color map cmap := read_colormap_file("NCV_rainbow2") printVarSummary(cmap) ; cmap := cmap(50:, :) ; dbres@cnFillPalette = cmap ; set color map dbres@cnLinesOn = False dbres@cnFillMode = "RasterFill" ; this mode is fastest dbres@trGridType = "TriangularMesh" dbres@tiMainString = filename dbres@tiXAxisString = "Zonal Distance (km)" dbres@tiYAxisString = "Meridional Distance (km)" dbres@lbOrientation = "Vertical" dbres@cnLevelSelectionMode = "ExplicitLevels" ; use explicit levels cmap = read_colormap_file("NCV_rainbow2") cmap(0,:) = 1. ; Make first color white dbres@cnFillPalette = cmap dbres@cnLevels = (/0.05,0.10,0.25,0.5,0.75,1.0,1.25,1.50,1.75,2.0,\ 2.5,3.0,3.5,4.0,4.5,5.0/) dbres@cnFillColors = (/0,35,95,88,81,75,115,118,122,130,155,160,166,176,183,190,197,204,211, \ 218,225,239,247,252/) ; dbres@cnLevels = ispan(-16,56,2) ; set the contour levels dbres@cnLineLabelsOn = False ; do not use line labels dbres@cnFillOn = True ; color fill dbres@cnLinesOn = False ; do not draw contour lines dbres@gsnLeftString = "Instantaneous Precipitation" dbres@gsnRightString = "in/h" print("MaxMin before contour") printMinMax(dbz_sub,False) contour = gsn_csm_contour(wks,dbz_sub,dbres) plots_dbz(i_file) = contour ; will reuse old dbz variable for differential reflectivity delete(dipr) ; plots_dbz(i_file) = contour end do ; Set Panel Resources pnlres = True ; pnlres@txString = t@description + " (" + t@units + ")" pnlres@txString = "Instantaneous Precipitation (in/h)" pnlres@gsnPanelYWhiteSpacePercent = 13 ; Add white space b/w plots. pnlres@gsnPanelLabelBar = True ; Turn on common labelbar pnlres@lbLabelAutoStride = True ; Spacing of lbar labels. pnlres@lbBoxMinorExtentF = 0.13 pnlres@lbLabelFontHeightF = .015 pnlres@lbPerimOn = False pnlres@lbLabelFont = "Helvetica" ; label font pnlres@lbTitleOn = True ; turn on title pnlres@lbTitleString = "in/h" ; title string ; pnlres@lbTitlePosition = "Top" ; title position pnlres@lbTitlePosition = "Bottom" ; title position pnlres@lbTitleFontHeightF= .015 ; make title smaller pnlres@lbTitleDirection = "Across" ; title direction pnlres@pmLabelBarWidthF = 0.5 pnlres@pmLabelBarHeightF = 0.15 pnlres@lbTopMarginF = 0.001 pnlres@pmLabelBarOrthogonalPosF = 0.02 ; position wrt plot pnlres@lbTitleOffsetF = -0.4 gsn_panel(wks,(/plots_dbz/),(/2,3/),pnlres) end do end