ILAMB.Variable.Variable.integrateInSpace

Variable.integrateInSpace(region=None, mean=False, weight=None, intabs=False)[source]

Integrates the variable over a given region.

Uses nodal integration to integrate to approximate

\[\int_{\Omega} v(\mathbf{x},\dots)\ d\Omega\]

The arguments of the integrand reflect that while it must be at least defined in space, the remaining arguments are flexible. The variable \(\Omega\) represents the desired region over which we will integrate. If no region is specified, the variable will be integrated over the extent of its spatial domain. If the mean function value over time is desired, this routine will approximate

\[\frac{1}{A(\Omega)} \int_{\Omega} v(\mathbf{x},\dots)\ d\Omega\]

again by nodal integration. The spatial area which we divide by \(A(\Omega)\) is the non-masked area of the given region, also given by

\[A(\Omega) = \int_{\Omega}\ d\Omega\]

This means that if a function has some values masked or marked as invalid, we do not penalize the average value by including this as a point at which data is expected.

We also support the inclusion of an optional weighting function \(w(\mathbf{x})\) which is a function of space only. In this case, we approximate the following integral

\[\int_{\Omega} v(\mathbf{x},\dots)w(\mathbf{x})\ d\Omega\]

and if a mean value is desired,

\[\frac{1}{\int_{\Omega} w(\mathbf{x})\ d\Omega} \int_{\Omega} v(\mathbf{x},\dots)w(\mathbf{x})\ d\Omega\]
Parameters
  • region (str, optional) – name of the region overwhich you wish to integrate

  • mean (bool, optional) – enable to divide the integrand to get the mean function value

  • weight (numpy.ndarray, optional) – a data array of the same shape as this variable’s areas representing an additional weight in the integrand

  • intabs (bool, optional) – enable to integrate the absolute value

Returns

integral – a Variable instace with the integrated value along with the appropriate name and unit change.

Return type

ILAMB.Variable.Variable