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

Support for custom colormap in precipfield.py and plot_custom_precipitation_range.py example #433

Merged

Conversation

rutkovskii
Copy link
Contributor

@rutkovskii rutkovskii commented Sep 13, 2024

[MODIFY] Add support for custom colormap configuration in precipfield.py

This update allows user-defined ranges and colors for plots. It supports
intensity (tested) and depth (untested), but not probability. A private
function was added to validate the colormap provided by the user.

[ADD] Add plot_custom_precipitation_range.py example demonstrating how to
create a custom config and use it for plotting.

Note: As mentioned, it should work with depth, but I have not verified it.

#430

…d.py`

This update allows user-defined ranges and colors for plots. It supports intensity (tested) and depth (untested), but not probability.

[ADD] Add `plot_custom_precipitation_range.py` example demonstrating how to create a custom config and use it for plotting.
@dnerini
Copy link
Member

dnerini commented Sep 17, 2024

Hi there, thanks for the reminder. I'll try to have a close look today, I don't expect any major issue.

Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 21.73913% with 18 lines in your changes missing coverage. Please review.

Project coverage is 83.89%. Comparing base (ee60fa6) to head (a12df02).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pysteps/visualization/precipfields.py 21.73% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #433      +/-   ##
==========================================
- Coverage   84.00%   83.89%   -0.11%     
==========================================
  Files         160      160              
  Lines       12882    12900      +18     
==========================================
+ Hits        10821    10822       +1     
- Misses       2061     2078      +17     
Flag Coverage Δ
unit_tests 83.89% <21.73%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@dnerini dnerini left a comment

Choose a reason for hiding this comment

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

@rutkovskii thanks for your contribution! I very much appreciated the clean implementation and the effort in adding a clear example of this new feature, way to go!

Please just remove the final line from the example when you save the figure, and then we'll be ready to merge!

pysteps/visualization/precipfields.py Show resolved Hide resolved


###############################################################################
# Download the data if it is not available
Copy link
Member

Choose a reason for hiding this comment

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

We usually do not include the code for downloading the example data in the other examples, since the data are downloaded before running the example codes, but I'm OK with leaving this snippet ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I'll keep it as is. My thought process was that the data erequires a manual download, so providing a way for users to quickly see how the plotting works in case they do not have it loaded.
Is the data included in the installation of the library via pip?

Copy link
Member

Choose a reason for hiding this comment

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

no, the data are not part of the actual package, but we provides some tools to get them (as the functions you used), see https://pysteps.readthedocs.io/en/stable/user_guide/example_data.html

examples/plot_custom_precipitation_range.py Outdated Show resolved Hide resolved
@rutkovskii
Copy link
Contributor Author

@dnerini I made the change. You can merge as you are the authorized user.

@dnerini dnerini merged commit bdda005 into pySTEPS:master Sep 18, 2024
8 of 10 checks passed
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.

2 participants