afsc-assessments / EBS_PCOD

Eastern Bering Sea Stock Assessment
1 stars 1 forks source link

change up? #119

Open BenWilliams-NOAA opened 1 month ago

BenWilliams-NOAA commented 1 month ago

https://github.com/afsc-assessments/EBS_PCOD/blob/7af4a36c2f0bb7c725bb8cb3cf406a11c3e98d58/2023_ASSESSMENT/Functions/R/GET_BS_BIOM.r#L5

Hey Steve, I've noticed a number of folks adapting your code for assessments. Wondering if you would be amenable to changing the format of functions so that they will work with afscdata and we can roll them in more easily?

For example this code produces the same results as your GET_BS_BIOM() function:

library(afscdata)
akfin = connect()
species = 21720

dplyr::tbl(akfin, dplyr::sql('afsc.race_biomass_ebsshelf_plusnw')) %>% 
    dplyr::filter(STRATUM %in% 999,
                  SPECIES_CODE %in% species) %>% 
    dplyr::select(YEAR, BIOM = BIOMASS, POP = POPULATION, POPVAR = VARPOP,
                    NUMHAULS = HAULCOUNT, NUMCAUGHT = CATCOUNT)  %>% 
    dplyr::collect() %>% 
    dplyr::group_by(YEAR) %>% 
    dplyr::summarise(dplyr::across(dplyr::everything(), sum)) 

While a simple example, the more we get things in a common framework the more easily we can make them work for multiple species.

zandjyo commented 1 month ago

Merging with afscdata has been my plan all along, but I needed something that worked back in February,so just updated my old code then to get it to function. As I work through the next assessment I will be drawing from the working afscdata functions where possible.

On Wed, Jun 5, 2024 at 3:38 PM Ben Williams @.***> wrote:

https://github.com/afsc-assessments/EBS_PCOD/blob/7af4a36c2f0bb7c725bb8cb3cf406a11c3e98d58/2023_ASSESSMENT/Functions/R/GET_BS_BIOM.r#L5

Hey Steve, I've noticed a number of folks adapting your code for assessments. Wondering if you would be amenable to changing the format of functions so that they will work with afscdata and we can roll them in more easily?

For example this code produces the same results as your GET_BS_BIOM() function:

library(afscdata) akfin = connect() species = 21720

dplyr::tbl(akfin, dplyr::sql('afsc.race_biomass_ebsshelf_plusnw')) %>% dplyr::filter(STRATUM %in% 999, SPECIES_CODE %in% species) %>% dplyr::select(YEAR, BIOM = BIOMASS, POP = POPULATION, POPVAR = VARPOP, NUMHAULS = HAULCOUNT, NUMCAUGHT = CATCOUNT) %>% dplyr::collect() %>% dplyr::group_by(YEAR) %>% dplyr::summarise(dplyr::across(dplyr::everything(), sum))

While a simple example, the more we get things in a common framework the more easily we can make them work for multiple species.

— Reply to this email directly, view it on GitHub https://github.com/afsc-assessments/EBS_PCOD/issues/119, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJFGJJHCU4F7JXYRLHQXPLZF6HNFAVCNFSM6AAAAABI3S5N5GVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTMOJUGMYTQOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Steven J. Barbeaux Ph.D. Research Fisheries Biologist Alaska Fisheries Science Center, National Marine Fisheries Service National Oceanic and Atmospheric Administration 7600 Sand Point Way NE, Seattle, WA 98115 USA Tel: (206) 729-0871