[ncl-talk] Creating Time Series Plots with Joined Arrays

Adam Phillips asphilli at ucar.edu
Tue Apr 3 17:11:03 MDT 2018


Hi Stuart,
I think the main issue is that you are joining the files together (you have
to as they do not have a time dimension), and the joined time coordinate is
not getting converted to be consistent amongst the timesteps.

Each of your two sample files has a time array with a different units
attribute, with time set to 0 for each.

file 1:
Variable: time (file variable)
Type: float
Total Size: 8 bytes
            2 values
Number of Dimensions: 1
Dimensions and sizes: [time | 2]
Coordinates:
            time: [ 0..80640]
Number Of Attributes: 5
  units : minutes since 2009-01-20 00:00:00
  long_name : time
  time_increment : 86400
  begin_date : 20090120
  begin_time : 000000

file 2:
Variable: time (file variable)
Type: float
Total Size: 8 bytes
            2 values
Number of Dimensions: 1
Dimensions and sizes: [time | 2]
Coordinates:
            time: [ 0..80640]
Number Of Attributes: 5
  units : minutes since 2009-03-17 00:00:00
  long_name : time
  time_increment : 86400
  begin_date : 20090317
  begin_time : 000000


By default, addfiles will concatenate and adjust the time variable
appropriately.

b = addfiles(fils,"r")
time = b[:]->time
print(time)

Variable: time
Type: float
Total Size: 8 bytes
            2 values
Number of Dimensions: 1
Dimensions and sizes: [time | 2]
Coordinates:
            time: [ 0..80640]
Number Of Attributes: 5
  units : minutes since 2009-01-20 00:00:00
  long_name : time
  time_increment : 86400
  begin_date : 20090120
  begin_time : 000000
(0) 0
(1) 80640

Thus, I think the solution is to continue to join your data arrays through
addfiles, but also concatenate the time variable through a separate call to
addfiles:
b = addfiles(fils,"r")
time = b[:]->time

a = addfiles(fils,"r")
ListSetType (a, "join")
data = a[:]->vic_lake_area_inst
data at time=a[:]->time
data!0 = "time"
data&time = time   ; assign time coordinate variable

; then, farther down your script change this:
date       = cd_calendar(a[:]->time,0)
to this:
date       = cd_calendar(data&time,0)

That should do it. If you have any further questions please respond to the
ncl-talk email list.
Adam















On Tue, Apr 3, 2018 at 4:00 PM, Smith, Stuart <smit1770 at purdue.edu> wrote:

> Hello,
>
>
>
> I am trying to augment my code to improve the display of figures. My goal
> is to plot variables during specific months. The attached code is currently
> setup to read in all of the netCDF files from a specific year, join the
> files, and then plot a variable of interest.
>
>
>
> When working to plot specific months, I added the “cd_calendar” function
> to change the values to calendar time. The output I get is listed below,
> which is also the same as when I print(data at time). This issue is caused
> by joining the arrays from the list of files.
>
>
>
> Does anyone have any recommendations to change the array to the correct
> time format? I have attached sample data and the code. Thank you for your
> time.
>
>
>
> (362,0) 2009
>
> (362,1)  1
>
> (362,2)  1
>
> (362,3)  0
>
> (362,4)  0
>
> (362,5)  0
>
> (363,0) 2009
>
> (363,1)  1
>
> (363,2)  1
>
> (363,3)  0
>
> (363,4)  0
>
> (363,5)  0
>
> (364,0) 2009
>
> (364,1)  1
>
> (364,2)  1
>
> (364,3)  0
>
> (364,4)  0
>
> (364,5)  0
>
>
>
> Regards,
>
>
>
> -Stuart
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180403/c3199852/attachment.html>


More information about the ncl-talk mailing list