dubfi.fluxes.localization

Localization utilities.

Added in version 0.1.1.

Changed in version 0.1.2: (renamed some methods)

Attributes

GASPARI_COHN_CUTOFF

Cutoff scale of gaspari_cohn().

GASPARI_COHN_GAUSS_CUTOFF

Cutoff scale of gaspari_cohn_gauss().

LOCALIZATION_FUNCTIONS

Access localization functions by (lower case) name.

Classes

Localization

Localization class for in-situ observations.

Functions

gaspari_cohn(x)

Gaspari-Cohn function.

gaspari_cohn_gauss(x)

Gaspari-Cohn with scale adjusted to match Gaussian.

gauss(x)

Gaussian, \(\exp(-\tfrac{1}{2} x^2)\).

Module Contents

dubfi.fluxes.localization.gaspari_cohn(x)

Gaspari-Cohn function.

This function has compact support on [-2, 2].

Parameters:

x (numpy.ndarray)

Return type:

numpy.ndarray

dubfi.fluxes.localization.GASPARI_COHN_CUTOFF = 2.0

Cutoff scale of gaspari_cohn().

gaspari_cohn(x) == 0 for abs(x) > GASPARI_COHN_CUTOFF.

dubfi.fluxes.localization.gaspari_cohn_gauss(x)

Gaspari-Cohn with scale adjusted to match Gaussian.

This function has compact support on [-2/sqrt(0.3), 2/sqrt(0.3)] and is guaranteed to be zero for |x| >= 3.6515.

Parameters:

x (numpy.ndarray)

Return type:

numpy.ndarray

dubfi.fluxes.localization.GASPARI_COHN_GAUSS_CUTOFF = 3.6514837167011076

Cutoff scale of gaspari_cohn_gauss().

gaspari_cohn_gauss(x) == 0 for abs(x) > GASPARI_COHN_GAUSS_CUTOFF.

dubfi.fluxes.localization.gauss(x)

Gaussian, \(\exp(-\tfrac{1}{2} x^2)\).

Parameters:

x (numpy.ndarray)

Return type:

numpy.ndarray

dubfi.fluxes.localization.LOCALIZATION_FUNCTIONS

Access localization functions by (lower case) name.

class dubfi.fluxes.localization.Localization(func, hscale, vscale, tscale)

Localization class for in-situ observations.

Localization object allows creating localization matrices.

Parameters:
  • func (callable | {"Gauss", "Gaspari-Cohn", "Gaspari-Cohn-scaled"}) – localization function. This must take an array as argument and describe a positive, symmetric function f(x) that decreases monotonically from |x| from f(0)=1 to f(x)=0 (at least asymptotically) for large x. Names for known localization functions are allowed. Note that “Gaspari-Cohn-scaled” is an approximation of a Gaussian with compact support, see gaspari_cohn_gauss().

  • hscale (float) – horizontal scale in meters

  • vscale (float) – vertical scale in meters

  • tscale (np.timedelta64) – temporal scale

classmethod from_config(config)

Construct Localization from configuration.

Parameters:

config (dict)

property function

Localization function, requires normalized input.

rel_dist_horizontal(lon, lat, lon2=None, lat2=None)

Matrix of normalized horizontal distances.

Changed in version 0.1.2: (renamed, added optional variables)

Parameters:
  • lon (numpy.ndarray)

  • lat (numpy.ndarray)

  • lon2 (numpy.ndarray | None)

  • lat2 (numpy.ndarray | None)

Return type:

numpy.ndarray

weights_spatial(lon, lat, height, lon2=None, lat2=None, height2=None)

Spatial weights (localization) matrix.

Changed in version 0.1.2: (added optional variables)

Parameters:
  • lon (numpy.ndarray)

  • lat (numpy.ndarray)

  • height (numpy.ndarray)

  • lon2 (numpy.ndarray | None)

  • lat2 (numpy.ndarray | None)

  • height2 (numpy.ndarray | None)

Return type:

numpy.ndarray

weights_time(time, time2=None)

Temporal weights (localization) matrix.

Changed in version 0.1.2: (added optional variables)

Parameters:
  • time (numpy.ndarray)

  • time2 (numpy.ndarray | numpy.datetime64 | None)

Return type:

numpy.ndarray

rel_dist_horizontal_unique(lon, lat)

Return normalized horizontal distance matrix for unique coordinates.

Returns:

  • dist (np.ndarray) – distance matrix

  • indices (np.ndarray) – indices into dist along lon, lat coordinates

  • .. versionchanged:: 0.1.2 (renamed)

Parameters:
  • lon (numpy.ndarray)

  • lat (numpy.ndarray)

Return type:

tuple[numpy.ndarray, numpy.ndarray]

matrix(lon, lat, height, time)

Construct localization matrix based on coordinates.

All input arrays must be one-dimensional and aligned.

Parameters:
  • lon (np.ndarray) – longitude (degrees east)

  • lat (np.ndarray) – latitude (degrees east)

  • height (np.ndarray) – vertical coordinate in meters

  • time (np.ndarray) – time relative to localization time scale with arbitrary offset

Returns:

localization_weights – localization matrix specifying weights between each combination of coordiniates

Return type:

np.ndarray

matrix_sparse(lon, lat, height, time, threshold=1e-05, chunk=500)

Construct localization matrix based on coordinates, see matrix().

Parameters:
  • lon (numpy.ndarray)

  • lat (numpy.ndarray)

  • height (numpy.ndarray)

  • time (numpy.ndarray)

  • threshold (float)

  • chunk (int)

Return type:

scipy.sparse.csc_array