[Thread Prev][Thread Next][Index]

Re: [ferret_users] Climatological Statistics

Hi Patrick,
We don't know of examples that implement a "climatology" attribute for a time axis. As the CF document says, Ferret has some support for climatological axes, implementing what's described in the COARDS standard. It might be worth it for you to write to the CF email list to see if  anyone has used an encoding that implements what the CF standard is describing.  An example is always so useful.

In Ferret, it's possible now to create an attribute, and add it to a file on output. In the attribute-handling syntax, coordinate variables are placed in parentheses to distinguish them from regular variables.
yes? define attribute (time).climatology = "climatology_bounds"
yes? set attribute/output (time).climatology

And then the new attribute will be saved for the TIME axis.

Now, to define the climatology_bounds variable, an external function might be the best method; but one could do something in a script, along these lines - the script could be generalized.
USE "http://ferret.pmel.noaa.gov/thredds/dodsC/data/PMEL/COADS/coads_sst.cdf"
USE climatological_axes; CAN DATA climatological_axes

!  Define the climatological axis for convenience, and save the units definition
DEFINE AXIS/T/UNITS=hours/MODULO/T0="`T[GT=month_reg],RETURN=t0`" TMOD=T[GT=month_reg]
DEFINE SYMBOL in_taxis = `sst,RETURN=taxis`
DEFINE SYMBOL in_taxis_units = "`(($in_taxis)).units`"

! Define the mean over a set of dates
LET sst6080 = sst[t=1-jan-1960:31-dec-1969,X=300:305,Y=20]
LET sst_clim_1960s = sst6080[GT=TMOD@mod]

! Define the climatology attribute for the output time axis

DEFINE ATTRIBUTE (TMOD).climatology = "climatology_bounds"

! Get the lower and upper bounds used by the climatological calculation.
! Put the two lists (12 values each) onto the output modulo time axis

LET clim_time_lo = TBOXLO[gt=($in_taxis),T=15-Jan-1965:15-Dec-1965]
LET clim_time_hi = TBOXHI[gt=($in_taxis),T=15-Jan-1970:15-Dec-1970]
LET bounds_lo = RESHAPE(clim_time_lo,T[gt=TMOD])
LET bounds_hi = RESHAPE(clim_time_hi,T[gt=TMOD])

! Make the climatology bounds variable. Set its units to the time units
! of the original variable before the modulo operation

DEFINE AXIS/X=1:2:1 nv
LET clim_shape = 0*(x[gx=nv] + t[gt=TMOD])
LET/TITLE="climatology bounds"/UNITS=($in_taxis_units) \
 climatology_bounds = IF I EQ 1 THEN (clim_shape+bounds_lo) ELSE \

! check by listing the date strings

LIST climatology_bounds
!             VARIABLE : climatology bounds (days since 1700-01-01 00:00:00)
!             SUBSET   : 2 by 12 points (X-TIME)
!                      1       2    
!                       1       2
! 16-JAN      /  1:  96788.  98644.
! 15-FEB      /  2:  96818.  98674.
! 17-MAR      /  3:  96848.  98704.
! 16-APR      /  4:  96878.  98734.
! 16-MAY      /  5:  96908.  98764.
! 16-JUN      /  6:  96938.  98795.

LIST TAX_DATESTRING(climatology_bounds , t[gt=sst], "days")
!             DATA SET : COADS Surface Marine Observations (1854-1993)
!             FILENAME : coads_sst.cdf
!             FILEPATH : http://ferret.pmel.noaa.gov/thredds/dodsC/data/PMEL/COADS/
!             SUBSET   : 2 by 12 points (X-TIME)
!                         1            2      
!                         1            2
! 16-JAN      /  1:"30-DEC-1964""30-JAN-1970"
! 15-FEB      /  2:"30-JAN-1965""01-MAR-1970"
! 17-MAR      /  3:"01-MAR-1965""30-MAR-1970"
! 16-APR      /  4:"30-MAR-1965""30-APR-1970"
! 16-MAY      /  5:"30-APR-1965""30-MAY-1970"
! 16-JUN      /  6:"30-MAY-1965""30-JUN-1970"

! Write out the data and the climatology_bounds variable
SAVE/CLOBBER/FILE=mod_clim_bounds.nc sst_clim_1960s, climatology_bounds

! OR we could save the variable as strings, as Patrick shows; then
! we dont need
the time units
LET t_bounds = IF I EQ 1 THEN (clim_shape+bounds_lo) ELSE (clim_shape+bounds_hi)
LET/TITLE="climatology bounds" climatology_bounds = \
  TAX_DATESTRING(t_bounds , T[GT=sst], "days")

SAVE/CLOBBER/FILE=mod_clim_bounds.nc sst_clim_1960s, climatology_bounds

A minor improvement to Ferret, for the future, might be to write out a climatology attribute and a climatology_bounds variable when a modulo regridding is done.  This wouldn't be difficult, and we can talk about that.

Patrick, would you be willing to write the CF email list as a first step and see if there is anyone who has implemented these ideas in netCDF files?


Brockmann Patrick wrote:
Hi all,

Is there any recommendations to save climatological statistics correctly  ?
I mean trying to respect as mush as possible CF convention but still usable by ferret.

Reading the paragraph on climatological statistics from
I am confused on what I can really use today.

Let's say I want to save a monthly climatological year calculated over 1961 to 1970.
Average of all january months for time=01, Average of all february months for time=02, ...

>From the CF convention, I would be tented to try the use of:

double time(time);
   time:units="days since 01-JAN-1961";
 double climatology_bounds(time,nv);
data:   time="1965-01-15", "1965-02-15", "1965-03-15", "1965-04-15",           "1965-05-15", "1965-06-15", "1965-07-15", "1965-08-15",
      "1965-09-15", "1965-10-15", "1965-11-15", "1965-12-15";
 climatology_bounds="1961-01-01",  "1970-02-01",
                    "1961-02-01",  "1970-03-01",
             "1961-03-01",  "1970-04-01", ...

How those metadata will be translated with ferret anyway ?
Perhaps I should continue with the climatologycal axis proposed by ferret (ie year 0000)
and use an explicite title such as '*Monthy decadal averages over 1961-1970'*


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement