NCL Home > Documentation > Functions > Meteorology

advect_variable_cfd

Using centered-finite_differences (cfd) to estimate gradients, advect a variable horizontally on a regional or global rectilinear grid.

Available in version 6.6.2 and later.

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 advect_variable_cfd (
		u            : numeric,  
		v            : numeric,  
		x            : numeric,  
		lat      [*] : numeric,  
		lon      [*] : numeric,  
		cyclic   [1] : logical,  
		longName [1] : string,   
		units    [1] : string,   
		opt          : integer   
	)

	return_val [dimsizes(x)] :  float or double

Arguments

u

Array containing zonal wind components (m/s). The array must be rectilinear and ordered south to north.

v

Array containing meridional wind components (m/s). Same size and shape as u.

x

Array containing a scalar quantity (eg: temperature, specific humidity, etc). Same size and shape as u.

cyclic

Grid type: cyclic=True means grid is cyclic in longitude; cyclic=False means regional grid.

longName

A string to be used as the long_name of the advected variable.

units

A string specifying the units of the returned variable.

opt

option.

  • opt=0 means return the the advection result.
  • opt=1 means return the advection result, longitudinal and latitudinal gradients as part of a three-element variable of type list

Return value

A multi-dimensional array of the same size and shape as x. The output will be double if u, v or x is of type double.

Description

Calculate the horizontal advection of a quantity on the globe.


             adv_X =  U*(dX/dlon) + V*(dX/dlat)

NOTE: This is a non-linear quantity. It is not appropriate to use (say) monthly mean quantities. Rather, high frequency (eg: hourly, 3-hr, 6-hr, daily) quantities should be used.

To see gradients derived via spherical harmonics and 'simple' centered finite differences, see: gradients.

See Also

advect_variable

Examples

Example 1 Here, the variables u,v (m/s) and T (degK) are on a global rectilinear grid and are ordered south to north.


; Units: u*(dT/dlon) + v(dT/dlat)  ->  (m/s)*(K/m) => K/s. If T were degC, the units would be C/s. 

   f = addfile ("...", "r")
   u = f->U           ; (time,lev,lat,lon); (7,17,73,144);  m/s
   v = f->V
   T = f->T           ; degK

   cyclic    = True   ; Grid is global
   opt_adv   = 0      ; Return only the advected variable

   long_name = "temp advection: Global"
   units     = "K/s"

   advTcfd   = advect_variable_cfd(u,v,T, T&lat,T&lon, cyclic, long_name, units, opt_adv)

   printVarSummary(advTcfd)
   printMinMax(advTcfd, 0)

The (edited) output is:

          Variable: advTcfd
          Type: float
          Total Size: 5003712 bytes
                      1250928 values
          Number of Dimensions: 4
          Dimensions and sizes:   [time | 7] x [level | 17] x [lat | 73] x [lon | 144]
          Coordinates: 
                      time: [1823280..1823424]
                      level: [1000..10]
                      lat: [-90..90]
                      lon: [ 0..357.5]
          
          Number Of Attributes: 4
            _FillValue :  -9.96921e+36
            long_name :   temp advection: Global
            units :       m-K/s
            NCL_tag :     advect_variable_cfd
          
          (0)     tCFD: Global (m-K/s) : min=-0.00107328   max=0.000923747
          (0)     ===

Example 2 Similar to Example 1 but for a regional rectilinear grid. Return the result as a variable of type list containing the advected quantity and the meridional and zonal gradients of the vatiable being advected.

; region

  latS =  25
  latN =  50.
  lonL = 230.
  lonR = 300.

  U = u(:,:,{latS:latN},{lonL:lonR})
  V = v(:,:,{latS:latN},{lonL:lonR})
  T = t(:,:,{latS:latN},{lonL:lonR})

  cyclic  = False            ; Grid is regional
  opt_adv = 1                ; Return a variable of type list containing 3 variables

  T_list  = advect_variable_cfd(U,V,T, T&lat,T&lon, cyclic \
                               ,"tcfd: Region","m-K/s", opt_adv)

  Tadv = T_list[0]           ; advected quantity
  Tgrx = T_list[1]           ; zonal (longitudinal) gradient of (here) temperature
  Tgry = T_list[2]           ; meridional (latitudinal) gradient

  printVarSummary(Tadv)    ; advection of temperature
  printVarSummary(Tgrx)    ; zonal gradient
  printVarSummary(Tgry)    ; meridional gradient

The (edited) output is:

          Variable: Tadv
          Type: float
          Total Size: 151844 bytes
                      37961 values
          Number of Dimensions: 4
          Dimensions and sizes:   [time | 7] x [level | 17] x [lat | 11] x [lon | 29]
          Coordinates: 
                      time: [1823280..1823424]
                      level: [1000..10]
                      lat: [25..50]                       region
                      lon: [230..300]
          Number Of Attributes: 4
            _FillValue :  -9.96921e+36
            long_name :   tcfd: Region
            units :       m-K/s
            NCL_tag :     advect_variable_cfd
          
          (0)     tcfd: Region (m-K/s) : min=-0.000617743   max=0.000705905
          
            ===
          
          Variable: Tgrx
          Type: float
          Total Size: 151844 bytes
                      37961 values
          Number of Dimensions: 4
          Dimensions and sizes:   [time | 7] x [level | 17] x [lat | 11] x [lon | 29]
          Coordinates: 
                      time: [1823280..1823424]
                      level: [1000..10]
                      lat: [25..50]
                      lon: [230..300]
          Number Of Attributes: 3
            units :       ?/m
            long_name :   cfd: zonal gradient
            _FillValue :  -9.96921e+36
          
          (0)     cfd: zonal gradient (?/m) : min=-3.29331e-05   max=2.25408e-05
          
          ===
          
          Variable: Tgry
          Type: float
          Total Size: 151844 bytes
                      37961 values
          Number of Dimensions: 4
          Dimensions and sizes:   [time | 7] x [level | 17] x [lat | 11] x [lon | 29]
          Coordinates: 
                      time: [1823280..1823424]
                      level: [1000..10]
                      lat: [25..50]
                      lon: [230..300]
          Number Of Attributes: 3
            units :       ?/m
            long_name :   cfd: meridional gradient
            _FillValue :  -9.96921e+36
          
          (0)     cfd: meridional gradient (?/m) : min=-3.78421e-05   max=2.14391e-05