afsc-assessments / afscdata

An R package for data extraction of AFSC survey and fishery data
https://afsc-assessments.github.io/afscdata/
Other
2 stars 0 forks source link

LLS length comps (all species) and age comps (just sablefish) #19

Open JaneSullivan-NOAA opened 1 year ago

JaneSullivan-NOAA commented 1 year ago

@BenWilliams-NOAA feel free to assign this to me once you've had a chance to review the lls PR. thank you

BenWilliams-NOAA commented 1 year ago

added

JaneSullivan-NOAA commented 1 year ago

@BenWilliams-NOAA I don't see the query in the list please be aware of the following:

# Methods to obtain RPN-weighted lengths were updated for 2021. Records with
# length = 999 now exist to account for instances when there was catch in a
# stratum but no lengths collected. The 999 lengths ensure RPNs sum properly to
# the area-level but should not be included in the length compositions.
# Currently, the user must join on `area_view_lls` in order to filter out areas
# not used in RPN calculations (i.e. `exploitable = 1`).

lens <- sqlQuery(channel_akfin, query = ("
                select    *
                from      afsc.lls_length_rpn_by_area_all_strata
                where     species_code = '21720' and 
                          country = 'United States' and 
                          year >= 1990 and
                          council_sablefish_management_area not in ('Bering Sea', 'Aleutians') and
                          length < 999
                order by  year asc
                ")) %>% 
  rename_all(tolower)

areaview <- sqlQuery(channel_akfin, query = ("
                select distinct   council_sablefish_management_area, council_management_area, 
                                  fmp_management_area, geographic_area_name, 
                                  exploitable, area_code
                from              afsc.lls_area_view
                ")) %>% 
  rename_all(tolower)

lens <- lens %>% 
  left_join(areaview, by = c("area_code", "geographic_area_name", "council_sablefish_management_area"))

# Filter out samples from areas that are not used in RPN calculations
lens <- lens %>% filter(exploitable == 1)
BenWilliams-NOAA commented 1 year ago

oops - got ahead of myself!

This looks to only apply to sablefish yeah?

JaneSullivan-NOAA commented 1 year ago

@BenWilliams-NOAA LLS lengths are fit in a model or reported in the SAFE for sablefish, pcod, REBS, shortraker, thornyheads, and turbot... there's probably more that I'm forgetting about