NCL Home > Documentation > Functions > Climatology

smthClmDayTLL

Calculates a smooth mean daily annual cycle for an array nominally dimensioned (Time,Lat,Lon).

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 smthClmDayTLL (
clmDay [*][*][*] : float or double,
nHarm        [1] : integer
)

return_val [366][*][*] :  typeof(clmDay)
```

Arguments

clmDay

A three-dimensional array (ntim, lat, lon) output by clmDayTLL. Typically, ntim is of size 360 (360_day), 365 (365_day) or 366 (gregorian) depending up the calendar attribute associated with the source variable.

nHarm

The number of harmonics that will be used to construct the smoothed mean annual cycle. Usually, nHarm is 1 to 3 with 2 being most common. A value of 2 means to use the annual and semi-annual harmonics only.

Return value

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

Description

Calculate a smooth annual cycle using the output from clmDayTLL. A Fourier analysis is performed via an FFT. Next, all harmonics greater than nHarm are set to zero and a backward transform is performed.

In 6.2.1, this function was updated to work on daily SST data which have _FillValue over land.

Examples

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

Example 1

Compute the smooth long term daily means. The input is 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, subsequently, associate it with the required variables.

```
;;The following library is loaded by default in NCL V6.2.0 and newer

diri    = "./"                             ; input directory
fili    = "HGT.nc"                         ; input file
f       = addfile (diri+fili , "r")
;***********************************************************
; Read time and create required yyyyddd
;***********************************************************
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) )
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: use one level only for this example
;***********************************************************
hgt     = short2flt( f->hgt(:,0,:,:) )    ; convert to float
;***********************************************************
; Compute raw daily climatology
;***********************************************************
hClmDay    = clmDayTLL(hgt, yyyyddd)     ; daily climatology at each grid point
;***********************************************************
; Compute smoothed daily climatology using 2 harmonics
;***********************************************************
hClmDay_sm = smthClmDayTLL(hClmDay, 2)
printVarSummary(hClmDay_sm)
```
The (edited) output yields
```Variable: hClmDay_sm
Type: float
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
smoothing :   FFT: 2 harmonics were retained.
information : Smoothed daily climatological averages
units :       m
long_name :   Daily Climatology: mean Daily Geopotential height
```