Risk Trajectory Split 4 : Non-interpolated (Static) trajectories#1200
Risk Trajectory Split 4 : Non-interpolated (Static) trajectories#1200
Conversation
| def reusable_intensity_mat(max_intensity=HAZARD_MAX_INTENSITY): | ||
| # Choosen such that: | ||
| # - 1st event has 0 intensity | ||
| # - 2nd event has max intensity in first exposure point (defaulting to 0 value) | ||
| # - 3rd event has 1/2* of max intensity in second centroid | ||
| # - 4th event has 1/4* of max intensity everywhere | ||
| # *: So that you can double intensity of the hazard and expect double impacts | ||
| return csr_matrix( |
There was a problem hiding this comment.
What would happen with negative intensities? Probably easy to test using a negative intensity factor. Although then the reusable impact function set would need adjustments.
There was a problem hiding this comment.
I think that is beyond the scope of this PR.
There was a problem hiding this comment.
hmmm when could this be done? Because negative intensities are valid in CLIMADA, and it would be quite problematic to break this without good reason.
There was a problem hiding this comment.
OK, sorry I got confused actually, my initial comment on "this is beyond this PR" applies.
This PR has absolutely no impact on how negative intensities are handled by CLIMADA, it will work the same as before, we did not modify anything related to impact computation here, everything is just a wrapper.
I do have to check if interpolation cause problems with negative value (but that's split 5 not this one).
What also might change something is the option appraisal refactoring (next big project in line) which does change the measure module, and hopefully fixes the problem mentioned by Chris in #1257.
As the Risk trajectory PR is too substantial, this is a fourth split.
This PR builds on PRs #1197 and #1199, introduces
RiskTrajectory, the abstract basis for trajectory objects, and the concrete classStaticRiskTrajectorywhich aims at facilitating the computation of risk metrics over multipleSnapshotobjects.The code is split between a high level interface
StaticRiskTrajectoryand a low level computing classCalcRiskMetricsPoint.RiskTrajectoryThe rationale behind this class is to hold the common code for any type of risk trajectory:
CalcRiskMetricPointThe rationale behind this class is to handle the computation and "data formatting" of different risk metrics over a collection of
Snapshot, following anImpactComputationStrategy(see PR #1199). In this case, without any interpolation, thus it is essentially a wrapper for multiple calls toImpactCalcor equivalent inImpactComputationStrategy.The class contains:
@lazy_propertyproperties, dictating how the foundational elements for risk metric should be computed (see below)calc_<risk_metric>methods (which are the ones called by theStaticRiskTrajectoryobject): these make use of the above and put them in nice and tidy dataframes.@lazy_propertyexplainedWe want to avoid recomputing when unnecessary, thus we have computed metrics and "impact data" as
@lazy_property, which cache the results of the computation. For instance, callingstatic_traj.per_date_aaithe first time computes the different requiredImpactobjects, stores them, and then the.aai_aggfor eachImpactand also store them.A subsequent call to
.per_date_aaireturn the previously stored value.In addition, a subsequent call to
.per_date_eaiwill reuse computedImpactobjects.The
@lazy_propertydecorator implements this memoization flow: it returns the cached_metricattribute if available. If not, it computes the value, stores it in_metric, and returns the result.Attributes that would change metric results (such as the computation strategy or the return periods to compute) make use of
@propertyto reset the cached data when their value is changed by calling_reset_impact_data.StaticRiskTrajectoryThis class is the interface with the user. It receives the list of snapshot to compute metrics for, and gives access to computed risk metrics and plots. It also handles the computation of net present values if a risk discount rate is provided.
It also uses a memoization flow for the "final" results.
PR Author Checklist
develop)PR Reviewer Checklist