Re: bar plots for frequency distribution

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Sun Oct 03 2010 - 08:23:43 MDT

I doubt anybody is going to spend the time to look at this
code. Dumping a code with many commented lines and
many other lines that do not pertain to the problem
and expecting people to look is not appropriate.

*Our time is valuable too!*

On 10/3/10 12:23 AM, Ammu Priya wrote:
> Hai,
> load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$HOME/ncl/lib/scripts/my_scripts.ncl"
>
> begin
>
> eps = 0
>
> fps = "Precbar_GPCP-TRMM-IMD_june98_frequency_col"
> fps@OverWrite = True
> fps@View = True
> diragpcp="/user1/akila/plot/frequncydistribution/gpcp1deg/"
> diraimd="/user1/akila/plot/frequncydistribution/imd1deg/"
> diratrmm="/user1/akila/plot/frequncydistribution/trmm1deg/"
> filesgpcp = systemfunc("ls "+diragpcp+"prec.gpcp.1dd.p1d.1998*")
> filesimd = systemfunc("ls "+diraimd+"prec.imd.mo.360x180.1998*")
> filestrmm = systemfunc("ls "+diratrmm+"prec.trmm.3b42.360x180.1998*")
> print(filesgpcp)
> print(filesimd)
> print(filestrmm)
>
> fgpcp = addfiles(filesgpcp,"r")
> ListSetType (fgpcp,"cat")
>
> fimd = addfiles(filesimd,"r")
> ListSetType (fimd,"cat")
>
> ftrmm = addfiles(filestrmm,"r")
> ListSetType (ftrmm,"cat")
>
> precgpcp = addfiles_GetVar(fgpcp,filesgpcp,"prec")
> precimd = addfiles_GetVar(fimd,filesimd,"prec")
> prectrmm = addfiles_GetVar(ftrmm,filestrmm,"prec")
>
> printVarSummary(precgpcp)
> printVarSummary(precimd)
> printVarSummary(prectrmm)
>
> gpcpjjas= precgpcp(time|151:272,lat|:,lon|:)
> gpcpjune= precgpcp(time|151:180,lat|:,lon|:)
> gpcpjuly= precgpcp(time|181:211,lat|:,lon|:)
> gpcpaug= precgpcp(time|212:242,lat|:,lon|:)
> gpcpsep= precgpcp(time|243:272,lat|:,lon|:)
> printVarSummary(gpcpjune)
> t=gpcpjune(:,{8:28},{70:90})
> printVarSummary(t)
> print(t)
> printVarSummary(gpcpjuly)
> printVarSummary(gpcpaug)
> printVarSummary(gpcpsep)
> imdjjas =precimd(time|151:272,lat|:,lon|:)
> ;printVarSummary(imdjjas)
> ;printMinMax(imdjjas,0)
> ;y=ndtooned(imdjjas(:,{8:28},{70:90}))
> ;print(y);printMinMax(y,0)
> imdjune =precimd(time|151:180,lat|:,lon|:)
> imdjuly=precimd(time|181:211,lat|:,lon|:)
> imdaug= precimd(time|212:242,lat|:,lon|:)
> imdsep=precimd(time|243:272,lat|:,lon|:)
> printVarSummary(imdjune)
> printVarSummary(imdjuly)
> printVarSummary(imdaug)
> printVarSummary(imdsep)
> trmmjjas =prectrmm(time|151:272,lat|:,lon|:)
> trmmjune =prectrmm(time|151:180,lat|:,lon|:)
> trmmjuly=prectrmm(time|181:211,lat|:,lon|:)
> trmmaug=prectrmm(time|212:242,lat|:,lon|:)
> trmmsep=prectrmm(time|243:272,lat|:,lon|:)
> printVarSummary(trmmjune)
> printVarSummary(trmmjuly)
> printVarSummary(trmmaug)
> printVarSummary(trmmsep)
> ;print(gpcpjune)
> ;x=gpcpjune(:,{8:28},{70:90})
> ;x=ndtooned(gpcpjjas(:,{8:28},{70:90}))
> x1=ndtooned(gpcpjune(:,{8:28},{70:90}))
> printMinMax(x1,0)
> ;y=ndtooned(imdjjas(:,{8:28},{70:90}))/12000*100
> y1=ndtooned(imdjune(:,{8:28},{70:90}))
> ;z=ndtooned(trmmjjas(:,{8:28},{70:90}))
> z1=ndtooned(trmmjune(:,{8:28},{70:90}))
> ;printVarSummary(x)
> ;printMinMax(x,0)
> ;printVarSummary(y)
> ;printMinMax(y,0)
> ;printVarSummary(z)
> ;printMinMax(z,0)
> printVarSummary(x1)
> printVarSummary(y1)
> printVarSummary(z1)
> printMinMax(x1,0)
> printMinMax(y1,0)
> printMinMax(z1,0)
> print(x1)
> printVarSummary(y1)
> printMinMax(y1,0 )
> printVarSummary(z1)
> printMinMax(z1,0)opt = True
> opt@bin_min =0
> opt@bin_max =50
> ry=pdfx(gpcpjune(:,{8:28},{70:90}),12000,opt)
> opt1 = True
> opt1@bin_min =0.4
> opt1@bin_max =50
> ry1=pdfx(imdjune(:,{8:28},{70:90}),12000,opt1)
> opt2 = True
> opt2@bin_min =0.7
> opt2@bin_max =50
> ry2=pdfx(imdjune(:,{8:28},{70:90}),12000,opt2)
> print(ry@bin_center+" "+ry)
> printVarSummary(ry)
> printVarSummary(ry1)
> print(ry1@bin_center+" "+ry1)
> printVarSummary(ry2)
> print(ry2@bin_center+" "+ry2)
> return
> if(eps .eq. 1)then
> wks = gsn_open_wks("eps",fps);
> else
> wks = gsn_open_wks("x11",fps);
> end if
>
> sres = True
> sres@gsnMaximize = True
> sres@vpWidthF = 0.7
> sres@vpHeightF = 0.5
> sres@vpXF = .10
> sres@trXMinF = 0
> sres@trXMaxF = 50
> sres@trYMinF = 0
> sres@trYMaxF = 61
> sres@gsnDraw = True
> sres@gsnFrame = False
> sres@gsnXYBarChart = True sres@tmXBLabelAngleF = 315
> sres@tmXBLabels =
> (/"0-0.001","0.001-3","3-5","5-7","7-9","9-11","11-13","13-15","15-17","17-19","19-21","21-23","23-25","25-27","27-29","29-31","31-33","33-35","35-37","37-39"/)
> ; sres@tmXBLabels =
> (/"0.001","2","4","6","8","10","12","14","16","18","20","22","24","26","28","30","32","34","36","38","40"/)
> sres@tmXBLabelFont=0.4
> sres@tmXBLabelFontHeightF = 0.0100
> sres@tmXTLabelFontHeightF = 0.0110
> sres@tmYLLabelFontAspectF =1.0
> sres@tmYLLabelFontHeightF = 0.0105
> sres@tiMainFontHeightF = 0.015
> sres@tiMainFont = "helvetica"
> sres@tiMainString = "Frequency distribution,JUNE-98"
> ; sres@gsnHistogramSelectNiceIntervals = False
> ; sres@gsnHistogramComputePercentages = True
> ; sres@gsnRightString = ""
> sres@tiYAxisFont = "helvetica"
> sres@tiYAxisString = "count(%)"
>
> sres@gsnXYBarChartColors = (/"red"/)
> ; plot1=gsn_csm_xy(wks,fspan(.775,11.775,12),x1,sres)
> plot1=gsn_csm_xy(wks,ry@bin_center,ry,sres)
> sres@gsnXYBarChartColors = (/"blue"/)
> plot2=gsn_csm_xy(wks,ry1@bin_center,ry1,sres)
> ; plot2=gsn_csm_xy(wks,fspan(.925,16.925,17),y1,sres)
> sres@gsnXYBarChartColors = (/"green"/)
> plot2=gsn_csm_xy(wks,ry2@bin_center,ry2,sres)
> ; plot3=gsn_csm_xy(wks,fspan(1.080,12.080,12),z1,sres)
> ; plot3=gsn_csm_xy(wks,fspan(1.080,17.080,17),z1,sres)
>
> lbres = True ; labelbar only resources
> lbres@vpWidthF = 0.25 ; labelbar width
> lbres@vpHeightF = 0.05 ; labelbar height
> lbres@lbBoxMajorExtentF = 0.36 ; puts space between color boxes
> lbres@lbFillColors = (/"red"/)
> lbres@lbMonoFillPattern = True ; Solid fill pattern
> lbres@lbLabelFontHeightF = 0.015 ; font height. default is small
> lbres@lbLabelJust = "CenterLeft" ; left justify labels
> lbres@lbPerimOn = False
> lbres@lgPerimColor = "white"
> ;without loop
> ; labels = (/"gpcp"/)
> ; gsn_labelbar_ndc(wks,1,labels,0.54,0.23,lbres)
> ; lbres@lbFillColors = (/"blue"/)
> ; labels = (/"imd"/)
> ; gsn_labelbar_ndc(wks,1,labels,0.09,0.23,lbres) ; draw right labelbar
> column
> ; lbres@lbFillColors = (/"green"/)
> ; labels = (/"trmm"/)
> ; gsn_labelbar_ndc(wks,1,labels,0.29,0.23,lbres) ; draw right labelbar
> column
> ;with loop
> ; colors = (/"red", "blue", "green"/)
> ; labels = (/"GPCP", "IMD", "TRMM"/); do i=0,2
> ; lbres@lbFillColors = colors(i)
> ; gsn_labelbar_ndc(wks,1,labels(i),xpos(i),0.78,lbres)
> ; gsn_labelbar_ndc(wks,1,labels(i),xpos(i),ypos(i),lbres)
> ; end do
>
> labels = (/"GPCP"/)
> gsn_labelbar_ndc(wks,1,labels,0.66,0.80,lbres)
> lbres@lbFillColors = (/"blue"/)
> labels = (/"IMD"/)
> gsn_labelbar_ndc(wks,1,labels,0.65,0.76,lbres) ; draw right labelbar column
> lbres@lbFillColors = (/"green"/)
> labels = (/"TRMM"/)
> gsn_labelbar_ndc(wks,1,labels,0.665,0.72,lbres) ; draw right labelbar column
>
> frame(wks)
> if(eps .eq. 1)then
> mkpdf(fps)
> end if
>
> end
>
> ; xpos = (/0.17, 0.159, 0.171 /)
>
>
> sres@gsnXYBarChartBarWidth = 0.55
> ; sres@tmXBMode = "Explicit"
> ; sres@tmXBValues = ispan(2,40,2)
> ; sres@tmXBValues = fspan(1.45,40.55,20)
>
>
> ;printMinMax(y,0)
> ;printMinMax(z,0)
> ;print(x)
>
> 2)
> want to plot frequency distribution
>
> 3)i tried it with if condition to get count between
> 0-0.001,0.001-2,2-4.....etc.as specified xtick label
> 4)will anyone please help to do
> Thank you,
> Thank you..
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Oct 3 08:23:49 2010

This archive was generated by hypermail 2.1.8 : Mon Oct 04 2010 - 08:55:54 MDT