API reference#

class echopop.Survey(init_config_path: Union[str, Path], survey_year_config_path: Union[str, Path])#

echopop base class that imports and prepares parameters for a survey. Additionally, it includes functions for accessing the modules associated with the transect and Kriging variable calculations, CV analysis, semi-variogram algorithm, and Kriging.

Parameters
init_config_pathstr or pathlib.Path

A string specifying the path to the initialization YAML file

survey_year_config_pathstr or pathlib.Path

A string specifying the path to the survey year YAML file

Attributes
metadict

Metadata variable that provides summary information concerning the data contained within the class object (e.g. ‘self.summary’).

configdict

Configuration settings and parameters that can be referenced for various downstream and internal functions.

datadict

Various dictionaries are incorporated into the Survey class object that are directly referenced for various downstream and internal functions. This includes attributes such as ‘biology’, ‘acoustics’, and ‘spatial’ that represent various nested biological, acoustic, and spatial/stratification datasets imported based on the input files defined via the configuration settings.

apportion_kriged_biomass(species_id)#

Apportion kriged biomass based on sex, age, and other proportions

Notes

This function apportions the kriged biomass values (interpolated along a user-defined mesh) based on sex and age. This provides biomass estimates for aged and unaged fish, total biomass inferred from the biological and kriged bioamss estimates, the coefficient of variation within each cell, and georeferenced biomass estimates for specific paired values of sex and age-class. Binned length data (length_df) represent sexed, but unaged fish measured at Station 1. Specimen data (specimen_data) represent sexed and aged fish measured at Station 2. Total haul weights (catch_df) represent the bulk weights of unaged and unsexed fish measured in Station 1.

biometric_distributions()#

Expand bin parameters into actual bins for length and age distributions

fit_binned_length_weight_relationship(species_id: float64)#

Fit a length-weight relationship across discrete bins

Parameters
species_idnp.float64

Numeric code representing a particular species of interest

Notes

This function first fits a length-weight regression based on measured values and then produces an array of fitted weight values based on binned length values. The length-weight relationship produced here are used for later biomass calculations and apportionment.

impute_missing_sigma_bs(species_id: float64)#

Imputes sigma_bs for strata without measurements or values

Parameters
species_idnp.float64

Numeric code representing a particular species of interest

Notes

This function iterates through all stratum layers to impute either the nearest neighbor or mean sigma_bs for strata that are missing values.

krige(variable: str = 'B_a_adult')#

Interpolates biomass data using ordinary kriging

Parameters
variable

Biological variable that will be interpolated via kriging

load_survey_data()#

Loads the biological, NASC, and stratification data using parameters obtained from the configuration files. This will generate data attributes associated with the tags defined in both the configuration yml files and the reference CONFIG_MAP and LAYER_NAME_MAP dictionaries.

nasc_to_biomass_conversion(species_id: float64)#

Converts integrated acoustic backscatter (NASC) into estimates of areal number/biomass densities, total abundance, and total biomass

Parameters
species_idnp.float64

Numeric code representing a particular species of interest

Notes

This function converts NASC into estimates of population-level metrics (abundance, biomass, areal densities) stratified by transects, sex, length-based strata, and age.

read_validated_data(file_name: Path, sheet_name: str, config_map: list, validation_settings: dict)#

Reads in data and validates the data type of each column/variable

Parameters
file_name: Path

The file name without the prepended file path

sheet_name: str

The Excel sheet name containing the target data

config_map: list

A list parsed from the file name that indicates how data attributes within self are organized

validation_settings: dict

The subset CONFIG_MAP settings that contain the target column names

standardize_coordinates(dataset: str = 'biomass_density')#

Standardizes spatial coordinates based on reference positions

strata_age_binned_weight_proportions(species_id: float64)#

Calculates the age- and sex-binned proportions across all strata with respect to specimen counts and weights

Parameters
species_idnp.float64

Numeric code representing a particular species of interest

Notes

The sex-stratified proportions for both counts and weights currently incorporate age-0 and age-1 fish without an option to exclude.

strata_mean_sigma_bs(species_id: float64)#

Calculates the stratified mean sigma_bs for each stratum

Parameters
species_idnp.float64

Numeric code representing a particular species of interest

Notes

This function iterates through each stratum to fit acoustic target strength (TS, dB re. 1 m^2) values based on length distributions recorded for each stratum. These fitted values are then converted from the logarithmic to linear domain (sigma_bs, m^2) and subsequently averaged. These are required for later functions that will convert vertically integrated backscatter (e.g. the nautical area scattering coefficient, or NASC, m^2 nmi^-2) to estimates of areal density (animals nmi^-2).

strata_sex_weight_proportions(species_id: float64)#

Calculate the total and sex-specific mean weight for each stratum

Parameters
species_idnp.float64

Numeric code representing a particular species of interest

Notes

This function produces the proportion of male and female, and the average weight of male, female, and total (male, female, and unsexed fish). The average weight is estimated using the length-weight relationship fitted in fit_binned_length_weight_relationship.

stratified_summary()#

Calculates the stratified summary statistics for biomass

Notes

This function calculates estimates and confidence intervals (95%) for biomass mean, variance, and coefficients of variation (CVs). This currently only calculates this metric for adult animals (age-2+) and is not calculated for other contrasts such as age-class and sex. This also only applies to the transect results and is not currently designed to be compatible with other derived population-level statistics (e.g. kriging).

transect_analysis(species_id: float64 = 22500)#

Calculate population-level metrics from acoustic transect measurements