Skip to content

Commit

Permalink
Onboarding World Resources Institute's thermal power plant physical c…
Browse files Browse the repository at this point in the history
…limate vulnerability factors

Onboarding World Resources Institute's thermal power plant physical climate vulnerability factors

Signed-off-by: EglantineGiraud <[email protected]>
  • Loading branch information
EglantineGiraud committed Nov 2, 2023
1 parent d490a0e commit ef6bfb4
Showing 1 changed file with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ def get_distributions(
assert isinstance(response_baseline, HazardEventDataResponse)

baseline_curve = ExceedanceCurve(1.0 / response_baseline.return_periods, response_baseline.intensities)
inundation_protection_level = (
protection_depth = (
0.0
if len(response_baseline.intensities) == 0
else baseline_curve.get_value(1.0 / asset.get_inundation_protection_return_period())
)

intensity_curve = ExceedanceCurve(1.0 / response_scenario.return_periods, response_scenario.intensities)
if intensity_curve.values[0] < inundation_protection_level:
if inundation_protection_level < intensity_curve.values[-1]:
intensity_curve = intensity_curve.add_value_point(inundation_protection_level)
if intensity_curve.values[0] < protection_depth:
if protection_depth < intensity_curve.values[-1]:
intensity_curve = intensity_curve.add_value_point(protection_depth)

intensities, probs = intensity_curve.get_probability_bins()
probs = np.insert(probs, 0, intensity_curve.probs[0])
Expand All @@ -129,14 +129,20 @@ def get_distributions(
elif asset.turbine in self.vuln_curves_by_type:
curves = self.vuln_curves_by_type[asset.turbine]

impacts = [
np.max([np.interp(intensity, curve.intensity, curve.impact_mean) for curve in curves])
if inundation_protection_level < intensity and 0 < len(curves)
else 0.0
for intensity in intensities
]
if 0 < len(curves):
impacts = [
np.max([np.interp(intensity, curve.intensity, curve.impact_mean) for curve in curves])
for intensity in intensities
]
else:
impacts = [0.0 for _ in intensities]

# keep all bins, but make use of vulnerability matrix to apply protection level
# for improved performance we could truncate (and treat identity matrix as a special case)
# but this general version allows model uncertainties to be added
protection = np.where(protection_depth < intensities, 1.0, 0.0)

vul = VulnerabilityDistrib(self.hazard_type, intensities, impacts, np.eye(len(impacts)))
vul = VulnerabilityDistrib(self.hazard_type, intensities, impacts, np.diag(protection))
event = HazardEventDistrib(self.hazard_type, intensities, probs)
return vul, event

Expand Down

0 comments on commit ef6bfb4

Please sign in to comment.