[ncl-talk] Pressure-height plot for different seasons
Mary Haley
haley at ucar.edu
Fri Mar 11 15:59:34 MST 2016
You need to be able to extract day 1 of months 3, 6, 9, and 12 from your
time array so that you can locate where to put the MAM, JJA, SON, and DJF
labels.
If your time array is one that is in a "standard" format like "days since
2004-1-1" or "months since 2004", then you can use cd_calendar to extract
the years, months, days, etc:
;---Reverse engineer the time array to get back year, month, day, etc
dates = cd_calendar(time,0) ; n x 6 array years
= toint(dates(:,0))
months = toint(dates(:,1))
days = toint(dates(:,2))
You can then use this information to get the desired indexes from your time
array:
;---Start constructing the strings for the X axis labels
month_vals = (/ 3, 6, 9, 12/) ; months where we want
labels
season_strs = (/"MAM","JJA","SON","DJF"/) + "-"
;---Get the indexes for the first day of the month for the first month of
each season
ii =
ind(months.eq.3.or.months.eq.6.or.months.eq.9.or.months.eq.12.and.days.eq.1)
nii = dimsizes(ii)
xaxis_labels = new(nii,string)
do n=0,dimsizes(month_vals)-1
xaxis_labels =
where(months(ii).eq.month_vals(n),season_strs(n)+years(ii),xaxis_labels)
end do
See the attached script, which uses a dummy array to create an XY plot with
the time labels on the X axis.
--Mary
On Mon, Mar 7, 2016 at 12:41 PM, sudipta sarkar <sdptsarkar2 at gmail.com>
wrote:
> Hi Folks
> I want to plot a pressure-height plot against seasonal values
> (DJF,MAM,JJA,SON) for different years. My variable has dimensions for
> season, time and level.
>
> I can collapse the merge the season and time dimensions to show have a 2D
> array of time and level but I am not sure how to get a pressure-time plot
> from this where the x-axis will be labeled in terms of seasons from
> different years like: DJF-2004,MAM-04,JJA-2004,SON-2004,DJF-2005 like this.
>
> Any suggestion how I can get this done?
>
> Regards
>
>
> _______________________________________________
> 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/20160311/9a12281d/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: label_seasons_x_axis.ncl
Type: application/octet-stream
Size: 1850 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160311/9a12281d/attachment.obj
More information about the ncl-talk
mailing list