get_early_iphc: Get early IPHC data from already-saved .rds files (can likely...

get_early_iphcR Documentation

Get early IPHC data from already-saved .rds files (can likely integrate into get-dat.R)

Description

Gets the early IPHC data from .rds files for the species in question. Those data are not all in GFBio.

Use the gfplot species common name to extract IPHC data.

For set-level data the counts are not in GFbio but in data/. When getting a new dataset for which we do not have hook level data then run this to check that all IPHC names have a GFbio name.

Details The IPHC report for 1996 mentions 120 stations and does not use the ones off WCVI that are 'RS' (random sample?) and not in the same pattern as the 'SG' (Setline Grid) stations. Here using the SG ones only (the RS ones are saved as setData1995rs and countData1995rs).

Details Note that 1996 is based on all hooks being enumerated while 1997-2002 is for first 20 only.

When only first 20 hooks were evaluated, the data are in here (not GFbio). See data-raw/iphc-2020-data.Rmd and updated data-raw/iphc-2020-data.Rmd for details to extract the data from the IPHC website and include in this pacakge. This function should then work for all such years, since the data will be saved in the correct format. Was get_iphc_2013() but generalising for future years.

Usage

get_iphc_spp_name(species = NULL)

check_iphc_spp_name(countData = NULL, ignore_obvious = TRUE)

get_iphc_1995(species)

get_iphc_1996to2002(species)

get_iphc_from_gfiphc(species, year)

Arguments

species

Species common name (as used by gfdata). If NULL then get_iphc_spp_name returns the full data frame of names (iphc-spp-names-csv).

countData

A new IPHC dataset to check all species names against, if NULL then returns all IPHC names in the saved set-level data that are not in our list of Type A or Type B species given in gfsynopsis.

ignore_obvious

Whether or not to ignore some obvious non-groundfish species (listed in function) when countData is NULL.

year

year of interest, must be 2013, 2020, 2021, or 2022

Details

The output datasets feed into IPHC-specific functions to create a time-series. **.....other functions (tidy_, plot_, or fit_ functions) for data visualization, which can be used as products themselves or can be fed into automated DFO Pacific groundfish data synopsis report production.

Details

Value

IPHC species common name, or NA if species is not in IPHC data (**need to add more years of species names if they start showing up), or if species is NULL then a data.frame of all species names (the file iphc-spp-names.csv).

IPHC species common names in countData (or if NULL IPHC species names in saved set-level IPHC data that are not in iphc-spp-names.csv).

Tibble contains year (1995), station name, lat, lon, E_it (effective skate number for that station, based on all hooks), N_it (number of 'species' caught on all hooks), C_it (catch rate of 'species' as number per effective skate, based on all hooks), E_it20 (effective skate number for that station, based on first 20 hooks, so NA for 1995), N_it20 (number of 'species' caught in first 20 hooks, so NA for 1995), C_it20 (catch rate of 'species' as number per effective skate, based on the first 20 hooks, so NA for 1995), usable (whether or not that station is usable, as deemed by IPHC), standard (whether or not station is a standard one or in the expansion set after 2018; manually setting to Y here as stations are not exactly the same as the standard ones but are not in the expanded area)

If no data at all on that species then C_it and N_it are NA's.

Tibble contains year, station name, lat, lon, E_it (effective skate number for that station, based on all hooks, so NA for 1997-2002), N_it (number of 'species' caught on all hooks, so NA for 1997-2002), C_it (catch rate of 'species' as number per effective skate, based on all hooks, so NA for 1997-2002), E_it20 (effective skate number for that station, based on first 20 hooks, so NA for 1996), N_it20 (number of 'species' caught in first 20 hooks, so NA for 1996), C_it20 (catch rate of 'species' as number per effective skate, based on the first 20 hooks, so NA for 1996), usable (whether or not that station is usable, as deemed by IPHC), standard (whether or not station is a standard one or in the expansion set after 2018; all Y here since pre-2018; for 1996 and 1997 the station layout is not the standard grid and the naming of stations is different, ⁠intersect(filter(sp_set_counts$set_counts, year == 1996)$station, setDataExpansion$station⁠ is empty, but the area fished is similar to later standard years so we put Y here)

If no data on that species then C_it and N_it are NA's.

Tibble contains year, station name, lat, lon, E_it (effective skate number for that station, based on all hooks, so all NA), N_it (number of 'species' caught on all hooks, so all NA), C_it (catch rate of 'species' as number per effective skate, based on all hooks, so all NA), E_it20 (effective skate number for that station, based on first 20 hooks), N_it20 (number of 'species' caught in first 20 hooks), C_it20 (catch rate of 'species' as number per effective skate, based on the first 20 hooks), usable (whether or not that station is usable, as deemed by IPHC), standard (whether or not station is a standard one or in the expansion set after 2018)

If no data at all on that species then C_it and N_it are NA's.

Examples

## Not run: 
get_iphc_spp_name("redbanded rockfish")
get_iphc_spp_name("made up name")
testthat::expect_error(get_iphc_spp_name(c("redbanded rockfish", "yellowmouth rockfish")))

## End(Not run)
## Not run: 
check_iphc_spp_name()              # All the IPHC names not in
                                   #  iphc-spp-names.csv
check_iphc_spp_name(countData2013) # All the 2013 IPHC names not in
                                   #  iphc-spp-names.csv

## End(Not run)
## Not run: 
yyr1995 <- get_iphc_1995("yelloweye rockfish")
summary(yyr1995)

## End(Not run)

## Not run: 
yyr1996to2002 <- get_iphc_1996to2002("yelloweye rockfish")
summary(yyr1996to2002)
dplyr::summarise(group_by(yyr1996to2002, year, num.stations = n()))
# number of stations in each year.

## End(Not run)

## Not run: 
yyr2013 <- get_iphc_from_gfiphc("yelloweye rockfish", year = 2013)
summary(yyr2013)
expect_equal(get_iphc_2013("yelloweye rockfish"), yyr2013)  # until I retire get_iphc_2013()

## End(Not run)

pbs-assess/gfiphc documentation built on July 4, 2023, 1:13 p.m.