Skip to content

Commit

Permalink
Diagnostic plotting extension (#304)
Browse files Browse the repository at this point in the history
* Update example notebook

* Fix validation function

* Initial diagnostic plotting

* DiagnosticPlot class

* Pre-commit changes

* Fix notebook image relative pathing

* Another fix to relative pathing

* Move images to a folder in `/example_workbooks`

* Update dependencies

* Changes to extension

* Fixes to notebook

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add pinning for `jupyter_bokeh` to avoid unresolvable bug when using older versions

* Add offset for minimum point size in `nasc_map`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Changes to diagnostic plotting functions

* Changes to diagnostic plotting notebook

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
brandynlucca and pre-commit-ci[bot] authored Dec 31, 2024
1 parent 96a0315 commit 0480e2a
Show file tree
Hide file tree
Showing 10 changed files with 1,277 additions and 12 deletions.
3 changes: 2 additions & 1 deletion docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ parts:
sections:
- file: example_notebooks/example_echopop_workflow
- file: example_notebooks/report_generation
- file: example_notebooks/plotting.ipynb
- file: example_notebooks/plotting
- file: example_notebooks/diagnostic_plotting
- file: theory
title: Underlying theory
sections:
Expand Down
712 changes: 712 additions & 0 deletions docs/example_notebooks/diagnostic_plotting.ipynb

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions echopop/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ def krige(input_dict: dict, analysis_dict: dict, settings_dict: dict) -> tuple[p
arguments and user-defined inputs.
"""

# Initialize kriging analysis dictionary
analysis_dict.update({"kriging": {}})

# Validate cropping method parameters
validated_cropping_methods = MeshCrop.create(**settings_dict["cropping_parameters"])
# ---- Update the dictionary
Expand Down Expand Up @@ -419,7 +422,16 @@ def krige(input_dict: dict, analysis_dict: dict, settings_dict: dict) -> tuple[p
)
else:
# ---- Compute the cropped mesh
mesh_full = crop_mesh(transect_data, mesh_data, validated_cropping_methods)
mesh_full, transect_mesh_regions = crop_mesh(
transect_data, mesh_data, validated_cropping_methods
)
# ---- Append 'transect_mesh_regions' to analysis variable
analysis_dict["kriging"].update(
{
"transect_mesh_regions_df": transect_mesh_regions,
}
)
# ---- Print message, if verbose
if (settings_dict["verbose"]) and (
validated_cropping_methods["crop_method"] == "convex_hull"
):
Expand Down Expand Up @@ -453,7 +465,7 @@ def krige(input_dict: dict, analysis_dict: dict, settings_dict: dict) -> tuple[p
# -------- y
mesh_full["y"] = mesh_full["latitude"]
# --- Append to the analysis attribute
analysis_dict.update({"kriging": {"mesh_df": mesh_full, "transect_df": transect_data}})
analysis_dict["kriging"].update({"mesh_df": mesh_full, "transect_df": transect_data})

# Kriged results
kriged_results = kriging(
Expand Down
8 changes: 6 additions & 2 deletions echopop/extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from .survey_extensions import patch_generate_reports as generate_reports
from .survey_extensions import (
patch_diagnostic_plots as diagnostic_plots,
patch_generate_reports as generate_reports,
)


# Flex patch import
def import_all_patches():
diagnostic_plots()
generate_reports()


# ---- Automatic import for `import echopop.extensions`
import_all_patches()

# Exposed individual patches for selective importing
__all__ = ["generate_reports"]
__all__ = ["diagnostic_plots", "generate_reports"]
Loading

0 comments on commit 0480e2a

Please sign in to comment.