knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(hake)

Note - simply rendering this vignette will build all the files, and you don't have to do anything else to update sample data. This includes age proportions (both weighted and raw), gear and bottom depth-by-fleet files, and the weight-at-age file. Check the timestamps of the files to verify. \

  1. Open R and load the hake package: \ r devtools::load_all()

  2. On the DFO network, or on a DFO computer with the VPN turned on, run the following to extract the newest data from the GFBioSQL database. \ Choose any directory, the one shown here is an example: \ r canada_extract_samples_from_db(dr = "some/path/on/local/machine") This will create a file called r can_sample_data_rds_fn in the directory you chose for dr.

  3. Move or copy the file (r can_sample_data_rds_fn) you created to the server in the directory /srv/hake/other/samples.

  4. Run the following to load the sample data from the RDS file created above. Area and gear type filtering is also performed in this function. The default gear type is midwater trawl and the default areas are the west coast major areas plus the strait of Juan de Fuca: \ r sample_df <- canada_load_sample_data()

  5. Run the following to break the sample_df data frame created above into smaller data frames representing the three Canadian fleets (Freezer trawlers, Shoreside, and Joint venture): \ r samples_fleet_lst <- canada_get_fleet_samples(sample_df)

  6. Run the following to create (overwrite) the Canadian age proportions by fleet files (Freezer trawlers, Shoreside, and Joint venture). These proportions are weighted by sample weight and catch weight, and use a length/weight model to estimate parameters used to generate individual specimen weights from records with only length data: \ r canada_create_age_proportions_csv(samples_fleet_lst$ft, type = "ft") canada_create_age_proportions_csv(samples_fleet_lst$ss, type = "ss") canada_create_age_proportions_csv(samples_fleet_lst$jv, type = "jv")

  7. Run the following to create (overwrite) the raw Canadian age proportions by fleet files (Freezer trawlers, Shoreside, and Joint venture). These proportions are not weighted and do not contain weights calculated by using a length/weight model: \ r canada_create_age_proportions_csv(samples_fleet_lst$ft, type = "ft", raw_counts = TRUE) canada_create_age_proportions_csv(samples_fleet_lst$ss, type = "ss", raw_counts = TRUE) canada_create_age_proportions_csv(samples_fleet_lst$jv, type = "jv", raw_counts = TRUE)

  8. Create the Canadian weight-at-age CSV file: r canada_create_commercial_waa(sample_df)

Process depth data

This section outlines how to extract fishing depth and bottom depth data for the fleets, and create the CSV files for them.

  1. This assumes you have loaded the package already using devtools::load_all()

  2. On the DFO network, or on a DFO computer with the VPN turned on, run the following to extract the depth data from the GFBioSQL database. Choose any directory, the one shown here is an example (can_sample_dr and can_depths_rds_fn are package data constants): \ r rds_fn <- file.path(can_sample_dr, can_depths_rds_fn) canada_extract_depth_data_from_db(rds_fn) This will create a file called r can_depths_rds_fn in the directory you chose for dr.

  3. Read in the depth/fishing event RDS file created in the previous step. It contains both depths and fishing event IDs. Also read in the samples data RDS file. It contains the fishing event IDs along with the vessel IDs and fleet: \ r # Load the Canadian depth data in and manipulate the data frame rds_fn <- file.path(can_sample_dr, can_depths_rds_fn) depth_fe_df <- readRDS(rds_fn) |> mutate(year = year(best_date)) |> select(year, fleet, fishing_event_id, vessel_id, bottom_depth_fm, gear_depth_fm) message("Loaded the Canadian depth data in from file:\n`", rds_fn, "`")

  4. Create the depth CSV files: \ ```r # Canadian Freezer trawlers gear depth create_depth_by_year_csv_files( filter(depth_fe_df, fleet == "ft"), col_name_depth = "gear_depth_fm", col_name_year = "year", country = "can", fleet = "ft", type = "gear", yrs = 2007:2023)

    # Canadian Shoreside gear depth create_depth_by_year_csv_files( filter(depth_fe_df, fleet == "ss"), col_name_depth = "gear_depth_fm", col_name_year = "year", country = "can", fleet = "ss", type = "gear", yrs = 2007:2023)

    # Canadian Freezer trawlers bottom depth create_depth_by_year_csv_files( filter(depth_fe_df, fleet == "ft"), col_name_depth = "bottom_depth_fm", col_name_year = "year", country = "can", fleet = "ft", type = "bottom", yrs = 2007:2023)

    # Canadian Shoreside bottom depth create_depth_by_year_csv_files( filter(depth_fe_df, fleet == "ss"), col_name_depth = "bottom_depth_fm", col_name_year = "year", country = "can", fleet = "ss", type = "bottom", yrs = 2007:2023) ```



pacific-hake/hake-assessment documentation built on July 21, 2024, 8:19 a.m.