Separate Hazard xarray reader into its own module by peanutfun · Pull Request #1063 · CLIMADA-project/climada_python

Conversation

@peanutfun

Changes proposed in this PR:

  • Move code of Hazard.from_raster_xarray into a separate module. This avoids an excessively long and complicated single function.
  • Deprecate Hazard.from_raster_xarray_file. The module separation lets us handle files and datasets elegantly without a separate method.
  • Minimal adjustments to the tests. All should still work like before.

PR Author Checklist

PR Reviewer Checklist

* Make `Hazard.from_raster_xarray` handle files.
* Update tests
* Fix linter issues

@peanutfun peanutfun marked this pull request as ready for review

June 19, 2025 09:19

@peanutfun

emanuel-schmid

Choose a reason for hiding this comment

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

Great work! Much cleaner now. Many thanks.
I've pushed minor cosmetic changes to io.py and marked xarray functions that could also be private. I'm not sure whether they have a use outside of that module. But it doesn't matter much.

@peanutfun

@emanuel-schmid I marked all free functions of the module as private. Thanks for the review and cosmetic updates! Merging now...

2 participants

@peanutfun @emanuel-schmid