-
Notifications
You must be signed in to change notification settings - Fork 128
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
added assign_centroids for impact objects #602
Conversation
The code is quite readable. I think it can be merged after a more thorough look at the doc string (I pushed few suggestions and made few comments). Also, it'd be good to have a coupe of tests. |
@aleeciu I added a test for the imp.assign_centroids() method, and all tests are passing. Shall I covert it to a 'real' pull request? |
Thanks a lot! The time for refactoring centroids assignment is just right I think. 😁 |
@emanuel-schmid I think everything is resolved now. Do you want to have a last look over it before I merge it? |
climada/engine/impact.py
Outdated
#Assert that the imp crs is epsg:4326, as it is required by the u_coord methods | ||
if not u_coord.equal_crs(self.crs, 'EPSG:4326'): | ||
raise ValueError('Set Impact to lat/lon crs (EPSG:4326)!') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more question (sorry 😁) - which u_coord methods require epsg:4326?
And why can't they speak for themselves, i.e. raise an exception if the crs is wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this in there as afterwards I label the coordinate column 'latitude' and 'longitude', but you are right: as with exposures the functionalities also work with other CRS, it's just the column labels 'latitude'/'longitude' that are not correct then, but this shouldn't be a problem. I think we can savely remove this part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there is no real assignment anymore, the method name is kind of misleading.
My favorite would be closest_centroids
. But then, the same argument is also valid for the coordinates
methods assign_centroids_to_gdf
, assign_gridpoints
and assign_coordinates
. Consequently they should be renamed too. Therefore I propose a wimp compromise: assigned_centroids
as in "if there was an assignment the assigned centroids would be assigned like this:"
And CHANGELOG.md needs to be updated ... 😁
climada/engine/test/test_impact.py
Outdated
fake_aai_agg = np.sum(fake_eai_exp) | ||
imp = Impact.from_eih(exp, ENT.impact_funcs, HAZ, | ||
fake_at_event, fake_eai_exp, fake_aai_agg) | ||
imp_centr = imp.assign_centroids(HAZ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imp_centr = imp.assign_centroids(HAZ) | |
imp_centr = imp.assigned_centroids(HAZ) |
Adding a method The information about the closest centroid from a hazard of an impact object is already in the exposures at the moment of computation. I really begin to be confused about the purpose of this pull request. |
With regard to |
@timschmi95 : could you please clarify the use case of the methods |
@chahank The It could also be used by if someone is just interested in what hazard intensity led to which (modelled) impacts. Ofc if the imp is produced with ImpactCalc().impact() one could also use the exp.assign_centroids() method instead, but the impact.assign_centroids woud be more direct |
@emanuel-schmid I am also not sure about the proposed name |
… match_coordinates
Many thanks @timschmi95 |
Thanks @emanuel-schmid the new names are also fine with me! And the use of _build_exp() also makes the method shorter :) |
I still think that there should not be any method |
That being said, if you really think it is useful, please feel free to merge. |
Changes proposed in this PR:
This PR supports the calibration of impact functions based with damage data from impact objects
PR Author Checklist
develop
)PR Reviewer Checklist