;*********************************************************** ; pdf_xyz.ncl ; ; Concepts illustrated: ; - Generating different univariate probability distributions ; - Generating PDFs of each sample distribution ; - Creating trivariate PDFs of variables with different distributions ;*********************************************************** ; ; 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" ;************************************************************** ; Calculate the "joint PDF" of arrays "x", "y" and "z" ;************************************************************** load "./PDFXYZ.ncl" ;======================================================================================== ; MAIN ;======================================================================================== N = 96 M = 144 norm = random_normal (0,50, (/64,128/) ) chi = random_chi (2 , dimsizes(norm)) gam = random_gamma (75,2, dimsizes(norm)) uni = random_uniform(0,10, dimsizes(norm)) ; univariate PDFs pdf_norm = pdfx(norm, 0, False) ; default number of bins pdf_chi = pdfx(chi , 0, False) pdf_gam = pdfx(gam , 0, False) pdf_uni = pdfx(uni , 0, False) ; bivariate PDFs pdf2_nc = pdfxy(norm,chi,0,0,False) pdf2_ng = pdfxy(norm,gam,0,0,False) pdf2_gc = pdfxy(gam ,chi,0,0,False) nbinx = 10 nbiny = 10 nbinz = 10 opt = True opt@binx_nice = True opt@biny_nice = True opt@binz_nice = True pdf3 = PDFXYZ(norm,chi,uni,nbinx,nbiny,nbinz,opt) printVarSummary(pdf3) ; (z,y,x) printMinMax(pdf3,0) print("---") print("binx_bounds="+pdf3@binx_bounds) print("---") print("biny_bounds="+pdf3@biny_bounds) print("---") print("binz_bounds="+pdf3@binz_bounds) print("---") nbinsx = pdf3@nbinsx nbinsy = pdf3@nbinsy nbinsz = pdf3@nbinsz plot = new (3, "graphic") wks = gsn_open_wks("png","pdfxyz") ; send graphics to PNG file res = True res@gsnDraw = False res@gsnFrame = False res@cnInfoLabelOn = False res@cnFillOn = True ; Turn on color res@cnFillMode = "RasterFill" res@cnFillPalette = "MPL_Blues" ; set color map res@cnLinesOn = False res@cnLineLabelsOn = False res@gsnCenterString = "x,y wth z constant" plot(0) = gsn_csm_contour (wks,pdf3(nbinsz/2,:,:), res) res@gsnCenterString = "x,z wth y constant" plot(1) = gsn_csm_contour (wks,pdf3(:,nbinsy/2,:), res) res@gsnCenterString = "y,z wth x constant" plot(2) = gsn_csm_contour (wks,pdf3(:,:,nbinsx/2), res) ;************************************************ ; create panel ;************************************************ resP = True ; modify the panel plot resP@txString = "Trivariate PDF: Different Distributions" resP@gsnPanelRowSpec = True ; tell panel what order to plt gsn_panel(wks,plot,(/1,2/),resP)