Skip to content

Implement a new tropical cyclone rain model#85

Merged
tovogt merged 45 commits intodevelopfrom
feature/tc_rain
Dec 12, 2023
Merged

Implement a new tropical cyclone rain model#85
tovogt merged 45 commits intodevelopfrom
feature/tc_rain

Conversation

@tovogt
Copy link
Copy Markdown
Collaborator

@tovogt tovogt commented Jul 5, 2023

Changes proposed in this PR:

  • This implements a new TC rainfall model (called TCR) as part of the climada_petals.hazard.tc_rainfield module.
  • The existing implementation (of R-CLIPER) is refactored a bit, with improved documentation, and it is also covered by the tutorial notebook.
  • Apart from the tutorial notebook (~1 MB), this adds three further binary files to the repository:
    1. climada_petals/data/tc_rainfield/tcrain_examples.nc (80 KB): Two TC tracks with additional variables extracted from ERA5. The data is used in the tutorial notebook as well as in the unit tests.
    2. climada_petals/data/tc_rainfield/c_drag_500.tif (~1 MB): A global gridded data set of the surface drag coefficient for gradient winds (from ERA5). The resolution is sufficient for almost all applications of the model, and it's still very small.
    3. climada_petals/data/tc_rainfield/topography_land_360as.tif (~3 MB): A global gridded data set of surface elevation at 0.1 degree resolution (derived from SRTM). The resolution is fine for applications of TCR, but is too low for many other applications, such as surge or flood simulations. It's public domain and comparably small, so I think we can distribute it with CLIMADA.

As of July 6, this PR is ready to be reviewed. I'm looking forward to your feedback!

PR Author Checklist

PR Reviewer Checklist

@tovogt tovogt marked this pull request as ready for review July 6, 2023 13:12
@tovogt
Copy link
Copy Markdown
Collaborator Author

tovogt commented Jul 6, 2023

Hey everyone, the new rain module is ready for review!

Please note that running the notebook and the tests will require data sets that are included in the ./climada_petals/data/tc_rainfield/ directory of the repository. If you struggle with error messages about missing data files, you might need to copy those files to the CLIMADA data and config directory on your computer.

Furthermore, the implementation is based on a proprietary MATLAB implementation. If you would like to have a look at the original code, please drop me a message, and I can send you the MATLAB source code via mail.

The implementation of the R-CLIPER model currently does not allow modifications, so that
`model_kwargs` is ignored with `model="R-CLIPER"`. While the TCR model can be configured in
several ways, it is usually safe to go with the default settings. Here is the complete list
of `model_kwargs` and their meaning with `model="TCR"` (in alphabetical order):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd expect the explanation of what model_kwargs is about in the function's parameters description just below, under model_kwargs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I moved the description accordingly.

Path to a GeoTIFF file containing digital elevation model data (in m). If not
specified, a topography at 0.1 degree resolution provided with CLIMADA is used.
Default: None
matlab_ref_mode : bool, optional
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we need this. If you are sure it's a bug, it's better if it's gone, no? I'd rather add in the docstring that this is the original implementation, with a bug fix, and explain what the bug fix is.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree that bugs should just be fixed if we are sure that they are bugs. I updated the description of the parameter.

Background: When I originally implemented this, I found quite a few strange "issues" in the MATLAB code. And it took some time to write them down and get feedback from the original authors about these "issues". I didn't want to remove the issues unless the original authors definitely confirm that they are unintended ("bugs"). When I wrote this docstring I still didn't have feedback from the authors. Today, the situation is different: I know that some of the issues really were bugs. Those bugs are now fixed in my implementation and the original authors also decided to fix them in their implementation. But some of the "issues" were actually deliberate decisions by the original authors that I, personally, don't like (for example, using a parameter value that is not documented anywhere in the literature, not even in their own papers), and, at the same time, only make a comparably small difference. For testing purposes, I still think that it's useful to be able to replicate the behavior of the reference implementation. That's why I keep this parameter, but make clear what it actually does.

@aleeciu
Copy link
Copy Markdown
Collaborator

aleeciu commented Sep 29, 2023

Thanks @tovogt , I screened through the code and ran the tutorial. I cannot check it thoroughly but I wanted to provide a user type of feedback.

Code: It looks great, I just had a couple of documentation-related comments.

Tutorial: I could run it but I had to specifiy the paths of the required additional files (c_drag_500, topography_land_360 and tcrain_examples) via the model_kwargs arguments as my machine was looking for data under the 'Users/user_name/climada/...' folder instead of the CLIMADA project's folder.

I am not completely sure, but my understanding is that 'Users/user_name/climada/...' is where these data are supposed to be by default? Anyway, beside that, it ran flawlessly and the text is also very clear with a good balance of explanation and links for further knowledge.

A couple of more points :

  • What is the origin of topo data? would be great to know (haven't seen that, but perhaps is there)

  • It seems this new model's results are waaay different than R-CLIPER, should we just kill R-CLIPER for good or we still want to keep both?

  • My understanding is that this code is not applicable to the Knutson-scaled future TCs, right? But what about scaling the generated rainfields with knutson's rain rate scaling factors? would that be sensible ?

@tovogt
Copy link
Copy Markdown
Collaborator Author

tovogt commented Oct 10, 2023

Thanks for your feedback!

  • Well spotted, I forgot to add the data files to the REPO_DATA in ./climada_petals/__init__.py. This should be fixed now and the files will be automatically copied over to the right locations during import.
  • The topography data is the one from the MATLAB reference implementation. which is just SRTM upscaled to 0.1 degree resolution. The advantage of this data set is that it is extremely small (~3 MB) so that it can be included in the CLIMADA repository. Since SRTM is public domain, there shouldn't be a licensing issue.
  • I would keep R-CLIPER since it's really very simple code (not hard to maintain) and nice for future reference.
  • I haven't worked with the Knutson scaling that is currently implemented in CLIMADA, so I cannot really comment on that.

EDIT: I was finally able to reproduce the topography file from SRTM using gdalwarp and the "average" interpolation option. This is now also mentioned in several docstrings:

DEF_ELEVATION_TIF = u_const.SYSTEM_DIR / "topography_land_360as.tif"
"""Topography (land surface elevation, 0 over oceans) raster data at 0.1 degree resolution
SRTM data upscaled to 0.1 degree resolution using the "average" method of gdalwarp.
"""

@aleeciu
Copy link
Copy Markdown
Collaborator

aleeciu commented Oct 10, 2023

Thanks for your feedback!

  • Well spotted, I forgot to add the data files to the REPO_DATA in ./climada_petals/__init__.py. This should be fixed now and the files will be automatically copied over to the right locations during import.
  • The topography data is the one from the MATLAB reference implementation. which is just SRTM upscaled to 0.1 degree resolution. The advantage of this data set is that it is extremely small (~3 MB) so that it can be included in the CLIMADA repository. Since SRTM is public domain, there shouldn't be a licensing issue.
  • I would keep R-CLIPER since it's really very simple code (not hard to maintain) and nice for future reference.
  • I haven't worked with the Knutson scaling that is currently implemented in CLIMADA, so I cannot really comment on that.

EDIT: I was finally able to reproduce the topography file from SRTM using gdalwarp and the "average" interpolation option. This is now also mentioned in several docstrings:

DEF_ELEVATION_TIF = u_const.SYSTEM_DIR / "topography_land_360as.tif"
"""Topography (land surface elevation, 0 over oceans) raster data at 0.1 degree resolution
SRTM data upscaled to 0.1 degree resolution using the "average" method of gdalwarp.
"""

Super ! thanks for addressing these points and especially for figuring out where the elevation data come from. All good for me regarding this PR.

@emanuel-schmid
Copy link
Copy Markdown
Contributor

I'm a wee bit uneasy about the data files being part of the repository. Alternatively we could get them from the data-api, maybe?

@tovogt
Copy link
Copy Markdown
Collaborator Author

tovogt commented Nov 8, 2023

Yes, sounds great! Please go ahead and copy the files to the data-api and tell me how I can access them from within the code, or just push your proposed changes.

@tovogt tovogt merged commit 209cc23 into develop Dec 12, 2023
@emanuel-schmid emanuel-schmid deleted the feature/tc_rain branch December 13, 2023 13:25
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