Skip to content

contains hotfixes for plotting utilities #133

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

Merged
merged 6 commits into from
Jul 24, 2021

Conversation

wsavran
Copy link
Collaborator

@wsavran wsavran commented Jul 22, 2021

@pabloitu do you mind taking a look at this pr when you have a chance?

contains a few adjustments to the plotting utilites

  • draw region border correctly
  • properly scale axes for comparison test plots
  • allow chaining for consistency test plots

wsavran added 3 commits July 22, 2021 10:01
- fixed issue where border was drawn incorrectly
- supressed std out message if unable to obtain region_border
- axes can be chained for plot_consistency_test_result
- grab xticks from axes correly in plot_comparison_test
- properly adjust xlim in plot_comparison_test
@wsavran wsavran requested a review from pabloitu July 22, 2021 19:47
@codecov-commenter
Copy link

codecov-commenter commented Jul 22, 2021

Codecov Report

Merging #133 (dab5ef9) into master (4195021) will decrease coverage by 0.09%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #133      +/-   ##
==========================================
- Coverage   57.06%   56.97%   -0.10%     
==========================================
  Files          19       19              
  Lines        3142     3147       +5     
  Branches      454      455       +1     
==========================================
  Hits         1793     1793              
- Misses       1238     1243       +5     
  Partials      111      111              
Impacted Files Coverage Δ
csep/core/regions.py 53.65% <0.00%> (-0.84%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4195021...dab5ef9. Read the comment docs.

Copy link
Collaborator

@pabloitu pabloitu left a comment

Choose a reason for hiding this comment

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

Thanks for the check of the functions! I believe only plot_comparison_test() : ax.set_xlim(-0.5, len(results_t) - 0.5) is needed for mergning

desc.append(poly_max[2])
desc.append(poly_max[3])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change loooks good, but made me realize a detail, that the polygons defined in the CSEP built-in italy region is not 100% correct
image
See the serrated edges, which does not happens if the Catalog region is assigned to the one that is imported from a forecast like this:
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think this issue is from the way i am pulling out the outermost region. thanks for spotting this, i'll come up with a solution so it works for both cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i pushed a hotfix for this issue. i checked it against the built in region. everything looks to work properly. if you have this pr cloned do you mind checking as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Checked! Looks perfect

ax.set_ylim([ylims[0], ylims[1]])
ax.set_xlim([ax.get_xlim()[0] + 0.5, ax.get_xlim()[1] - 0.5])
ax.set_ylim([ylim[0], ylim[1]])
ax.set_xlim([ax.get_xlim()[0] - 0.5, ax.get_xlim()[1] + 0.5])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This ax.set_xlim() change gives an extra edge border that I'm not sure is needed. This gives
image

versus this, which was in the previous xlim definition
image

But this failed for low number of Models in the t-test. I'd suggest to leave it better like:

ax.set_xlim([-0.5, len(results_t) - 0.5])

It appears to work well with any number of forecasts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that doesn't seem to work with only two models, it only displays one
image
if i use

ax.set_xlim([-0.5, len(results_t) + 0.5]) 

it seems to work ok. am i missing something here?
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

checking....

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i really like the way these plots look!

Copy link
Collaborator

@pabloitu pabloitu Jul 22, 2021

Choose a reason for hiding this comment

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

Weird! Using ax.set_xlim([-0.5, len(results_t) - 0.5]) from the cloned pycsep_esrl repo I got this plot correctly:
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think i got it. i just pushed a new commit with that fix.

wsavran added 2 commits July 22, 2021 15:55
* try to determine which points to plot based on latitude values
* update xlim in plot_comparison_test
Copy link
Collaborator

@pabloitu pabloitu left a comment

Choose a reason for hiding this comment

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

Will be back tomorrow early. GL

@@ -1342,7 +1342,7 @@ def plot_comparison_test(results_t, results_w=None, axes=None, plot_args=None):
xTickPos = ax.get_xticks()
ax.yaxis.set_major_locator(matplotlib.ticker.MaxNLocator(integer=True))
ax.set_ylim([ylim[0], ylim[1]])
ax.set_xlim([ax.get_xlim()[0] - 0.5, ax.get_xlim()[1] + 0.5])
ax.set_xlim([0.5, len(results_t) - 0.5])
Copy link
Collaborator

Choose a reason for hiding this comment

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

nope, this still hides me a forecast. It works for me with [ - 0.5, len(results_t) - 0.5]. Weiirdd.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

missed the '-'. catch you tomorrow! gn!

* update xlim in plot_comparison_test
@wsavran wsavran merged commit fe858e5 into SCECcode:master Jul 24, 2021
@wsavran wsavran deleted the whs_plots_hotfix branch July 24, 2021 17:39
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