Skip to content

Conversation

@spjuhel
Copy link
Collaborator

@spjuhel spjuhel commented Dec 17, 2025

As the Risk trajectory PR is too substantial, this is a second split.

This PR implements the concept of interpolation strategies to journey along the Risk Cube.

It:

  • defines functions for linear and exponential interpolation for both sparse matrices and numpy arrays of metrics
  • Abstract class for interpolation strategies, which dictate how to interpolate along the different dimensions of the cube.
  • Two concrete classes, one with all linear and one with exponential interpolation for exposure.

A strategy is a triplet of callable:

  • exposure_interp: "how do I generate a range of given number of dates impact matrices, between present date and future date, accounting for changing exposure but constant hazard and vulnerability?"
  • hazard_interp: "how do I interpolate between two arrays of risk metrics, the first one corresponding to present hazard and evolving exposure, and the second one to future hazard and evolving exposure, to incorporate the evolution due to the changing hazard"
  • vulnerability_interp: same as hazard_interp but for vulnerability.

PR Author Checklist

PR Reviewer Checklist

@spjuhel
Copy link
Collaborator Author

spjuhel commented Dec 17, 2025

One consideration could be to put this in utils/interpolation.py

@chahank what do you think?

@chahank
Copy link
Member

chahank commented Jan 6, 2026

One consideration could be to put this in utils/interpolation.py

@chahank what do you think?

I think this is a good idea! I would then if it is not too much work rename linear_interp_imp_mat to something like linear_interp_matrix_elemwise or linear_interp_sparse_mat. Although, maybe just the general functions, not the classes maybe?

@chahank
Copy link
Member

chahank commented Jan 6, 2026

I think the code in itself is fine, but it is very very hard to understand what the class and methods are actually doing. I think this is because the word interpolation is used for many different type of operations.

In my understanding, the "array" interpolation is supposed to represent Bayesian mixing. The "mat" inteprolation on the other hand is an interpolation between two known points.

In addition, it is quite hard to comprehend what the class InteprolationStrategies is doing, as it seems to treat the exposures, hazard and vulnerabulity dimensions differently. For exposures, it does inteprolation between points, whereas for hazard and vulnerablity is does mixing. Is this correct?

@chahank
Copy link
Member

chahank commented Jan 6, 2026

And thanks for splitting into separate PRs! That helps a ton.

@spjuhel
Copy link
Collaborator Author

spjuhel commented Feb 9, 2026

@chahank I think I addressed all comments, can you do a last check and give the green light to merge?

@CLIMADA-project CLIMADA-project deleted a comment from spjuhel Feb 10, 2026
@chahank
Copy link
Member

chahank commented Feb 10, 2026

I still find the use of the word interpolation for many distinct operations confusing, but it is time to merge as the code does what it should do.

@chahank chahank self-requested a review February 10, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants