bw2regional.utils

Module Contents

Functions

create_certain_datapackage(indices, data, data_store, ...)

create_empty_intersection(name)

Shortcut to create Intersection object with no data

dp(fp)

filter_columns(matrix, col_indices[, exclude])

Filter a sparse matrix, either excluding or taking only the columns in col_indices.

filter_fiona_metadata(dct)

Include only valid Fiona keywords for opening a feature collection

filter_rows(matrix, row_indices[, exclude])

Filter a sparse matrix, either excluding or taking only the rows in row_indices.

get_pandarus_map(geocollection)

get_pandarus_map_for_method(method[, geocollection])

get_spatial_dataset_kind(filepath)

Get kind of spatial dataset at filepath.

hash_collection(name)

Return SHA256 hash for a topo- or geocollection.

import_regionalized_cfs(geocollection, method_tuple, ...)

Import data from a vector geospatial dataset into a Method.

reset_all_geo()

Reset all bw2regional data and metadata

reset_geo_meta()

bw2regional.utils.create_certain_datapackage(indices, data, data_store, **extra_metadata)[source]
bw2regional.utils.create_empty_intersection(name)[source]

Shortcut to create Intersection object with no data

bw2regional.utils.dp(fp)[source]
bw2regional.utils.filter_columns(matrix, col_indices, exclude=True)[source]

Filter a sparse matrix, either excluding or taking only the columns in col_indices.

  • matrix: A Scipy sparse matrix.

  • col_indices: An iterable of integer column indices

  • exclude: Boolean. If true, exclude rows in row_indices. Otherwise, include only rows in row_indices.

Returns a sparse matrix.

bw2regional.utils.filter_fiona_metadata(dct)[source]

Include only valid Fiona keywords for opening a feature collection

bw2regional.utils.filter_rows(matrix, row_indices, exclude=True)[source]

Filter a sparse matrix, either excluding or taking only the rows in row_indices.

  • matrix: A Scipy sparse matrix.

  • row_indices: An iterable of integer row indices

  • exclude: Boolean. If true, exclude rows in row_indices. Otherwise, include only rows in row_indices.

Returns a sparse matrix.

bw2regional.utils.get_pandarus_map(geocollection)[source]
bw2regional.utils.get_pandarus_map_for_method(method, geocollection=None)[source]
bw2regional.utils.get_spatial_dataset_kind(filepath)[source]

Get kind of spatial dataset at filepath.

Returns one of “vector”, “raster”, None.

bw2regional.utils.hash_collection(name)[source]

Return SHA256 hash for a topo- or geocollection.

Prefers topocollection if available.

bw2regional.utils.import_regionalized_cfs(geocollection, method_tuple, mapping, scaling_factor=1, global_cfs=None, nan_value=None)[source]

Import data from a vector geospatial dataset into a Method.

A Method can have both site-generic and regionalized characterization factors.

The mapping defines which field (vector) maps to which biosphere flows. Some geocollections may only define regionalized chracterization factors for a single biosphere flow, but it is much more common to have each field or band map to multiple biosphere flows. Therefore, mapping should be defined as:

{
    field name (str): [list of biosphere flows (tuples)]
}
Parameters:
  • geocollection (*) – A geocollection name.

  • method_tuple (*) – A method tuple.

  • mapping (*) – Mapping from fields or bands to biosphere flows. See above.

  • scaling_factor (*) – Optional. Rescale the values in the spatial data source.

  • global_cfs (*) – An optional list of CFs to add when writing the method.

  • nan_value (*) – Sentinel value for missing values if NaN is not used directly.

bw2regional.utils.reset_all_geo()[source]

Reset all bw2regional data and metadata

bw2regional.utils.reset_geo_meta()[source]