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

Plot comparison test failing #214

Open
wsavran opened this issue Apr 4, 2023 · 4 comments
Open

Plot comparison test failing #214

wsavran opened this issue Apr 4, 2023 · 4 comments
Assignees

Comments

@wsavran
Copy link
Collaborator

wsavran commented Apr 4, 2023

On line 1486 in csep/utils/plots.py the plot_comparison_test is failing due to an incompatible change in matplotlib. The fix currently exists in plot_poisson_consistency_test and should be duplicated in plot_comparison_test.

@fabiolsilva fabiolsilva self-assigned this Apr 14, 2023
@pabloitu
Copy link
Collaborator

can't seem to reproduce this bug :C. I think the comparison plot was not affected by the matplotlib change. The change forced errorbars to be defined only by positive values (e.g. plt.errorbar(origin, xerr=[1, 2]) giving a (-1, +2) error margin), meaning the origin point now must be inside the error range. That was the problem with consistency tests (with obs outside sim range), but t-tests was already having the origin inside by default

created a unit test for comparison tests in, #222 that randomizes the values to see if at some point it breaks. so far it works alright

@fabiolsilva fabiolsilva assigned pabloitu and unassigned fabiolsilva Jul 25, 2023
@pabloitu pabloitu reopened this Nov 15, 2023
@pabloitu
Copy link
Collaborator

should we close this?

@wsavran
Copy link
Collaborator Author

wsavran commented Nov 20, 2023

UPDATE: Open pull request to address this. @pabloitu @fabiolsilva let me know what you think.

im reopening this because I'm seeing this is still an issue.

see example script to reproduce

import csep
from csep.core import poisson_evaluations as poisson
from csep.utils import datasets, time_utils, plots

# Needed to show plots from the terminal
import matplotlib.pyplot as plt

start_date = time_utils.strptime_to_utc_datetime('2006-11-12 00:00:00.0')
end_date = time_utils.strptime_to_utc_datetime('2011-11-12 00:00:00.0')

forecast = csep.load_gridded_forecast(datasets.helmstetter_aftershock_fname,
                                      start_date=start_date,
                                      end_date=end_date,
                                      name='helmstetter_aftershock')

print("Querying comcat catalog")
catalog = csep.query_comcat(forecast.start_time, forecast.end_time, min_magnitude=forecast.min_magnitude)
print(catalog)

catalog = catalog.filter_spatial(forecast.region)
print(catalog)

t_test = poisson.paired_t_test(forecast, forecast, catalog)

ax = plots.plot_comparison_test([t_test], plot_args={})

This script is failing with the following error.

/Users/wsavran/Working/github/pycsep/csep/utils/plots.py:1761: UserWarning: set_ticklabels() should only be used with a fixed number of ticks, i.e. after set_ticks() or using a FixedLocator.
  ax.set_xticklabels([res.sim_name[0] for res in results_t],
Traceback (most recent call last):
  File "/Users/wsavran/Desktop/test.py", line 25, in <module>
    ax = plots.plot_comparison_test([t_test], plot_args={})
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/wsavran/Working/github/pycsep/csep/utils/plots.py", line 1773, in plot_comparison_test
    width=(xTickPos[1] - xTickPos[0]), color=['gray', 'w'], alpha=0.2)
           ~~~~~~~~^^^
IndexError: index 1 is out of bounds for axis 0 with size 1

some notes:

  1. this issue only happens when len(results_t) == 1
  2. @pabloitu you're right this wasn't related to matplotlib changes, but that we're shading the regions and not checking if there is more than 2 forecasts when doing this.

wsavran pushed a commit to wsavran/pycsep that referenced this issue Nov 20, 2023
@wsavran wsavran reopened this Nov 20, 2023
@wsavran
Copy link
Collaborator Author

wsavran commented Nov 22, 2023

See PR #247 to address this issue

fabiolsilva pushed a commit that referenced this issue Nov 29, 2023
fixes issue #214

Co-authored-by: William Savran <wsavran@unr.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

3 participants