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" ;****************************************************; ; Reads in the mode netCDF output and plots the frequency ; of objects for both the model and observations begin ;Read in the mode files for the Full grid plt_files = systemfunc("ls "+input_path) plt_files_leads = new(dimsizes(plt_files),"double") do ff=0,dimsizes(plt_files)-1 psplit = str_split(plt_files(ff),"/") gendate_str = psplit(dimsizes(psplit)-2) gendate_split = str_split(gendate_str,"_") gtime_split = str_split_by_length(gendate_split(dimsizes(gendate_split)-1),2) gendate = cd_inv_calendar(tointeger(gendate_split(0)),tointeger(gendate_split(1)),tointeger(gendate_split(2)),tointeger(gtime_split(0)),tointeger(gtime_split(1)),tointeger(gtime_split(2)),"hours",0) fname = psplit(dimsizes(psplit)-1) fname_split = str_split(fname,"_") vdate_split = str_split_by_length(fname_split(2),(/4,2,2/)) vdate = cd_inv_calendar(tointeger(vdate_split(0)),tointeger(vdate_split(1)),tointeger(vdate_split(2)),0,0,0,"hours",0) lhrs = vdate - gendate plt_files_leads(ff) = lhrs end do ;open the first file to get the data sizes tfile = addfile(plt_files(0),"r") fobj_id_test = tfile->fcst_obj_id dsize = dimsizes(fobj_id_test) n_infiles = dimsizes(plt_files) fobj_bin_all = new((/n_infiles,dsize(0),dsize(1)/),float) oobj_bin_all = new((/n_infiles,dsize(0),dsize(1)/),float) f_df = n_infiles delete([/fobj_id_test,tfile,dsize/]) ;Read in the rest of the data do f=0,n_infiles-1 ffile := addfile(plt_files(f),"r") lat_in := ffile->lat lon_in := ffile->lon fobj_id_in := ffile->fcst_obj_id oobj_id_in := ffile->obs_obj_id fobj_bin = where(ismissing(fobj_id_in).ne.1,1,0) oobj_bin = where(ismissing(oobj_id_in).ne.1,1,0) fobj_bin_all(f,:,:) = fobj_bin oobj_bin_all(f,:,:) = oobj_bin end do fobj_cnt = dim_sum_n(fobj_bin_all,0) oobj_cnt = dim_sum_n(oobj_bin_all,0) fobj_freq = (dim_sum_n(fobj_bin_all,0)/f_df)*100.0 oobj_freq = (dim_sum_n(oobj_bin_all,0)/f_df)*100.0 ;Copy cooordinates for easy plotting copy_VarAtts(fobj_id_in(:,:),fobj_freq) copy_VarCoords(fobj_id_in(:,:),fobj_freq) copy_VarAtts(oobj_id_in(:,:),oobj_freq) copy_VarCoords(oobj_id_in(:,:),oobj_freq) copy_VarAtts(fobj_id_in(:,:),fobj_cnt) copy_VarCoords(fobj_id_in(:,:),fobj_cnt) copy_VarAtts(oobj_id_in(:,:),oobj_cnt) copy_VarCoords(oobj_id_in(:,:),oobj_cnt) ;Do a Frequency plot color_list = (/0,49,41,38,33,25,12,8,4,58/) wks_type = "png" wks = gsn_open_wks(wks_type ,"freq_cesm_gpcp_India") gsn_define_colormap(wks,"matlab_hsv") plot = new(2,graphic) ; Set up plot parameters res = True res@gsnDraw = False ; don't draw res@gsnFrame = False ; don't advance frame res@mpFillOn = False ; do not color-fill the map res@mpMinLatF = 5.0 ; range to zoom in on res@mpMaxLatF = 40. res@mpMinLonF = 60. res@mpMaxLonF = 110.0 res@cnFillOn = True ; turn on color fill res@cnLevelSelectionMode = "ExplicitLevels" res@cnLevels = (/10,20,30,40,50,60,70,80,90,100/) res@cnLineLabelsOn = False ; no line labels res@cnFillColors = color_list res@lbLabelBarOn = False res@cnLinesOn = False ;Plots and titles res@tiMainString := "GPCP Object Frequency, JJA 2014" plot(0) = gsn_csm_contour_map(wks,oobj_freq,res) res@tiMainString := "CESM 24h Object Frequency, JJA 2014" plot(1) = gsn_csm_contour_map(wks,fobj_freq,res) resP = True ; modify the panel plot resP@gsnPanelLabelBar = True ; add common colorbar resP@lbOrientation = "vertical" resP@lbBoxCount = 10 res@lbTitleOn = True resP@lbTitleString = " %" resP@lbTitleJust = "BottomLeft" resP@lbTitleFontHeightF = 0.015 resP@lbLabelFontHeightF = 0.013 resP@pmLabelBarOrthogonalPosF = 0.01 resP@pmLabelBarWidthF = 0.1 resP@lbLabelAlignment = "ExternalEdges" resP@lbLabelStrings = (/"0","10","20","30","40","50","60","70","80","90","100"/) gsn_panel(wks,plot,(/2,1/),resP) end