[ncl-talk] Is there any way to fix this x-axis time plotting problem?
Mary Haley
haley at ucar.edu
Thu Dec 3 14:50:26 MST 2015
You didn't actually include your call to gsn_csm_xy, so I'm not sure how
you are passing your data to this routine.
If your "time" array starts at dec85, but you want to start the plot at the
second time value of jan86, then you need to subscript your time array
accordingly.
For starters, then, you don't want to use "time0(::incr)" as your tickmark
values, because time(0) corresponds with dec85, and you are telling it to
put a "jan" label on it.
I think this is what you want:
nt = 1 ; skip first time step
res at tmXBMode = "Explicit" ; explicit time setting
res at tmXBValues = PPT_mod&time0(nt::incr)
res at tmXBLabels = labels
When you call gsn_csm_xy, make sure it is also starting at the second time
index. Something like:
plot = gsn_csm_xy(wks,time(nt:),x(nt:),res)
On Thu, Dec 3, 2015 at 4:35 AM, Ruksana Abedin <ruksana.abedin at gmail.com>
wrote:
> Hi,
>
> I have used *Jan-Nov* to define the annual cycle excluding the month of
> Dec (figure a, blue line). Reason behind this is - each model year starts
> from Dec of the previous year following to Jan to Nov of the actual year
> (e.g., dec85, jan86, feb86, ….. nov86. Etc.). If I plot Jan-Dec (figure b,
> blue line), the annual cycle of model shifts eastwards along the x-axis and
> exhibits a delay in the onset of monsoon season. This is actually not
> correct, as it is plotting Dec, Jan, Feb.....data in place of Jan, Feb,
> Mar,.... . Is there any way which can help me plot Jan-Dec where NCL can
> put the month of Dec at its right tick point along the x-axis? Any
> suggestion will be very much appreciated.
>
>
> [image: Inline image 2]
>
>
> a) Annual ppt cycle over months Jan-Nov (correct) b) Annual
> ppt cycle over months Jan-Dec (wrong)
>
>
> Script used for the time plotting:
>
> f0=addfile ("/......../wah2_sas_1985_2007.part.LRBdesh.ymonmean_1_11.nc",
> "r");
>
> time = f0->time0
> x = PPT_mod&time0
> timax = dimsizes(time)-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)/)
> labels = (/"J","F","M","A","M","J","J","A","S","O","N"/)
>
> ;-- set 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_mod&time0(::incr) ; axis tick position
> res at tmXBLabels = labels
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151203/d4cd21f6/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 67722 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151203/d4cd21f6/attachment.png
More information about the ncl-talk
mailing list