> .
> .
> .
> Now I need to assign a coordinate variable to the time dimension.
> When I draw a latitude-time section, I'd like to have dates as tick marks
> rather than hours.
> In another case I may even want it with pentads.
>
> CCSM example pages seem to show only basic ones with a simple time axis.
> Other tutorials showing assignment of the time coordinate variable show
> an example such as:
>
> time = (/ 1., 2., 3., 4., 5., 6./)
>
> 1. How date and time should be expressed and assigned?
> 2. Does a template, such as gsn_csm_lat_time automatically scale
> hr/day/month?
> 3. How can I customize the coordinate labels?
> 4. Is there a way to deviate from Gregorian calendar, defined in
> udunits.dat
> and use the model month of 30 days?
>
I will try to answer questions #1-3. I'm hoping someone else who has
more knowledge of udunits will answer #4.
If you want to change the labels used on the X axis in the
"gsn_csm_lat_time" script (or any other script for that matter), you
can use the "tmXBMode", "tmXBLabels", and "tmXBValues" resources.
First, you want to set "tmXBMode" to the string "Explicit", to
indicate that you want to explicitly set the labels yourself.
Then, you need to decide at what tick mark values you want labels for,
and create two arrays of the same length of tick mark labels and
values, and use these to set the "tmXBLabels" and "tmXBValues"
resources. The "tmXBValues" array must be in the same data space as
whatever you have for the X coordinate array, and the "tmXBLabels"
array is just whatever labels you want at those tick mark values.
In the example below, the "time" X coordinate array is represented by
"sdemo&time", and its values go from 0 to 126. I set "tmXBValues" to
(0,25,50,75,100,125) to indicate I wanted special labels at these
values, and then I set "tmXBLabels" to the strings that I wanted to
appear at these tick mark values:
res@tmXBMode = "Explicit"
res@tmXBValues = (/0,25,50,75,100,125/)
res@tmXBLabels = (/"Jan","Feb","Mar","Apr","May","Jun"/)
In answer to your second question:
Does a template, such as gsn_csm_lat_time automatically
scale hr/day/month?
the answer is "no" because it has no way of knowing what values your
"time" variable is currently represented by. You can do the scaling
yourself by using NCL's array syntax capability.
sdemo&time = sdemo&time / 24.
Here's an example of how to change the X axis labels:
;*********************************************
; lat_time_1.ncl
;*********************************************
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/shea_util.ncl"
begin
diri = "/fs/scd/home1/shea/ezplot_demo_data/" ; directory
fili = "sst8292a.nc" ; data
f = addfile (diri+fili , "r") ; add file
lat = f->lat ; get lat
lon = f->lon ; get lon
time = f->time ; get time
date = f->date ; get date
sst = f->SSTA ; sst anomalies
lon90W = ind(lon.eq.270.) ; subscript at 90W
latS = -30.
latN = 30.
shov = sst(lon|lon90W:lon90W,{lat|latS:latN},time|:)
dims = dimsizes(shov) ; shov=3D array=(1,31,127)
sdemo = onedtond(ndtooned(shov), (/dims(1),dims(2)/) )
sdemo!0 = "lat"
sdemo!1 = "time"
sdemo&lat = lat({lat|latS:latN})
sdemo&time= time
sdemo = smth9 (sdemo,0.5, 0.25, False) ; 2D smoother
gtPat = 17 ; stiple
ltPat = 3 ; hatch
;*************************
; plotting parameters
;*************************
wks = gsn_open_wks ("x11", "lat_time" ) ; open workstation
res = True ; plot mods desired
res@gsnDraw = False ; don't draw yet
res@gsnFrame = False ; don't advance frame yet
res@tiMainString = "SST Anomalies at 90W" ; title
res@vpXF = 0.12 ; default is 0.2 change aspect
res@vpYF = 0.8 ; default is 0.8 ration
res@vpHeightF = 0.4 ; default is 0.6
res@vpWidthF = 0.8 ; default is 0.6
res@cnLevelSelectionMode = "ManualLevels" ; manual levels
res@cnMinLevelValF = -4. ; min level
res@cnMaxLevelValF = 4. ; max level
res@cnLevelSpacingF = 0.5 ; contour spacing
res@tmXBMode = "Explicit"
res@tmXBValues = (/0,25,50,75,100,125/)
res@tmXBLabels = (/"Jan","Feb","Mar","Apr","May","Jun"/)
plot = gsn_csm_lat_time(wks, sdemo, res )
plot = ShadeLtGtContour(plot, -0.5, ltPat, 0.5, gtPat)
plot = ZeroLineContour (plot)
draw (plot) ; draw the contour object
frame (wks) ; advance frame
end
_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2b29 : Mon Jul 29 2002 - 08:36:34 MDT