[Thread Prev][Thread Next][Index]
Ferret "how to": sequence of files as a time series
Ferret how-to: treating a sequence of independent files as a time series
On Jul 13, 11:18am, Ms S Sajani wrote:
> Subject: @ave from 12 nc files.
>
>
> Hi Netters,
>
> I have a simple question. I have 12 .nc
> files consists of daily data of 12 months. I
> wanted to compute the yearly average. How I can
> append the whole time points other than writing
> them into a single .nc output file.
Hi Sajani,
The above example could be addressed "brute force" as follows:
yes? USE file1.nc, file2.nc, file3.nc, ...
yes? LET ave = (v[d=1]+v[d=2]+v[d=3]+...+v[d=12])/12
Alternatively, here is a general technique for converting a sequence of files
into a time series, where each file contains a single time step of data. The
technique applies equally well to NetCDF, ASCII, or binary files.
The trick to this technique is to "time stamp" the files by defining a variable
with a value everywhere of zero but which is defined on the appropriate time
axis.
==========
! GOAL: combine variable "V" from 12 separate files into a monthly time series
! initialize the files
USE file1.cdf, file2.cdf, file3.cdf, ..., file12.cdf
! define the time axis
DEFINE AXIS/T=15-JAN:15-DEC/npoints=12 tmonth ! note 1
! define the "zero" value
LET zero = T[gt=tmonth] * 0 ! note 2
! define the time-stamped variable
LET v_stamped = v + zero
! save all 12 months in a time series
REPEAT/L=1:12 (SET DATA `L`; SAVE/APPEND/FILE=T_series.cdf v_stamped)
Note 1: A better way to define a climatological monthly time axis is
yes? SET DATA coads_climatology
yes? SHOW GRID sst <== use the time axis name
Note 2: look at what you defined with yes? list/l=1:12 zero
Happy Ferreting - steve
--
| NOAA/PMEL | ph. (206) 526-6080
Steve Hankin | 7600 Sand Point Way NE | FAX (206) 526-6744
| Seattle, WA 98115-0070 | hankin@pmel.noaa.gov
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement