-
Notifications
You must be signed in to change notification settings - Fork 148
Risk Trajectory Split 5: Interpolated Risk Trajectories #1201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
spjuhel
wants to merge
39
commits into
develop
Choose a base branch
from
feature/interpolated-trajectories
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As the Risk trajectory PR is too substantial, this is the fifth (and final) split.
This PR builds on all previous splits (#1197 #1198 #1199 #1200).
It implements the high level
InterpolatedRiskTrajectoryclass and the low level computing classCalcRiskMetricsPeriod, similarly as Split 4, but with interpolation in between pairs of consecutiveSnapshot. The additional complexity and the differences with Split 4 are summarized below.It also ships the tutorial for the
trajectorymodule.Core differences
Instead of having one
CalcRiskMetricsPointsfor all snapshot, the high level class holds a list ofCalcRiskMetricsPeriodobjects (one for each pair of consecutive snapshots), each having the role of computing the metrics for the period defined by the two snapshots.CalcRiskMetricsPeriodthus takes a starting (0) and ending (1)Snapshotinstead of a list of them.It also takes an
InterpolationStrategyin addition to theImpactComputationStrategy, and a "time resolution", which defines the number of time points to have for the metrics (including start and end).Interpolation conceptual flow (in
calc_risk_metrics)Instead of "simply" computing the impacts for each snapshot, it computes all corners of the so-called Risk Cube™ (all 2³ convolutions of (exp,haz,vul) Impact triplet), and the interpolated risk metrics based on these.
The eight corners are
@lazy_property, and labelledEiHjVk(where i,j,k are 0 or 1), such that for instanceE0H0V0is the impact object corresponding to Exposure, Hazard and Vulnerability of Snapshot 0.From then, arrays of impact matrices are interpolated between corners for as many points as needed by the given time resolution. (i.e. if start date is 2020, end date is 2025 and resolution is yearly, arrays of 5 impact matrices will be computed).
As it is not feasible (in general) to interpolate between corners with a different hazard (shapes of impact matrices may differ), this interpolation of impact matrices is only done "along the exposure dimension", that is for the four edges of the Risk Cube™ where hazard and vulnerability remain constant along the edge. (side note here, it should actually also be possible to do that for vulnerability, will see for future updates)
These four arrays of matrices are labelled
imp_mats_HiVj, to be read as "Evolution of impacts matrices with hazard constant to snapshot i, vulnerability constant to snapshot j, and exposure changing from snapshot 0 to 1".From then on, interpolation is made on the metrics themselves and not the matrices.
We compute both the EAIs for each of the four arrays (
per_date_eai_HiVj), from which the corresponding AAIs can be computed (per_date_aai_HiVj), and the "return period impacts".Then we can compute the "fully interpolated metrics basis",
per_date_eai,per_date_aai(return periods have a special treatment given they rely on an argument), and cache them using@lazy_property. Computation is done by interpolating first along the hazard dimension and then along the vulnerability one.Finally, we can have the
calc_<risk_metric>methods which take care of tidying the data in nice dataframes.Differences in interface class
InterpolatedRiskTrajectoryhandle the additional "time resolution" attribute, shipsper_period_<risk_metric>methods in addition to theper_dateones, where average values of the metric for each period (consecutive pairs of snapshots) are computed.PR Author Checklist
develop)PR Reviewer Checklist