NCL Website header
NCL Home > Documentation > Functions > Climatology

clmDayTLL

Calculates long term daily means (daily climatology) from daily data.

Prototype

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  ; This library is automatically loaded
                                                             ; from NCL V6.2.0 onward.
                                                             ; No need for user to explicitly load.

	function clmDayTLL (
		x [*][*][*] : float or double,  
		yyyyddd [*] : integer           
	)

	return_val [366][*][*] :  typeof(x)

Arguments

x

A three-dimensional array (time, lat, lon) containing daily mean data.

yyyyddd

A one-dimensional array (same size as the "time" dimension of x) containing values of the form yyyyddd [ie: yyyy*1000 + ddd] where yyyy is a year [eg: 1993] and ddd is the sequential day of the current year [eg: Jan01=>1, Feb01=>32, etc.)

By default, this function assumes that the gregorian calendar is being used. To correcly handle other calendars, the calendar attribute must be associated with the yyyyddd argument. The user may have to be explicitly perform the assignment.

Return value

A climatological time series where the leftmost dimension refers to the sequential day of the year.

Description

Calculate the mean annual cycle from daily data. The return array will give the raw climatology at each grid point


       x(time,lat,lon)  <==== input dimension order

non-Leap  yyyyddd
       1905001 =>  Jan  1, 1905
       1905032 =>  Feb  1, 1905
       1905059 =>  Feb 28, 1905
       1905060 =>  Mar  1, 1905
       1905365 =>  Dec 31, 1905

Leap      yyyyddd
       1908001 =>  Jan  1, 1908
       1908032 =>  Feb  1, 1908
       1908059 =>  Feb 28, 1908
       1908060 =>  Feb 29, 1908
       1908061 =>  Mar  1, 1908
       1908366 =>  Dec 31, 1908

See Also

smthClmDayTLL, clmMonTLL, clmMonTLLL, clmMonLLLT, clmMonLLT calculate_daily_values

Examples

Please see: MJO_CLIVAR: Example 2 for a visual example.

Example 1

Compute the daily climatologies. The input is mean daily 500 hPa heights spanning 1990-1999. The values are packed as type short and the time is in units "hours since 1-1-1 00:00:0". There was no calendar attribute associated with the 'time' dimension/variable. Hence, a gregorian calendar is assumed. Still, the example shows how a user might check if the calendar attribute exists and associate it with the required variables.

;;The following library is loaded by default in NCL V6.2.0 and newer
;;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" 
   :
   :
   diri    = "./"                             ; input directory   
   fili    = "HGT.nc"                         ; input file       
   f       = addfile (diri+fili , "r")                          
;***********************************************************
; Read time and create required yyyyddd                    
; NOte the tests for a calendar attribute are necessary for non-gregorian calendars
;***********************************************************
   time    = f->time                          ; time:units = "hours since 1-1-1 00:00:0.0"                               
   TIME    = cd_calendar(time, 0)             ; type float 
   year    = toint( TIME(:,0) )               ; toint strips meta data
   month   = toint( TIME(:,1) )
   day     = toint( TIME(:,2) ) 
                                                                 ; check for calendar attribute
   if (isatt(TIME,"calendar")) then           ; default is gregorian
       year@calendar = TIME@calendar         
   end if

   ddd     = day_of_year(year, month, day) 
   if (isatt(year,"calendar")) then           ; default is gregorian
       ddd@calendar = year@calendar  
   end if

   yyyyddd = year*1000 + ddd                                    ; needed for input
   if (isatt(ddd,"calendar")) then           ; default is gregorian
       yyyyddd@calendar = ddd@calendar  
   end if

;***********************************************************
; Read data: short2flt                                     
;*********************************************************** 
   hgt     =  short2flt( f->hgt(:,0,:,:) )    ; convert to float 
   printVarSummary( hgt ) 
;***********************************************************
; Compute daily climatology: raw daily means 
;***********************************************************
   hClmDay    = clmDayTLL(hgt, yyyyddd)     ; daily climatology at each grid point                                      
   printVarSummary(hClmDay)                                                                                              
The (edited) output yields
Variable: hgt
Type: float
Dimensions and sizes:   [time | 3652] x [lat | 73] x [lon | 144]
Coordinates: 
            time: [17435256..17522880]
            lat: [90..-90]
            lon: [ 0..357.5]
Number Of Attributes: 16
  _FillValue :  1e+20
  level :       500
  long_name :   mean Daily Geopotential height
The climatology
Variable: hClmDay
Type: float
Total Size: 15389568 bytes
            3847392 values
Number of Dimensions: 3
Dimensions and sizes:   [year_day | 366] x [lat | 73] x [lon | 144]
Coordinates: 
            year_day: [1..366]
            lat: [90..-90]
            lon: [ 0..357.5]
Number Of Attributes: 4
  long_name :   Daily Climatology: mean Daily Geopotential height
  units :       m
  information : Raw daily averages across all years
  smoothing :   None

Example 2

Compute the climatological daily Outgoing Longwave Radiation (OLR) values. The 'time' uses a '360_day' ('360') calendar [time@calendar="360_day" or time@calendar="360"]. The input are daily olr values spanning 2001-2010 (10*360=3600 days). The values are packed as type short. The user must make certain that the calendar attribute is properly propogated to various functions. The code is nearly identical to Example 1 except for:

   fili    = "olr.360_day.nc"                 ; input file       

;***********************************************************
; Read data: short2flt                                     
;*********************************************************** 
   olr     =  short2flt( f->OLR )    ; convert to float 
;***********************************************************
; Compute daily climatology: raw and then 'smoothed'  
;***********************************************************
   olrClmDay    = clmDayTLL(olr, yyyyddd)     ; daily climatology at each grid point                                      
The (edited) output yields

  Variable: olr
  Type: float
  Total Size: 151372800 bytes
              37843200 values
  Number of Dimensions: 3
  Dimensions and sizes:	[time | 3600] x [lat | 73] x [lon | 144]
  Coordinates: 
              time: [   0..3599]
              lat: [90..-90]
              lon: [ 0..357.5]
  Number Of Attributes: 15
    long_name :	Daily OLR
    unpacked_valid_range :	(  0, 500 )
    actual_range :	( 64.75, 344.5 )
    units :	W/m^2
    var_desc :	Outgoing Longwave Radiation
    precision :	2
    dataset :	NOAA Interpolated OLR
    level_desc :	Other
    statistic :	Mean
    parent_stat :	Individual Obs
    _FillValue_original :	32766
    _FillValue :	32766
    missing_value_original :	32766
    valid_range :	(  0, 500 )
    missing_value :	32766
The daily climatology:

  Variable: olrClm
  Type: float
  Total Size: 15137280 bytes
              3784320 values
  Number of Dimensions: 3
  Dimensions and sizes:	[year_day | 360] x [lat | 73] x [lon | 144]
  Coordinates: 
              year_day: [1..360]
              lat: [90..-90]
              lon: [ 0..357.5]
  Number Of Attributes: 5
    long_name :	Daily Climatology: Daily OLR
    units :	W/m^2
    information :	Raw daily averages across all years
    smoothing :	None
    calendar :	360_day

Example 3

Same as Example 2 except that 'calendar="365_day': 10*365=3650 days. The file used was: "olr.365_day.nc"

  Variable: olr
  Type: float
  Total Size: 153475200 bytes
              38368800 values
  Number of Dimensions: 3
  Dimensions and sizes:   [time | 3650] x [lat | 73] x [lon | 144]
  [SNIP]
  
  -----------------------
  Variable: olrClm
  Type: float
  Total Size: 15347520 bytes
              3836880 values
  Number of Dimensions: 3
  Dimensions and sizes:   [year_day | 365] x [lat | 73] x [lon | 144]
  Coordinates: 
              year_day: [1..365]
              lat: [90..-90]
              lon: [ 0..357.5]