Skip to content

Conversation

@tovogt
Copy link
Collaborator

@tovogt tovogt commented Jan 16, 2024

Changes proposed in this PR:

  • Implement a new unit test for TropCyclone to cover the case where a TC track crosses the antimeridian. Note that this test fails in the current develop branch!
  • Fix the code of TropCyclone to make the new test pass. This mostly affects the helper function get_close_centroids and surrounding code. Note that this function is also used in petals, and there is a compatibility PR here: tc_rainfield: tests for tracks crossing the antimeridian climada_petals#105
  • Change variable names in trop_cyclone.py to make binary numpy arrays start with mask_ and arrays of indices with idx_. I found the previous nomenclature confusing while working on this fix.
  • Implement a new unit test for util.coordinates.latlon_bounds to cover the case where the specified buffer is very large so that the bounds cover more than the full longitudinal range [-180, 180].

This PR does NOT fix #831!

PR Author Checklist

PR Reviewer Checklist

Copy link
Collaborator Author

@tovogt tovogt left a comment

Choose a reason for hiding this comment

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

See below for comments that explain some of the changes directly in the code.

@tovogt tovogt changed the title Fix TropCyclone for storms crossing antimeridian trop_cyclone: fix for tracks crossing antimeridian Jan 19, 2024
@peanutfun
Copy link
Member

GitHub tests pass, but Jenkins tests fail with

climada.hazard.test.test_trop_cyclone.TestReader.test_cross_antimeridian

ValueError: The following given IDs are not in IBTrACS: 2020346S13168.

@tovogt
Copy link
Collaborator Author

tovogt commented Jan 31, 2024

GitHub tests pass, but Jenkins tests fail

Thanks for checking! Here is the reason, from the Jenkins log output:

2024-01-31 10:51:41,777 - climada.hazard.tc_tracks - WARNING - The cached IBTrACS data set dates from 2020-08-08 03:51:21 (older than 180 days). Very likely, a more recent version is available. Consider manually removing the file /var/lib/jenkins/climada/data/IBTrACS.ALL.v04r00.nc and re-running this function, which will download the most recent version of the IBTrACS data set from the official URL.

Hence, the IBTrACS file in Jenkins is really old (2020!), and needs an update.

@emanuel-schmid
Copy link
Collaborator

The file is updated, and hence the test climada_branches passes, but the petals_compatibility test still fails with
TypeError: get_close_centroids() got multiple values for argument 'metric'

@tovogt
Copy link
Collaborator Author

tovogt commented Jan 31, 2024

The file is updated, and hence the test climada_branches passes, but the petals_compatibility test still fails with TypeError: get_close_centroids() got multiple values for argument 'metric'

Good point, that means that the PR CLIMADA-project/climada_petals#105 is actually a compatibility PR and needs to be merged at the same time with this one.

Copy link
Member

@peanutfun peanutfun left a comment

Choose a reason for hiding this comment

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

Great to see that this now works, thanks for adding the necessary unit tests! 🙌

I am a bit confused about functions returning both centroids and masks for centroids. I think they should return only one.

I agree with most of the naming changes, and will simply resolve the respective conversations 😇

@tovogt
Copy link
Collaborator Author

tovogt commented Feb 14, 2024

Thanks for the review! Yes, understanding masks can be challenging in this module. For performance reasons, we have a mask for each track position, but at some point we also apply a single mask to the centroids to filter out centroids that are not affected by any of the track positions. But we need the masks to stick around in order to inflate the result (that is only defined on the masked centroids) to the original set of centroids in the end.

@peanutfun
Copy link
Member

@tovogt The double-backticks are very annoying and easy to miss 😅

From my point of view, this is ready! Can I merge?

@tovogt
Copy link
Collaborator Author

tovogt commented Feb 15, 2024

Wait a second, CHANGELOG...

And let's also merge CLIMADA-project/climada_petals#105 soonish due to compatibility.

@tovogt
Copy link
Collaborator Author

tovogt commented Feb 15, 2024

Okay, ready to be merged!

@tovogt
Copy link
Collaborator Author

tovogt commented Feb 15, 2024

@emanuel-schmid Thanks for fixing the CHANGELOG! I should have merged develop before adding the new points...

@peanutfun peanutfun merged commit bd470ed into develop Feb 15, 2024
@peanutfun peanutfun deleted the feature/tc_antimeridian_close_centr branch February 15, 2024 10:50
@peanutfun
Copy link
Member

@tovogt @emanuel-schmid Nice work, thank you!

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.

4 participants