Re: mergetime with different time units

From: Xi Chang <xi.chang01_at_nyahnyahspammersnyahnyah>
Date: Thu Oct 03 2013 - 02:11:23 MDT

I got this warning:

*warning:File ERA_daily_hgt_2012.nc dimension sizes do not conform to
others in list; skipping file*
*
*
*ncl 23> var&time(ntimx:) = (/ timey /) *
*fatal:Subscript out of range, error in subscript #0*
*fatal:["Execute.c":8126]:Execute: Error occurred at or near line 23*
*
*
In this case, I want to combine two daily data from *era 2012.nc* (365
days) and *era 2013.nc* (181 days -- until June),
once I did as you recommended, ti produces those error. Here are the
details of the input data:

--
*netcdf ERA_daily_hgt_2012 {*
dimensions:
        time = 366 ;
        level = 23 ;
        lat = 73 ;
        lon = 144 ;
variables:
        float Z3(time, level, lat, lon) ;
                Z3:table = 128 ;
                Z3:typeConversion_op_ncl = "double converted to float" ;
        float time(time) ;
                time:units = "*hours since 2012-01-01 00:00:00*" ;
                time:calendar = "proleptic_gregorian" ;
        float level(level) ;
                level:long_name = "Pressure" ;
                level:units = "mb" ;
                level:positive = "down" ;
                level:axis = "Z" ;
        float lat(lat) ;
                lat:long_name = "latitude" ;
                lat:units = "degrees_north" ;
                lat:standard_name = "latitude" ;
                lat:axis = "Y" ;
        float lon(lon) ;
                lon:long_name = "longitude" ;
                lon:units = "degrees_east" ;
                lon:standard_name = "longitude" ;
                lon:axis = "X" ;
---
*netcdf ERA_daily_hgt_2013 {*
dimensions:
        time = 181 ;
        level = 37 ;
        lat = 73 ;
        lon = 144 ;
variables:
        float Z3(time, level, lat, lon) ;
                Z3:table = 128 ;
        double time(time) ;
                time:calendar = "proleptic_gregorian" ;
                time:units = "*hours since 2013-01-01 00:00:00*" ;
        double level(level) ;
                level:long_name = "Pressure" ;
                level:units = "mb" ;
                level:positive = "down" ;
                level:axis = "Z" ;
        double lat(lat) ;
                lat:axis = "Y" ;
                lat:standard_name = "latitude" ;
                lat:units = "degrees_north" ;
                lat:long_name = "latitude" ;
        double lon(lon) ;
                lon:axis = "X" ;
                lon:standard_name = "longitude" ;
                lon:units = "degrees_east" ;
                lon:long_name = "longitude" ;
thanks for any help!
Xi.
On Thu, Sep 26, 2013 at 6:32 AM, Xi Chang <xi.chang01@gmail.com> wrote:
> 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 Thu Oct 3 02:11:38 2013

This archive was generated by hypermail 2.1.8 : Fri Oct 04 2013 - 16:45:17 MDT