Skip to content

Commit

Permalink
Add vulnerability functions.
Browse files Browse the repository at this point in the history
We add vulnerability functions with the aim of replicating the paper:
'Climate change-related statistical indicators'
Statistics Paper Series No 48 from the European Central Bank.
https://www.ecb.europa.eu/pub/pdf/scpsps/ecb.sps48~e3fd21dd5a.en.pdf?4826f6ee77d3ac7a681916b6d419b751

Co-authored-by: Víctor de Luna <[email protected]>
Co-authored-by: Arfima Dev <[email protected]>

Signed-off-by: Virginia Morales <[email protected]>
  • Loading branch information
VMarfima committed Aug 7, 2024
1 parent 9ac2d6c commit 0114aaf
Show file tree
Hide file tree
Showing 20 changed files with 1,770 additions and 206 deletions.
1 change: 1 addition & 0 deletions src/physrisk/api/v1/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import Enum
from typing import Dict, List, Optional, Union

import numpy as np
Expand Down
8 changes: 6 additions & 2 deletions src/physrisk/api/v1/impact_req_resp.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class AssetImpactRequest(BaseModel):
True, description="If true, include impact calculation details."
)
use_case_id: str = Field(
"",
description="Identifier for 'use case' used in the risk measures calculation.",
"DEFAULT",
description=(
"Identifier for 'use case' used in vulnerability models and risk measures calculations."
),
)
provider_max_requests: Dict[str, int] = Field(
{},
Expand Down Expand Up @@ -70,6 +72,8 @@ class Category(int, Enum):
HIGH = 3
REDFLAG = 4

NORISK = -1


class RiskMeasureDefinition(BaseModel):
measure_id: str = Field(None, description="Identifier for the risk measure.")
Expand Down
13 changes: 2 additions & 11 deletions src/physrisk/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

from dependency_injector import containers, providers

from physrisk.kernel import calculation as calc
from physrisk.data.hazard_data_provider import SourcePath
from physrisk.data.inventory import EmbeddedInventory
from physrisk.data.inventory_reader import InventoryReader
from physrisk.data.pregenerated_hazard_model import ZarrHazardModel
from physrisk.data.zarr_reader import ZarrReader
from physrisk.kernel import calculation as calc
from physrisk.kernel.hazard_model import HazardModelFactory
from physrisk.kernel.vulnerability_model import (
DictBasedVulnerabilityModels,
VulnerabilityModels,
VulnerabilityModelsFactory,
)
from physrisk.kernel.vulnerability_model import DictBasedVulnerabilityModelsFactory
from physrisk.requests import Requester, _create_inventory, create_source_paths


Expand Down Expand Up @@ -41,11 +37,6 @@ def hazard_model(
)


class DictBasedVulnerabilityModelsFactory(VulnerabilityModelsFactory):
def vulnerability_models(self) -> VulnerabilityModels:
return DictBasedVulnerabilityModels(calc.get_default_vulnerability_models())


class Container(containers.DeclarativeContainer):
config = providers.Configuration(default={"zarr_sources": ["embedded", "hazard"]})

Expand Down
3 changes: 1 addition & 2 deletions src/physrisk/data/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

import physrisk.data.colormap_provider as colormap_provider
import physrisk.data.static.hazard
from physrisk.api.v1.hazard_data import HazardResource, Period
from physrisk.data.inventory_reader import HazardModels

from ..api.v1.hazard_data import HazardResource, Period

# from physrisk.kernel.hazards import ChronicHeat


Expand Down
Loading

0 comments on commit 0114aaf

Please sign in to comment.