afsc-gap-products / gapindex

Calculation of Design-Based Indices of Abundance and Composition for AFSC GAP Bottom Trawl Surveys
https://afsc-gap-products.github.io/gapindex/
Other
4 stars 3 forks source link

calc_biomass_subarea bug #38

Closed zoyafuso-NOAA closed 10 months ago

zoyafuso-NOAA commented 10 months ago

Using version 2.1.1

This piece of script does not reproduce what is in HAEHNR.BIOMASS_EBS_PLUSNW. Bug has to do with how NAs are dealt in the function.

library(gapindex)

## Connect to Oracle
sql_channel <- gapindex::get_connected()

## Pull data.
gapindex_data <- gapindex::get_data(
  year_set = c(1993),
  survey_set = "EBS",
  spp_codes = 81742,   
  haul_type = 3,
  abundance_haul = "Y",
  pull_lengths = F,
  sql_channel = sql_channel)

## Fill in zeros and calculate CPUE
cpue <- gapindex::calc_cpue(racebase_tables = gapindex_data)

## Calculate stratum-level biomass, population abundance, mean CPUE and 
## associated variances
biomass_stratum <- gapindex::calc_biomass_stratum(
  racebase_tables = gapindex_data,
  cpue = cpue)

## Calculate aggregated biomass and population abundance across subareas,
## management areas, and regions
biomass_subareas <- gapindex::calc_biomass_subarea(
  racebase_tables = gapindex_data,
  biomass_strata = biomass_stratum)
zoyafuso-NOAA commented 10 months ago

will be updated in v2.1.2