Skip to content

Conversation

@pabloitu
Copy link
Collaborator

@pabloitu pabloitu commented Dec 27, 2025

pyCSEP Pull Request Checklist

Please check out the contributing guidelines for some tips
on making pull requests to pyCSEP.

Fixes issue #(please fill in or delete if not needed).

Type of change:

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (this pull request adds no new code)
  • Unpublished science feature (This may require a science review)
  • This change requires a documentation update

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

pabloitu and others added 30 commits April 13, 2025 23:01
 - Harmonized the parameters for all plotting functions. Removed the `plot_args` argument from all functions. Now, default parameters, such as `title`, `figsize` and many other repeating parameters are now found in a global dictionary `DEFAULT_PLOT_ARGS`. All plotting functions now default to these parameters and update a copy of it with **kwargs, thus having control to customize plots. Relevant parameters to the function are left in the function signature.
 - Added type hints for all signatures.
 - Removed functions `plot_cumulative_events_versus_time_dev`, `plot_ecdf`, `plot_magnitude_histogram_dev`.
 - Refactored catalog evaluation plot functions `plot_number_test`, `plot_magnitude_test`, `plot_spatial_test`, `plot_likelihood_test` into a generic `plot_distribution_test` (Should it be renamed plot_consistency_test?). Automatic annotations for each type test are done if required, or when called directly from EvaluationResult subclasses.
 - The function `plot_poisson_consistency_test` was collapsed onto `plot_consistency_test`, which also included the negative binomial model.
 - Reworked `plot_magnitude_vs_time`: removed some old functionality and give the possibility to scale the size of each event by its magnitude. Added datetime formatter/locator
 - Reworked`plot_cumulative_events_versus_time`. Now it has the option to plot with the real datetimes, or hours/days after a given mainshock.
 - Now plot_magnitude_histogram plots in log scale.
 - plot_basemap now allows cacheing of downloaded data
 - Created or refactored from existing functions multiple helper functions to ease unit testing and code readability: `_get_basemap`,`_autosize_scatter`, `_size_map`, `_autoscale_histogram`, `_annotate_distribution_plot`, `_calculate_spatial_extent`, `_create_geo_axes`, `_calculate_marker_size`, `_add_gridlines`, `_define_colormap_and_alpha`, `_add_colorbar`, _process_stat_distribution`. These still needs some review, type hinting and further refactoring if necessary.
 tests: Completed test coverage of almost all plots.py functions. Added test artifacts for catalog based evaluations (catalogs, forecasts, test results).
…he same projection of the cartopy GeoAxes.

ft: Added cache handler for plot_basemap. Uses the cache option from cartopy, but removes the cache if a different basemap source is selected (otherwise it would get stuck with the first cached map).
tests: added .tif basemap plotting to existing unit tests
build: added rasterio as requirement
…ent into the EvaluationResult, as part of the test_distribution attribute: ('negbinom', mean, variance). plot_consistency_test() now does not accept variance as attribute, but it is rather obtained when processing the negative binomial distribution.

tests: unittests of consistency test now do not accept variance argument, and negative_binomial mocks contain the second variance parameter as part of the test_distribution
…t is not necessary to set it again when plotting. plot_comparison_test() includes a default legend that explains the symbology therein.
…em compatible with sphinx docs. Reordered the index of the API reference docs for plotting functions. Also added EvaluationResult and CartesianGrid2D.get_cartesian, which are referenced by the plot docs. Added cartopy for intersphinx_mapping

refac: Renamed plot_spatial_dataset to plot_gridded_dataset (since catalogs are also a spatial datasets)
…of plot_args. Kept the `plot_args` for legacy compatibility.

docs: Adapted tutorials to the new plot refactoring. Added catalog_plot to Catalog Operations tutorial.
ft: Added higher resolutions for basemap autoscale functions, in case extent is lower.
…ctions that would otherwise be broke with proposed changes. Deprecation strategy were issued for distinct cases:

 - Functions to be removed (plot_cumulative_events_versus_time_dev, plot_histogram, plot_ecdf, plot_magnitude_histogram_dev, add_labels_for_publication) fallback to legacy code and issue warning of future removal.
 - Abstracted functions ( [plot_number_test, plot_spatial_test, plot_magnitude_test, plot_likelihood_test] >> plot_test_distribution ;  plot_poisson_consistency_test >> plot_consistency test ) also fallback to legacy code and issue deprecation warning hinting the new function and docs.
 - Refactored functions with strong API breaks (plot_cumulative_events_versus_time, plot_basemap, plot_consistency_test (when NB-distributed)) adapts to new call with known cases OR fallsback to legacy code.
  - Refactored functions with minor API breaks (plot_comparison_test, plot_concentration_ROC_diagram, plot_ROC_diagram, plot_Molchan_diagram) only adapts to new code with known cases without fallback to legacy.
  - Renamed function (plot_spatial_dataset >> plot_gridded_dataset) just wraps to correct function.

refac: renamed plot_distribution_test to plot_test_distribution.  Added to all catalog-based-test's names the prefix "Catalog" for consistency.
ft: Added 'reset_times' to plot_magnitude_versus_time for backwards compat.
tests: added unit tests for plot_magnitude_versus_time includint reset_times arg.
…rgs is passed as arguments. Backtracked on plot_spatial_dataset, which now fallbacks to legacy call + deprecwarning.
…ing tutorial links and expanded with m_vs_t plot. Added reference links to multiple tutorials. Changed sphinx confx to not display full function signature in API docs. Added comparative tests/plots to gridded_forecast_+tutorial

refac: shifted some function args ordering
ft: Comparative plots now handle being passed only one forecast.
docs: Added "plot composition" section to  Plotting tutorial. Added plot_magnitude_vs_time and plot_magnitude_histogram examples to Catalog-forecast tutorial. Added reflinks to tutorial headers. Added load_evaluation_result to API ref.
ft: Added default plot_region=True to forecast.plot(). Added log_scale option to plot_magnitude_histogram for y axis, and also the mean is plotted now instead of median. Remove tight_layout from plot_catalog() option.
fix: added transform argument when plotting the region in plot_gridded_dataset.
ft: added helper to issue deprecation warning when plot_args is passed. Added typehinting overload to legacy wrappers, so IDEs can detect signature/docstrings.
fix: avoid drawing basemap when an ax is passed to plot_catalog and plot_gridded_dataset.  modified .plot methods to be consistent with new plot functionality
docs: remove plots.rst
…plot legend option to plot_consistency() to explain its symbology. Abstracted draw_shaded_bars from plot_consistency and plot_comparison test. Plot_consistency defaults to plot name of the first EvaluationResult.
…tring to where the function is used in the tutorials. Added and fixed multiple docs references. Added changelogs in docstrings with versionchanged/versionadded directives to outline major changes. Added optional label to multiple args in docstrings

ft: re-added xlabel_rotation for comparison_plots
fix: typos in docstrings
build-sphinx: rewrite "make clean" directive, to effectively delete generated sphinx-gallery and sphinx-autodocs material.
…., import csep.plots), and left the legacy plots module in the same location (csep.utils.plots), while adding deprecation warnings to all of its uses. Removed legacy compat layer. Modified tests and docs accordingly.
…py versions (numpy.bool_ can't behave as int anymore).
Refactored Plot Module, updating plotting functions and changed API to `csep.plots`
…h PEP621 and PEP660. Added automatic versioning with setuptools_scm. Added tox as dev dependency to run local tests on multiple python versions. Changed conda build file to environment.yml

docs: modified installing instructions accordingly
lic: change license name to LICENSE
…ons are optional, and made explicit options to normalize, confidence intervals, and cumulative histogram
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