openghg_inversions.basis.algorithms#

Algorithms for computing basis functions.

openghg_inversions.basis.algorithms.quadtree_algorithm(fps: ndarray, nbasis: int, seed: int | None = None) ndarray#

Given an array and a specified number of basis functions, return basis regions specified by the quadtree algorithm.

Parameters:
  • fps – array (mean flux times mean footprints) to use to calculate basis regions

  • nbasis – target number of basis regions

  • seed – optional random seed to use (for testing or reproducing results)

Returns:

2D numpy array with positive integer values representing basis regions.

openghg_inversions.basis.algorithms.weighted_algorithm(grid: ndarray, bucket: float = 1, nregion: int = 100, tol: int = 1, domain: str = 'EUROPE') ndarray#

Obtain basis function with nregions (for land-sea split).

Parameters:
  • grid – 2D grid of footprints * flux, or whatever grid you want to split. Could be: population data, spatial distribution of bakeries, you choose!

  • bucket – Initial bucket value for each basis function region. Defaults to 1

  • nregion – Number of desired basis function regions Defaults to 100

  • tol – Tolerance to find number of basis function regions. i.e. optimizes nregions to +/- tol Defaults to 1

  • domain – Domain across which to calculate basis functions. Currently limited to “EUROPE” or “EASTASIA”

Returns:

2D basis function array

Return type:

basis_function