Re: mergetime with different time units

From: Xi Chang <xi.chang01_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 25 2013 - 15:32:55 MDT

Wow,, thanks a lot NCL Developers and Dave!
NCL works so smart to handle the netcdf data.! great work!

Regards,
Xi

On Thu, Sep 26, 2013 at 4:32 AM, Dennis Shea <shea@ucar.edu> wrote:

> The solution offered by Adam is not yet released.
> The next release of NCL (6.2.0) will handle this automatically.
> **NCL will handle exactly like the netCDF Operators.**
> It will rebase to the units associated with the 1st file.
>
>
> fils = (/"X.nc", "Y.nc"/)
> f = addfiles(fils, "r")
> var = f[:]->VAR
>
> ===
> Currently (6.1.2 and prior) the following approach should work
>
>
> fils = (/"X.nc", "Y.nc"/)
> f = addfiles(fils, "r")
>
> timex = f[0]->time
> timey = f[1]->time
>
> ; rebase timey to timex@units
> datey = cd_calendar(timey, 0)
> timey = cd_inv_calendar(datey(:,0), datey(:,1), datey(:,2), \
> datey(:,3), datey(:,4), datey(:,5), \
> timex@units, 0 )
> ntimx = dimsizes(timex)
>
> var = f[:]->VAR
> var&time(ntimx:) = (/ timey /) ; overwrite times associated with y
>
>
>
> On 9/25/13 1:28 PM, Dave Allured - NOAA Affiliate wrote:
>
>> Adam's NCL solution is better than mine. But if your objective is
>> simply to make a concatenated Netcdf file, NCO is the simplest way.
>>
>> --Dave
>>
>> On Wed, Sep 25, 2013 at 1:21 PM, Dave Allured - NOAA Affiliate
>> <dave.allured@noaa.gov> wrote:
>>
>>>
>>> NCO utilities have this capability built in to recent versions. It is
>>> an extremely simple and robust solution for this problem, if you do
>>> not mind creating a new concatenated file. They call this "time
>>> rebasing".
>>>
>>> Here is an overview of a straightforward method for NCL. There is
>>> more than one way to do this:
>>>
>>> 1. Use the cd_calendar function to decode the time coordinates of
>>> each file into time series of separate date numbers year, month, day,
>>> hour, etc. You will get arrays (N1, 6) and (N2, 6). See the function
>>> documentation.
>>>
>>> 2. Concatenate these two decoded arrays. You should now have a
>>> single array (N, 6) where N is the total number of time steps (N1 +
>>> N2), and 6 is the dimension for the separated year, month, day, etc.
>>> numbers.
>>>
>>> 3. As needed, concatenate the associated data arrays along the time
>>> dimension.
>>>
>>> 4. If needed, you can re-encode the time coordinates back to CF-style
>>> time coordinates, by using cd_inv_calendar on the concatenated
>>> date/time array from step (2). For the unit string, recycle the time
>>> unit string from the EARLIEST data being concatenated. You could also
>>> use a different unit string of your choice, if you are careful about
>>> roundoff error. HTH.
>>>
>>> Please reply only to the user list.
>>>
>>> --Dave
>>>
>>> On Wed, Sep 25, 2013 at 12:38 PM, Xi Chang <xi.chang01@gmail.com> wrote:
>>>
>>>> Hallo NCL,,
>>>>
>>>> Is there any solution in NCL to merge two netcdf data with different
>>>> time
>>>> units?
>>>> for instance I have two daily datasets, say:
>>>>
>>>> X.nc: 1990-2010 time units hours since 1955-01-01 00:00:00
>>>> Y.nc: 2011-2013 time units hours since 1980-01-01 18:00:00
>>>>
>>>> how could I combine or merge the time in these two datasets?
>>>> Thank you for any hints..
>>>>
>>>> Xi
>>>>
>>> ______________________________**_________________
>>
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/**mailman/listinfo/ncl-talk<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 Wed Sep 25 15:33:07 2013

This archive was generated by hypermail 2.1.8 : Tue Oct 01 2013 - 14:41:43 MDT