Re: Sub-setting a 1D array

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 12 2012 - 09:15:57 MDT

Hi Bart:

I think the issue is more with how you are calling gsn_csm_xy. You are passing in "taus", which is only every 24th time step. I would think you'd want to pass in the full time array, and then subscript the labels/tickmarks as desired:

 taus = ispan(0,n(0)-1,1)
   
 istep = 24

 ts_res = True
 ts_res@tmXBMode = "Explicit" ; Define own tick mark labels.
 ts_res@tmXBValues = taus(::istep) ; location of explicit labels
 ts_res@tmXBLabels = times(::istep) ; labels are the locations

 ts_plot = gsn_csm_xy(wks,taus,rain,ts_res)

Really, if you are just using 0…n(0)-1 on the X axis, there's no need to even pass in "taus". You can just call gsn_csm_y, which will automatically use 0….n-1 on the X axis:

 ts_plot = gsn_csm_y(wks,rain,ts_res)

--Mary

On Oct 11, 2012, at 5:59 PM, Bart Brashers wrote:

> If I have an array containing 1 month of hourly data (0:743) and another array of corresponding time-stamps, and try to plot the time series with the time-stamps as labels on the X-axis, they are too close together and I just get a big bunch of black.
>
> How can I select a sub-set of the timestamps to print? Something like this:
>
> rain = wrf_user_getvar(a,"RAINNC",-1) / 25.4 ; 25.4 mm/inch
> Times = a->Times
> times = wrf_times_c(Times,3)
>
> n = dimsizes(rain)
> taus = ispan(0,n(0)-1,24) ; One label per day
>
> ts_res = True
> ts_res@tmXBMode = "Explicit" ; Define own tick mark labels.
> ts_res@tmXBValues = taus ; location of explicit labels
> ts_res@tmXBLabels = times(taus) ; labels are the locations
>
> ts_plot = gsn_csm_xy(wks,taus,rain,ts_res)
>
> It boils down to "how do I select every Nth element of an array"? I can't find a discussion of such a basic concept in the examples...
>
> Thanks,
>
> Bart
>
>
>
>
>
> Ignore Mordac:
>
> ________________________________
> This message contains information that may be confidential, privileged or otherwise protected by law from disclosure. It is intended for the exclusive use of the Addressee(s). Unless you are the addressee or authorized agent of the addressee, you may not review, copy, distribute or disclose to anyone the message or any information contained within. If you have received this message in error, please contact the sender by electronic reply to email@environcorp.com and immediately delete all copies of the message.
> _______________________________________________
> 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 Fri Oct 12 09:16:09 2012

This archive was generated by hypermail 2.1.8 : Fri Oct 12 2012 - 15:38:19 MDT