Re: Add multiple files with different time units.

From: Ping Huang <ph0007_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 17 2012 - 19:08:22 MDT

Hi, Dave,

Thanks for your help.

They are very useful methods.

The following processes are that I'm using.

1. Search the files.
2. Judge the number of files. If there's one file, read it directly. If there are more than two files, then
3. Add the first two files individually, and compare the time units in these two files. If the time units are same, add all files using addfiles and read directly. If not, then
4. Add all files individually, and read the time of each file and transfer the time value of other files to the time unit of the first file. Connect the transferred time value in to one variables, and use it to search subset and replace the wrong time value.

I don't know if there is more efficient method.

Regards,

Ping.

ÔÚ 2012-7-18£¬ÉÏÎç1:03£¬ Dave Allured дµÀ£º

> 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 19:08:52 2012

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