Skip to content
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

Feature/change impact total value #702

Merged
merged 19 commits into from
May 15, 2023
Merged

Conversation

chahank
Copy link
Member

@chahank chahank commented Apr 19, 2023

Changes proposed in this PR:

  • Proposal to update the affected value of the exposures to only those centroids with intensity above 0 (or threshold)

This PR would make the impact computation slower by roughly 10%. Do we want that?

The code can be made prettier.

This PR fixes #

PR Author Checklist

PR Reviewer Checklist

@chahank chahank marked this pull request as draft April 19, 2023 20:02
@chahank chahank requested a review from peanutfun April 19, 2023 20:02
@chahank
Copy link
Member Author

chahank commented Apr 20, 2023

@peanutfun : an alternative could be to have two methods: one that just computes the total sum of the exposures in the vicinity of a hazard centroid (so as it is currently) and which is used in the impact computation. Another method that would only be for the exposures object and which does what the here proposed method does (compute the value of the exposures affected by a given value of intensity).

@peanutfun
Copy link
Member

I like the new thing much better, however, the computation overhead could be a problem. Is Impact.tot_value really something useful? I would suggest keeping the current version of the method for backward-compatiblity, and deprecating Impact.tot_value. Users should instead use the new affected_total_value with a threshold of their choice and retrieve it from the exposure when they actually need it.

@chahank
Copy link
Member Author

chahank commented May 4, 2023

I like the new thing much better, however, the computation overhead could be a problem. Is Impact.tot_value really something useful? I would suggest keeping the current version of the method for backward-compatiblity, and deprecating Impact.tot_value. Users should instead use the new affected_total_value with a threshold of their choice and retrieve it from the exposure when they actually need it.

Good idea. Before doing so, it is probably to be discussed once with users from the insurance sector (which are at the origin of this feature). Thanks!

@chahank
Copy link
Member Author

chahank commented May 9, 2023

Ok, my suggestion is the following:

We keep the total value as it is currently implemented in the impact computation. We add a new method which does compute the total people subject to a given threshold.

Thus, we do not slow down the impact computation and keep backwards compatibility, and give the possibility to users to obtain the more useful value of affected people directly from the hazard and exposures. Potentially we could also simply ditch completely the tot_value from the impact computation in order to simplify the code base.

@peanutfun
Copy link
Member

@chahank I approve!

Potentially we could also simply ditch completely the tot_value from the impact computation in order to simplify the code base.

When? Do you want to create an issue or deprecate the value immediately? With the latter approach, I think we are more likely to get some feedback on that decision 😉

@chahank
Copy link
Member Author

chahank commented May 9, 2023

I would go for the more direct approach -> deprecate.

peanutfun and others added 3 commits May 10, 2023 17:27
* Replace attribute with getter/setter and declare private attribute.
* Adjust writers accordningly
climada/engine/impact.py Outdated Show resolved Hide resolved
climada/engine/impact.py Outdated Show resolved Hide resolved
@peanutfun peanutfun marked this pull request as ready for review May 12, 2023 12:03
CHANGELOG.md Outdated
@@ -30,13 +30,16 @@ Removed:
- Added test for non-default impact function id in the `lines_polys_handler` [#676](https://github.com/CLIMADA-project/climada_python/pull/676)
- The sigmoid and step impact functions now require the user to define the hazard type. [#675](https://github.com/CLIMADA-project/climada_python/pull/675)
- Improved error messages produced by `ImpactCalc.impact()` in case hazard type is not found in exposures/impf_set [#691](https://github.com/CLIMADA-project/climada_python/pull/691)
- `Exposures.affected_total_value` now takes a hazard intensity threshold as argument. [#702](https://github.com/CLIMADA-project/climada_python/pull/702)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `Exposures.affected_total_value` now takes a hazard intensity threshold as argument. [#702](https://github.com/CLIMADA-project/climada_python/pull/702)
- `Exposures.affected_total_value` now takes a hazard intensity threshold as argument. [#702](https://github.com/CLIMADA-project/climada_python/pull/702)
- Bugfix for the `Hazard.select` method: any iterable are now accepted for `event_id` and `event_names` [#719](https://github.com/CLIMADA-project/climada_python/pull/719)

@chahank
Copy link
Member Author

chahank commented May 12, 2023

I sneaked-in the missing changelog entry from the pull request #719. Hope this is fine for you @peanutfun

@chahank
Copy link
Member Author

chahank commented May 15, 2023

@peanutfun ready to merge?

@peanutfun
Copy link
Member

I sneaked-in the missing changelog entry from the pull request #719. Hope this is fine for you @peanutfun

I personally much prefer using a separate PR for that, but let's not overcomplicate things. You'll have to add this yourself, I cannot commit your suggestion because it is outdated.

@peanutfun ready to merge?

Yes!

@chahank chahank merged commit 7a646c8 into develop May 15, 2023
@chahank chahank mentioned this pull request May 24, 2023
13 tasks
@emanuel-schmid emanuel-schmid deleted the feature/change_impact_total_value branch May 25, 2023 08:40
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.

3 participants