Skip to content

API Reference

isku

__all__ module-attribute

__all__ = [
    "ExtractionTemplate",
    "GridWeightingRegions",
    "ProjectionTemplate",
    "RegionExtractor",
    "build_extraction_template",
    "build_projection_template",
    "extract_regions",
    "project",
]

ExtractionTemplate

Bases: Protocol

Template for pre and post region extraction transformation

See Also

build_extraction_template: Quickly build extraction template from functions for regionalization with pre/post transformations. extract_regions: Apply a template to extract a new regionalized dataset from gridded data. RegionExtractor: Protocol for regionalizing, or extracting regions from a dataset.

pre_extract

pre_extract(ds: Dataset) -> Dataset

Transform dataset before region extraction

post_extract

post_extract(ds: Dataset) -> Dataset

Transform dataset after region extraction

GridWeightingRegions

GridWeightingRegions(weights: Dataset)

Bases: RegionExtractor

Regions that can be extracted from regularly-gridded data after weighting grid points

'weights' dataset must have "lat", "lon", "weight", "region".

These are sometimes called "segment weights".

Raises:

  • ValueError

    If 'weights' is missing "lat", "lon", "weight" or "region" variables.

See Also

extract_regions: Extract new regionalized dataset. build_extraction_template: Quickly build extraction template from functions for regionalization. RegionExtractor: Protocol for regionalizing, or extracting regions from a dataset.

extract_regions

extract_regions(ds: Dataset) -> Dataset

Regionalize input gridded data after multiplying 'ds' by weights and summing the product within each region.

'ds' must have "lat", "lon" coordinates exactly matching "lat", "lon" in weights.

RegionExtractor

Bases: Protocol

Protocol for extracting regions from gridded data

See Also

extract_regions: Apply a template to extract a new regionalized dataset from gridded data with pre/post transformations. ExtractionTemplate: Technical protocol for a workflow with pre/post regionalization transformations.

extract_regions

extract_regions(ds: Dataset) -> Dataset

Extract and aggregate gridded dataset points into regionalized dataset

ProjectionTemplate

Bases: Protocol

Template for projecting a model with pre and post processing.

See Also

build_projection_template: Build a projection template from simple functions.

pre_project

pre_project(ds: Dataset) -> Dataset

Pre-process a dataset before projection

project

project(ds: Dataset) -> Dataset

Create a projection from a dataset

post_project

post_project(ds: Dataset) -> Dataset

Process a projected dataset

build_extraction_template

build_extraction_template(
    *, pre: Callable[[Dataset], Dataset], post: Callable[[Dataset], Dataset]
) -> ExtractionTemplate

Build a template of tranformation steps applied to input gridded data, pre/post regionalization, to create a derived variable as output

This function is a quick and simple way to build an ExtractionTemplate from two simple functions.

These steps should be general. They may contain logic for sanity checks on inputs and outputs, calculating derived variables and climate indices, adding or checking metadata or units. Avoid including logic for cleaning, or harmonizing input data, especially if it is specific to a single project's usecase. Generally avoid using a single strategy to output multiple unrelated variables.

See Also

extract_regions: Apply a template to extract a new regionalized dataset from gridded data. build_extraction_template: Quickly build extraction template from functions for regionalization. ExtractionTemplate: The underlaying protocol for a workflow that extracts a regionalized dataset.

extract_regions

extract_regions(
    ds: Dataset, *, template: ExtractionTemplate, regions: RegionExtractor
) -> Dataset

Regionalize a gridded dataset with a template of pre- and post-extraction transformations

Parameters:

  • ds (Dataset) –

    A gridded dataset with variables to regionalize and transform.

  • template (ExtractionTemplate) –

    A template describing pre- and post-regionalization trasformations to create the output regionalized data.

  • regions (RegionExtractor) –

    Regions to extract from the gridded dataset.

Returns:

  • out ( Dataset ) –

    A regionalized dataset.

Notes

This function is especially concerned with applying a transformation step before regions are extracted, and applying a transformation after extraction. To extract regions without the surrounding transformations, use the extract_regions method on whatever was passed for the regions argument.

See Also

build_extraction_template: Quickly build extraction templates from functions.

GridWeightingRegions: An example of a RegionExtractor that can be used for the regions argument.

build_projection_template

build_projection_template(
    *,
    pre: Callable[[Dataset], Dataset],
    project: Callable[[Dataset], Dataset],
    post: Callable[[Dataset], Dataset],
) -> ProjectionTemplate

Use simple functions to quickly build a model to project effects, impacts and/or damages.

This function is a quick and simple way to build an ProjectionTemplate from three simple functions.

See Also

project: Apply a projection template to a dataset. ProjectionTemplate: Technical ProjectionTemplate protocol.