reVeal.config.downscale.RegionalDownscaleConfig#
- class RegionalDownscaleConfig(*, grid: Annotated[Path, PathType(path_type=file)], grid_ext: str | None = None, grid_flavor: str | None = None, grid_crs: str | None = None, grid_priority: str, grid_baseline_load: str, baseline_year: Annotated[int, Gt(gt=0)], grid_capacity: str, projection_resolution: RegionalResolutionEnum, load_projections: Annotated[Path, PathType(path_type=file)], load_value: str, load_year: str, max_site_addition_per_year: Annotated[float | None, Strict(strict=False), Gt(gt=0.0)] = None, site_saturation_limit: Annotated[float | None, Strict(strict=False), Gt(gt=0.0), Le(le=1.0)] = 1.0, priority_power: Annotated[float | None, Strict(strict=False), Gt(gt=0.0)] = 1.0, n_bootstraps: Annotated[int, Gt(gt=0)] | None = 10000, random_seed: int | None = 0, max_workers: Annotated[int, Gt(gt=0)] | None = None, reduce_output: bool | None = False, load_regions: str | None = None, region_weights: dict | None = None, regions: Annotated[Path, PathType(path_type=file)], region_names: str, regions_ext: str | None = None, regions_flavor: str | None = None, **extra_data: Any)[source]#
Bases:
BaseDownscaleConfigModel for regional downscaling configuration. Extends BaseDownscaleConfig with additional validations for regional downscaling.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Methods
Check that either load_regions or region_weights is provided, and not both.
Dynamically set the crs property.
Dynamically set the grid_ext property.
Dynamically set the dset_flavor.
Dynamically set the regions_ext property.
Dynamically set the regions_flavor.
Validate the input grid dataset can be opened, has the expected attributes, and those attributes are numeric.
Validate the input load_projections dataset can be opened, has the expected attributes, and those attributes are numeric.
If region_weights is specified, validate the input load_projections does not have duplicate entries over years.
If load_regions is specified, check that the column exists in the load_projections dataset.
Check that the regions in the regions dataset match either the load_regions in the load_projections dataset or the keys of the region_weights.
Validates the input regions dataset: 1.
Validate that the sum of all region weights is equal to 1.
Attributes
model_computed_fieldsConfiguration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Get extra fields set during validation.
model_fieldsReturns the set of fields that have been explicitly set on this model instance.
projection_resolutionload_regionsregion_weightsregionsregion_namesregions_extregions_flavorgrid_prioritygrid_baseline_loadbaseline_yeargrid_capacityload_projectionsload_valueload_yearmax_site_addition_per_yearsite_saturation_limitpriority_powern_bootstrapsrandom_seedmax_workersreduce_outputgridgrid_extgrid_flavorgrid_crs- check_load_regions_or_region_weights()[source]#
Check that either load_regions or region_weights is provided, and not both.
- set_regions_flavor()[source]#
Dynamically set the regions_flavor.
- Raises:
TypeError – A TypeError will be raised if the input dset is not either a geoparquet or compatible with reading with ogr.
- validate_regions()[source]#
Validates the input regions dataset: 1. Has either Polygon or MultiPolygon geometries. 2. Has a column corresponding to the input region_names parameter 3. Has a CRS matching the input grid.
- validate_load_projections_duplicate_years()[source]#
If region_weights is specified, validate the input load_projections does not have duplicate entries over years.
- validate_load_regions()[source]#
If load_regions is specified, check that the column exists in the load_projections dataset.
Also check for duplicate entries over load_regions and years.
- validate_region_consistency()[source]#
Check that the regions in the regions dataset match either the load_regions in the load_projections dataset or the keys of the region_weights.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- property model_extra: dict[str, Any] | None#
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- property model_fields_set: set[str]#
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- set_grid_crs()#
Dynamically set the crs property.
- set_grid_ext()#
Dynamically set the grid_ext property.
- set_grid_flavor()#
Dynamically set the dset_flavor.
- Raises:
TypeError – A TypeError will be raised if the input dset is not either a geoparquet or compatible with reading with ogr.
- validate_grid()#
Validate the input grid dataset can be opened, has the expected attributes, and those attributes are numeric.
- validate_load_projections()#
Validate the input load_projections dataset can be opened, has the expected attributes, and those attributes are numeric. Also ensures that the projections are for years after the the specified baseline year.