Diagnostic plotting#

Several interactive diagnostic plots can be generated using the graphics.diagnostics module, which extracts required intermediate data products and final results from the analysis workflow. These can then be rendered in a Jupyter notebook. The Diagnostics-class not only enables several diagnostic plots, but it also handles the appropriate bokeh renderer and themes initialization. This can be imported via:

from pathlib import Path
import pandas as pd
from echopop.graphics import diagnostics
from echopop.utils import feat_functions, feat_parameters

# Initialize the plotting class
dplot = diagnostics.Diagnostics()

There are several diagnostic plots that can be readily generated using built-in class methods:

  • plot_mesh_cropping

  • plot_transect_mesh_regions

  • plot_nasc_map

  • plot_stratified_results

Interactive legends

Legend entries can be clicked to highlight or mute the associated data points displayed in the figures.

Hover tooltips

Some figures have additional tooltips that appear when hovering the cursor over data points.

Assess cropped kriging mesh#

This renders a figure that displays the full, uncropped kriging mesh (gray points), cropped mesh nodes (black points), and the associated 200 m isobath (dashed red line). This method has four arguments:

  • mesh_data: Kriging mesh grid DataFrame.

  • cropped_mesh_data: Cropped kriging mesh grid DataFrame.

  • isobath_data: 200 m isobath coordinates DataFrame.

  • projection: EPSG or other CRS string/object compatible with cartopy (e.g. “epsg:4326”).

import panel as pn

# Define specific mesh-region-cropping function
# ---- Latitude resolution
LATITUDE_RESOLUTION = 1.25/60.
# ---- Cropping function
CROP_FUN = feat_functions.transect_ends_crop
# ---- Transect-mesh-region mapper
TRANSECT_MESH_REGION_FUN = feat_parameters.transect_mesh_region_2019


# Transect mesh region assignment
# 'df_nasc_noage1_prt' -> Age-2+ NASC DataFrame 
mesh_cropped, transect_regions = CROP_FUN(
    df_nasc_noage1_prt, df_mesh, LATITUDE_RESOLUTION, TRANSECT_MESH_REGION_FUN
)

# Check mesh cropping
dplot.plot_mesh_cropping(df_mesh, mesh_cropped, df_isobath).opts(width=650, height=400)

Survey transect/mesh-based regions#

This renders a figure displaying survey transects with their respective mesh-based regions. This method has two arguments:

  • transect_data: Transect DataFrame with columns for longitude, latitude, transect_num, and mesh_region.

  • mesh_data: Kriging mesh grid DataFrame.

  • projection: EPSG or other CRS string/object compatible with cartopy (e.g. “epsg:4326”).

# Plot the assignment
dplot.plot_transect_mesh_regions(transect_regions, mesh_cropped).opts(width=650, height=400)

Detecting “extreme” NASC points#

This figure visualizes non-zero NASC data points scaled by color and size distributed along each transect line (black lines). The size of each point represents magnitude in NASC, while the color represents minimum-maximum-scaled NASC values (note that the hover tooltips display the actual NASC estimates). Redder points correspond to NASC values that are larger than other values. This method has two arguments:

  • transect_data: Transect DataFrame with georeferenced NASC values.

  • projection: EPSG or other CRS string/object compatible with cartopy (e.g. “epsg:4326”).

# 'Extreme' NASC plot 
dplot.plot_nasc_map(df_nasc_noage1_prt).opts(width=650, height=400)

Min-max normalization

Min-max normalization is used to rescale along-transect \(\textit{NASC}\), which can help emphasize potentially erroneously large values or spatial regions where there was relatively elevated integrated biological backscatter.

Stratified survey biomass results#

This figure displays the biomass and biomass density distributions for each INPFC stratum computed from the Jolly and Hampton (1990) implementation that is incorporated into Echopop’s stratified analysis methods. The points and lines correspond to the mean and 95% confidence intervals, respectively. This method takes one argument:

  • stratum_results: This can be either a single DataFrame or Dictionary that maps the mean and confidence interval estimates to each stratum. When a Dictionary is supplied, this is intended to include multiple groups for comparison (e.g. transect-only vs kriged outputs).

# Plot stratified results -- biomass per stratum and overall survey
dplot.plot_stratified_results(
    stratum_results={"Transect": stratified_transect_results, "Kriged": stratified_kriged_results}
).opts(width=650, height=400)

Bias

The bias (expressed as a percentage) represent the difference between the bootstrapped and original mean estimates for each stratum and the coefficient of variation (\(\textit{CV}\)).