[Thread Prev][Thread Next][Index]

Re: Concatenating netcdf files along time dim



Hi Kek,
	Here is a demo for what I think is your situation - a series
of files with common x,y,z axes but with a single time step in each
file with a different time origin for each.  I've simulated the
situation with a set of 9 daily files - evenly spaced to make it
clear what is going on, but with an alternate definition of the time
axis (perhaps involving a dummy file defining the time axis) it should
be possible to make the idea work for unevenly spaced times too.
Hope the demo helps,
Mick

PS: I've attached the CDL file of one of the daily files at the end.

PPS: I think your wish is to make a single file to hold all the data.
If it were the case that you just wanted access to data from multiple
individual files I bet you could do that with the multi-netcdf file
arrangement described in the user guide which involves a descriptor
file rather than a big combined data file.

!---------------------------------------------------------
! Combining daily netcdf files into a single netcdf file
! Example:
!       Here there are 9 files sharing the same x,y,z axes
!       and each containing a single time step
!         test001.cdf : time=1-jan-2003 , t0=1-jan-2003
!         test002.cdf : time=2-jan-2003 , t0=2-jan-2003
!         ...
!         test009.cdf : time=9-jan-2003 , t0=9-jan-2003
!       So the time value in each file is 0 but the time
!       origin changes.
!
! Step 1: Read in the first file
use test001.cdf

! Step 2: Form a new grid with the same x,y,z axes but a new
!         time axis that steps through all of the times
def axis/t0=1-jan-2003/t=1-jan-2003:9-jan-2003:1/units=days tall
def grid/like=v[d=1]/t=tall gall

! Step 3: Redefine the variable on this grid
let/title="Combined Variable" vall=v[g=gall]

! Step 4: Save the first time step
save/file=combo.cdf/t=1-jan-2003 vall

! Step 5: Append the remaining time steps
can data/all ; use test002 ; save/file=combo.cdf/app/t=2-jan-2003 vall
can data/all ; use test003 ; save/file=combo.cdf/app/t=3-jan-2003 vall
can data/all ; use test004 ; save/file=combo.cdf/app/t=4-jan-2003 vall
can data/all ; use test005 ; save/file=combo.cdf/app/t=5-jan-2003 vall
can data/all ; use test006 ; save/file=combo.cdf/app/t=6-jan-2003 vall
can data/all ; use test007 ; save/file=combo.cdf/app/t=7-jan-2003 vall
can data/all ; use test008 ; save/file=combo.cdf/app/t=8-jan-2003 vall
can data/all ; use test009 ; save/file=combo.cdf/app/t=9-jan-2003 vall

!------------------------------------------------------

One of the CDL files
netcdf test001 {
dimensions:
        XAX = 4 ;
        YAX = 3 ;
        ZAX = 2 ;
        TAX = UNLIMITED ; // (1 currently)
variables:
        double XAX(XAX) ;
                XAX:point_spacing = "even" ;
        double YAX(YAX) ;
                YAX:point_spacing = "even" ;
        double ZAX(ZAX) ;
                ZAX:point_spacing = "even" ;
        double TAX(TAX) ;
                TAX:units = "DAYS since 2003-01-01 00:00:00" ;
                TAX:time_origin = "1-JAN-2003" ;
        float V(TAX, ZAX, YAX, XAX) ;
                V:long_name = "Test Variable" ;
data:
 XAX = 1, 2, 3, 4 ;
 YAX = 1, 2, 3 ;
 ZAX = 1, 2 ;
 TAX = 0 ;
 V =
  1111, 1112, 1113, 1114,
  1121, 1122, 1123, 1124,
  1131, 1132, 1133, 1134,
  1211, 1212, 1213, 1214,
  1221, 1222, 1223, 1224,
  1231, 1232, 1233, 1234 ;
}

|____Mick.Spillane@noaa.gov____|
|__Room 2070 Bldg#3 NOAA/PMEL__|
|____Phone_:_(206)526-6780_____|




[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement