Re: Add multiple files with different time units.

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 17 2012 - 11:03:43 MDT

Ping,

Here are two ways to do it without changing the input files. There
are other ways.

Before using addfiles, use addfile to read the time coordinates
separately for each file. Use cd_convert or time_to_newtime to
convert the time coordinates to uniform coordinates based on the time
attributes of the first file. Put the resulting coordinates in the
correct order, into a single long "time" array.

Then when using addfiles, use coordinate addressing only on the long
time array to get the correct time indices for subscripting the other
file variables. Do not try to use coordinate subscripting directly on
the concatenated time dimension from addfiles.

Another method that I use is to again start by reading each file
separately with addfile, then use cd_calendar or calendar_decode2 or
ut_calendar to make long concatenated arrays for year, month, and day.
 Then use the year, month, day arrays directly to search for
individual dates or subsets of dates. Once again, the indices for the
YMD arrays are supposed to exactly match the concatenated time
dimension when later using addfiles.

--Dave

On Tue, Jul 17, 2012 at 12:51 AM, Ping Huang <ph0007@ustc.edu> wrote:
> Dear all,
>
> As we know, "addfiles" can be used to add multiple files with cat mode.
> When the data are read using inFile[:], the value of time coordinate in all
> files are read directly but the time unit of the first file is used.
> There is no problem when the time units are same in all files. But when the
> time units are different in these files, it would be wrong.
> For example, in some cmip5 model output, one variable from 1850-2005 are cut
> into three files.
> The time unit in the first file is "Since 1850......" and the value of time
> coordinate are "15, 45, 75...".
> Similarly, in the second file the time unit has changed to "Since 1900....",
> but the value of time coordinate still are "15, 45, 75".
> Thus, when these files are read using addfiles, the time unit of first files
> can't be treated as the time units of all time. It does not match the value
> of time coordinate in the other files.
> How to handle this kind of files?
>
> Thanks
>
> Ping
>
> _______________________________________________
> 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 Tue Jul 17 11:03:55 2012

This archive was generated by hypermail 2.1.8 : Wed Jul 18 2012 - 14:33:00 MDT