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

fix hardcoded text elements in the plots of the forecast class #769

Merged
merged 8 commits into from
Aug 17, 2023

Conversation

ThomasRoosli
Copy link
Collaborator

@ThomasRoosli ThomasRoosli commented Aug 10, 2023

Changes proposed in this PR:

  • fix hardcoded text elements in the plots of the forecast class

This PR fixes #

PR Author Checklist

PR Reviewer Checklist

Copy link
Collaborator

@timschmi95 timschmi95 left a comment

Choose a reason for hiding this comment

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

Looks good to me. There are two variable names still containing wind (wind_map_file_name, wind_map_file_name_full) which could also be adjusted.

climada/engine/forecast.py Outdated Show resolved Hide resolved
climada/engine/forecast.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@timschmi95 timschmi95 left a comment

Choose a reason for hiding this comment

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

Looks good to me. I didn't realize the split was because of the linter. I guess the previous version would've been also good then (maybe better for some), although I personally still like the new version better.

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.

I find a lot of inconsistencies in the code of these plots. But since we want to overhaul the entire class and make it more useful until then without changing any of its "logic", I think it's fine.

Are you sure about the wordings, though? I find figure titles usually unnecessary. The default "explain text" states what I would use as a colorbar label, e.g. "Mean Wind Damage" or "Total Building Damage". There is no need to repeat this information in the title, imho.

CHANGELOG.md Outdated Show resolved Hide resolved
climada/engine/forecast.py Outdated Show resolved Hide resolved
save_fig=False, close_fig=True)
forecast.plot_exceedence_prob(run_datetime=dt.datetime(2017,12,31),
threshold=5000, save_fig=False, close_fig=True)

threshold=5000, explain_str='test text',
Copy link
Member

Choose a reason for hiding this comment

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

Since there is quite some fiddling with titles, it might make sense to assert if the correct figure title is set with something like

ax = forecast.plot_exceedence_prob(explain_str="Something from the title")
self.assertIn(ax.get_title(), "Something from the title")

@ThomasRoosli
Copy link
Collaborator Author

I find a lot of inconsistencies in the code of these plots. But since we want to overhaul the entire class and make it more useful until then without changing any of its "logic", I think it's fine.

Are you sure about the wordings, though? I find figure titles usually unnecessary. The default "explain text" states what I would use as a colorbar label, e.g. "Mean Wind Damage" or "Total Building Damage". There is no need to repeat this information in the title, imho.

I agree with waiting to improve the plots when we do the overhaul of the entire class.

About the need of titles: as there is a lot of forecast specific information in the plot titles (actually one of the features of the class), I find using the title to quickly spot the type of plot quite useful. But luckily you don't have to agree, because from now on you can assign an empty string to the "explain text" to have no repetition of the colorbar label.

@peanutfun
Copy link
Member

@ThomasRoosli True! 😁 Could you have a look at my suggestions and comment/commit/adapt them at your convenience? Then we are ready to merge!

Thomas Roosli and others added 3 commits August 16, 2023 17:38
rework text about Text in Forecast class plots

Co-authored-by: Lukas Riedel <[email protected]>
Add linebreaks

Co-authored-by: Lukas Riedel <[email protected]>
@ThomasRoosli
Copy link
Collaborator Author

@peanutfun I added the suggested functionality in the tests and additionally some more asserts and structure.
Further test upgrades can happen in the overhaul of the module. Can you have a look at it again?

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.

Looks very good now, thanks for improving the new tests! I'll see ich the pipeline succeeds and merge afterwards

@peanutfun peanutfun merged commit 015fdbf into develop Aug 17, 2023
4 checks passed
@emanuel-schmid emanuel-schmid deleted the feature/forecast_plot_improvement branch September 7, 2023 13:27
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.

3 participants