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 Refactoring #263

Open
wants to merge 9 commits into
base: v1.0.0-candidate
Choose a base branch
from

Commits on Aug 20, 2024

  1. refac: initial refactoring of the plotting module.

     - 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).
    pabloitu committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    9648e76 View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2024

  1. ft: Added rasterio reader for plot_basemap, which plots a raster in t…

    …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
    pabloitu committed Aug 22, 2024
    Configuration menu
    Copy the full SHA
    f9ade59 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    694f6f3 View commit details
    Browse the repository at this point in the history

Commits on Aug 23, 2024

  1. Configuration menu
    Copy the full SHA
    7d89727 View commit details
    Browse the repository at this point in the history
  2. refactor: Added type hints and docstrings to helper functions. Remove…

    …d unused helper functions
    pabloitu committed Aug 23, 2024
    Configuration menu
    Copy the full SHA
    c348605 View commit details
    Browse the repository at this point in the history

Commits on Aug 27, 2024

  1. refactor: negative_binomial_number_test now stores the variance argum…

    …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
    pabloitu committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    229d0d8 View commit details
    Browse the repository at this point in the history
  2. refactor: t-test EvaluationResult() now includes value of alpha, so i…

    …t is not necessary to set it again when plotting. plot_comparison_test() includes a default legend that explains the symbology therein.
    pabloitu committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    7306329 View commit details
    Browse the repository at this point in the history

Commits on Aug 30, 2024

  1. docs: Harmonized docstrings of all plotting main functions, making th…

    …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)
    pabloitu committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    21fcc33 View commit details
    Browse the repository at this point in the history
  2. refactor: catalog and forecasts plot methods now uses kwargs instead …

    …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.
    pabloitu committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    c009af4 View commit details
    Browse the repository at this point in the history