Skip to content

Commit

Permalink
Merge pull request #187 from joemoorhouse/bug-fix
Browse files Browse the repository at this point in the history
Improve failure behaviour with missing data
  • Loading branch information
joemoorhouse authored Nov 29, 2023
2 parents e6e4e30 + 7536890 commit 66828e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/physrisk/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from physrisk.hazard_models.core_hazards import get_default_source_paths
from physrisk.kernel.exposure import JupterExposureMeasure, calculate_exposures
from physrisk.kernel.hazards import all_hazards
from physrisk.kernel.impact_distrib import EmptyImpactDistrib
from physrisk.kernel.risk import AssetLevelRiskModel, BatchId, Measure, MeasureKey
from physrisk.kernel.vulnerability_model import VulnerabilityModelBase

Expand Down Expand Up @@ -282,13 +283,13 @@ def _get_asset_impacts(

scenarios = [request.scenario] if request.scenarios is None or len(request.scenarios) == 0 else request.scenarios
years = [request.year] if request.years is None or len(request.years) == 0 else request.years
risk_measures = None
if request.include_measures:
batch_impacts, measures = risk_model.calculate_risk_measures(assets, scenarios, years)
measure_ids_for_asset, definitions = risk_model.populate_measure_definitions(assets)
risk_measures = _create_risk_measures(measures, measure_ids_for_asset, definitions, assets, scenarios, years)
elif request.include_asset_level:
batch_impacts = risk_model.calculate_impacts(assets, scenarios, years)
risk_measures = None

if request.include_asset_level:
results = batch_impacts[BatchId(scenarios[0], years[0])]
Expand Down Expand Up @@ -317,6 +318,9 @@ def _get_asset_impacts(
else:
calc_details = None

if isinstance(v.impact, EmptyImpactDistrib):
continue

impact_exceedance = v.impact.to_exceedance_curve()
hazard_impacts = AssetSingleImpact(
hazard_type=v.impact.hazard_type.__name__,
Expand Down

0 comments on commit 66828e9

Please sign in to comment.