[ncl-talk] can't figure out why could not plot time axis properly
Rick Brownrigg
brownrig at ucar.edu
Thu Nov 26 10:37:22 MST 2015
Hi,
I'm not certain, and don't have a good way to test at the moment. However,
a hint might be the variable "incr = 1"
Maybe print out the variable "labels" ... I' guess that it only contains
two values. Likewise for for PPT_obs&time(:,1).
Hope that helps, but please write back to the list if not.
Rick
On Wednesday, November 25, 2015, Ruksana Abedin <ruksana.abedin at gmail.com>
wrote:
> Hi.
>
> Can you please help me to find out why I could not plot the time axis
> properly?
>
> Below given the script anf the ouput. The axis should show 2-10 but only
> showing 2-3. How can I change this to Feb-Nov?
>
> Thank you for your kind support.
>
> Best regards,
> Ruksana
>
>
> ;*****************************************************
> 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"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
> ;*****************************************************
> begin
> ;*****************************************************
> ;read in data
> ;*****************************************************
> f0=addfile ("/ouce-home/students/rege1218/WAH2_SAS_Results_1985_2011/
> wah2_sas_1985_2007.part.Bdesh.ymonmean.nc", "r");
> f =
> addfile("/ouce-home/students/rege1218/Observations/APHRO_Asian_Monsoon_1963-2007/APHRO_Bdesh_ppt_1985_2007_ymonmean.nc",
> "r")
> ;*****************************************************
> ; parameters
> ;*****************************************************
>
> PPT_mod = f0->field90(:,0,0,0)
> PPT_mod = PPT_mod*86400
>
> PPT_obs = f->precip
> time = f->time
> x = PPT_obs&time
> timax = dimsizes(time)-1
>
> fldmean = wgt_areaave_Wrap(PPT_obs,1.0,1.0,1)
>
> ;--convert the time proleptic_gregorian calendar to UTC date
> utc_date = cd_calendar(time,0)
>
> ;-- set date variable names
>
> year = tointeger(utc_date(:,0))
> month = tointeger(utc_date(:,1))
> day = tointeger(utc_date(:,2))
> hour = tointeger(utc_date(:,3))
> minute = tointeger(utc_date(:,4))
> second = utc_date(:,5)
>
> ;-- write date as string (MM)
> date_str_i = sprinti("%0.2i",month)
>
> ;-- create the time strings, plot every axis annotation
> incr = 1
> labels = (/date_str_i(0:incr)/)
>
> ;-- set t resources
> res = True
> res at trXMinF = time(0) ; time minimum on axis
> res at trXMaxF = time(timax) ; time maximum on axis
> res at tmXBMode = "Explicit" ; explicit time setting
> res at tmXBValues = PPT_obs&time(:incr) ; axis tick position
> res at tmXBLabels = labels
>
>
> colors = (/"blue","violet"/)
> labels = (/"RCM_ppt","OBS_ppt"/)
>
> wks = gsn_open_wks("eps","annpptcycle")
>
> res =True
> res at gsnDraw = False
> res at gsnFrame = False
> res at gsnPaperOrientation = "portrait"
>
> res= True ; plot mods desired
> res =True
> res at gsnMaximize= True
> res at gsnDraw = False
> res at gsnFrame = False
> res at gsnPaperOrientation = "portrait"
>
>
> res= True ; plot mods desired
> res at tiMainString = "Bangladesh with Larger Region"
> res at tiYAxisString = "mm/day"
> res at xyLineThicknessF = (/3,3/)
> res at trYMinF = 0.0
> res at trYMaxF = 20.0
>
>
> res at xyLineColor = colors(0)
> plot0 = gsn_csm_xy(wks,x,PPT_mod,res)
>
> res at xyLineColor = colors(1)
> plot1 = gsn_csm_xy(wks,x,fldmean,res)
>
> overlay(plot0,plot1)
>
>
> ; Attach a legend
>
> lgres = True
> lgres at lgLineColors = colors
> lgres at lgItemType = "Lines"
> lgres at lgLabelFontHeightF = 0.2
> lgres at lgBoxMinorExtentF = 0.2
> lgres at vpWidthF = 0.2
> lgres at vpHeightF = 0.2
> lgres at pmLegendDisplayMode = "Always"
> lgres at pmLegendWidthF = 0.05
> lgres at pmLegendHeightF = 0.04
> lgres at xyExplicitLabels = labels
> lgres at lgBoxMinorExtentF = 0.3
> legend = gsn_create_legend(wks, 2, labels, lgres)
>
> amres = True
> amres at amJust = "BottomRight" ; Use bottom right corner of
> box for determining its location.
> amres at amOrthogonalPosF = -0.22
> amres at amParallelPosF = 0.4
>
> annoid = gsn_add_annotation(plot0, legend, amres) ; add legend to plot
>
> draw(plot0)
>
> frame(wks)
>
> end
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151126/16cafb72/attachment.html
More information about the ncl-talk
mailing list