Source code for bw2regional.meta

from pathlib import Path

from bw2data.serialization import CompoundJSONDict, SerializedDict

from .hashing import sha256


[docs] class Loadings(SerializedDict): """Metadata on regionalized LCIA weightings."""
[docs] filename = "loadings.json"
[docs] class Intersections(CompoundJSONDict): """Areal intersections between the elements of two geo- or topocollections"""
[docs] filename = "intersections.json"
[docs] class Geocollections(SerializedDict): """Metadata for spatial data sets."""
[docs] filename = "geocollections.json"
def __setitem__(self, key, value): from .utils import get_spatial_dataset_kind if "filepath" in value: assert Path(value["filepath"]).is_file(), "Can't find file at `{}`".format( value["filepath"] ) value["sha256"] = sha256(value["filepath"]) value["kind"] = get_spatial_dataset_kind(value["filepath"]) super(Geocollections, self).__setitem__(key, value)
[docs] class Topocollections(Geocollections): """Mappings from geocollections to a set of topographical face ids."""
[docs] filename = "topocollections.json"
def __setitem__(self, key, value): value["empty"] = value.get("empty", True) if "geocollection" not in value: raise ValueError( "topocollections must be linked to exactly one geocollection" ) elif value["geocollection"] not in geocollections: raise ValueError( "Linked geocollection {} does not exist".format(value["geocollection"]) ) super(Topocollections, self).__setitem__(key, value)
[docs] class ExtensionTables(SerializedDict): """Metadata for extension tables that give loadings on a third spatial scale."""
[docs] filename = "extension-tables.json"
[docs] extension_tables = ExtensionTables()
[docs] geocollections = Geocollections()
[docs] intersections = Intersections()
[docs] loadings = Loadings()
[docs] topocollections = Topocollections()