openairclim.core.interpolate_space
Interpolation and Regridding methods in the space domain.
- openairclim.core.interpolate_space.calc_weights(spec: str, resp: Dataset, inv: Dataset, unique_locs: tuple[ndarray, ndarray] | None = None) Dataset[source]
Calculate the weighting factors for a given response and inventory.
- Parameters:
spec (str) – Name of the species for which the weights are being calculated.
resp (xarray.Dataset) – Response dataset
inv (xarray.Dataset) – Emission inventory dataset
unique_locs (tuple[numpy.ndarray, numpy.ndarray] | None) – Output of
unique_lat_plev_vals()forinv. If given, the response is interpolated on the unique locations only. IfNone, every inventory point is interpolated directly.
- Returns:
Dataset with weighting parameters
- Return type:
- openairclim.core.interpolate_space.find_weights(spec: str, resp: Dataset, inv: Dataset) Dataset[source]
Find weighting parameters on response grid for entire emission inventory.
Response grid is 2d with dimensions lat and plev. First, query checksum table to get pre-calculated weights from cache. If weights are not pre-calculated for the resp / inv combination, execute calc_weights.
- Parameters:
spec (str) – Name of the species
resp (xarray.Dataset) – Response Dataset with lat and plev dimensions
inv (xarray.Dataset) – Emission inventory Dataset
- Returns:
Dataset with weighting parameters
- Return type:
- openairclim.core.interpolate_space.unique_lat_plev_vals(inv: Dataset) tuple[ndarray, ndarray][source]
Find the unique (lat, plev) locations of an emission inventory.
Although OpenAirClim’s inventories are flat, they were often built from grids and hence contain far fewer unique (lat, plev) pairs than emission points. Interpolating over the unique pairs only and pushing the results back is significantly cheaper than interpolatinng over every point.
- Parameters:
inv (xarray.Dataset) – Emission inventory dataset
- Returns:
locations, array of shape(n_unique, 2)with columns lat and plev, andinverse, integer array of shape(n_points,)such thatlocations[inverse]reproduces the inventory’s (lat, plev) pairs.- Return type: