Skip to content

Commit

Permalink
updated biomass RDS files with quahog and scallop data
Browse files Browse the repository at this point in the history
  • Loading branch information
andybeet committed Aug 17, 2021
1 parent 14b6114 commit 1b04e1a
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 11 deletions.
48 changes: 48 additions & 0 deletions data-raw/quahog754Biomass.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#' Northeast US Ocean Quahog
#'
#' @description Biomass (mt) of age 20+ fom 1982-2020. 20 is when they become vulnerable to fishery. This data set is an estimate from assessment model
#'
#' @source email communication July 14, 2021
#'
#' @contact Dan Hennen
#'
Yr,Value,StdDev,CV,upper,lower
1982,3651020,447999,0.122705162,4529098.04,2772941.96
1983,3643160,446195,0.12247472,4517702.2,2768617.8
1984,3632820,444285,0.122297554,4503618.6,2762021.4
1985,3618360,442283,0.122233001,4485234.68,2751485.32
1986,3600430,440191,0.122260674,4463204.36,2737655.64
1987,3583100,437986,0.122236611,4441552.56,2724647.44
1988,3562650,435709,0.122299131,4416639.64,2708660.36
1989,3542600,433353,0.122326258,4391971.88,2693228.12
1990,3520200,430960,0.122424862,4364881.6,2675518.4
1991,3498520,428529,0.122488652,4338436.84,2658603.16
1992,3475810,426095,0.122588692,4310956.2,2640663.8
1993,3452690,423676,0.12270896,4283094.96,2622285.04
1994,3430150,421292,0.122820285,4255882.32,2604417.68
1995,3408600,418960,0.122912633,4229761.6,2587438.4
1996,3387210,416713,0.12302544,4203967.48,2570452.52
1997,3367200,414573,0.123120991,4179763.08,2554636.92
1998,3348360,412576,0.123217336,4157008.96,2539711.04
1999,3332090,410751,0.12327128,4137161.96,2527018.04
2000,3317610,409118,0.123317087,4119481.28,2515738.72
2001,3307340,407758,0.123288806,4106545.68,2508134.32
2002,3297450,406723,0.123344706,4094627.08,2500272.92
2003,3290190,406157,0.123444847,4086257.72,2494122.28
2004,3286740,406260,0.123605761,4083009.6,2490470.4
2005,3290260,407297,0.123788698,4088562.12,2491957.88
2006,3303000,409831,0.124078414,4106268.76,2499731.24
2007,3320050,415511,0.125152031,4134451.56,2505648.44
2008,3346210,421110,0.125846854,4171585.6,2520834.4
2009,3376510,428666,0.126955347,4216695.36,2536324.64
2010,3409400,437470,0.1283129,4266841.2,2551958.8
2011,3442570,446898,0.129815225,4318490.08,2566649.92
2012,3476710,456473,0.131294528,4371397.08,2582022.92
2013,3507890,465907,0.132816879,4421067.72,2594712.28
2014,3538040,474948,0.134240427,4468938.08,2607141.92
2015,3566010,483459,0.135574213,4513589.64,2618430.36
2016,3590700,491367,0.136844348,4553779.32,2627620.68
2017,3613680,498616,0.13798012,4590967.36,2636392.64
2018,3633840,505203,0.13902731,4624037.88,2643642.12
2019,3651440,511131,0.139980665,4653256.76,2649623.24
2020,3670560,516376,0.140680441,4682656.96,2658463.04
53 changes: 53 additions & 0 deletions data-raw/scallop401Biomass.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#' Northeast US Sea Scallop
#'
#' @description Biomass (mt) of from 1975-2017 of individuals >= 40mm. Individuals < 40mm are excluded since survey can not sample smaller than this size. Contrubute very little to biomass. No value for Gulf of Maine. Expected at most 5% of biomass (Dvora Hart communication). This data set is from 65 SAW 2018 assessment p80 table A9.4
#'
#' @source email communication July 15, 2021
#'
#' @contact Dvora Hart
#'
#' NA,millions,NA,mt gonads,NA,mt meats,NA,mt meats,NA,NA,NA
Year,Abundance,CV,SSB,CV_1,Bms,CV_2,ExplBms,CV_3,F,CV_4
1975,3155,0.05,24467,0.12,51187,0.06,40059,0.07,0.14,0.06
1976,2656,0.05,25882,0.12,54945,0.06,44644,0.07,0.25,0.06
1977,2503,0.05,23387,0.12,50681,0.06,40429,0.07,0.33,0.06
1978,2247,0.05,19788,0.12,43303,0.06,33816,0.07,0.49,0.07
1979,1590,0.05,15045,0.13,33670,0.06,26831,0.07,0.57,0.07
1980,1770,0.05,12590,0.13,27793,0.06,24120,0.07,0.41,0.06
1981,1582,0.06,11328,0.13,25481,0.06,22251,0.07,0.46,0.06
1982,1436,0.06,9895,0.14,22308,0.06,19699,0.07,0.54,0.07
1983,1228,0.07,8585,0.16,19016,0.07,16550,0.08,0.58,0.08
1984,1165,0.08,7726,0.19,16680,0.09,14170,0.1,0.53,0.09
1985,1564,0.08,7951,0.19,17184,0.09,12841,0.12,0.62,0.1
1986,2407,0.06,10091,0.16,21877,0.07,14430,0.11,0.7,0.1
1987,2824,0.06,12468,0.15,26813,0.07,18502,0.1,0.89,0.09
1988,2818,0.07,13599,0.15,29433,0.07,21588,0.1,0.76,0.09
1989,3098,0.06,14395,0.14,31035,0.06,22370,0.09,0.85,0.09
1990,2954,0.05,13278,0.13,29763,0.06,21729,0.08,1.06,0.08
1991,2629,0.06,11055,0.13,25171,0.06,18226,0.08,1.28,0.07
1992,1869,0.09,8688,0.2,19932,0.09,15250,0.12,1.24,0.09
1993,3023,0.1,11799,0.25,25459,0.11,15289,0.19,0.57,0.13
1994,3083,0.09,16861,0.24,35024,0.11,26576,0.15,0.43,0.13
1995,3571,0.09,21609,0.23,44896,0.11,36259,0.14,0.34,0.12
1996,3109,0.1,24901,0.23,52290,0.11,46252,0.12,0.27,0.11
1997,3036,0.1,27237,0.23,56780,0.11,51949,0.12,0.18,0.11
1998,5324,0.09,35097,0.2,72954,0.1,45315,0.16,0.21,0.11
1999,6981,0.07,46844,0.18,97602,0.08,54332,0.15,0.3,0.12
2000,8386,0.06,59879,0.15,124294,0.07,75756,0.12,0.29,0.1
2001,9127,0.05,71049,0.14,147771,0.07,97544,0.1,0.32,0.08
2002,8184,0.05,75545,0.13,157358,0.06,107600,0.09,0.33,0.07
2003,9954,0.07,79073,0.12,164400,0.06,116122,0.08,0.32,0.07
2004,8041,0.05,76710,0.11,160016,0.05,112320,0.07,0.37,0.06
2005,7195,0.04,72255,0.1,152093,0.05,108273,0.07,0.32,0.06
2006,6737,0.04,65531,0.1,139620,0.05,102115,0.07,0.34,0.06
2007,6601,0.04,59716,0.1,125255,0.05,87578,0.07,0.39,0.06
2008,7370,0.04,59962,0.1,125025,0.05,81766,0.07,0.4,0.06
2009,6832,0.04,62474,0.1,130493,0.05,84113,0.07,0.4,0.06
2010,6124,0.05,60677,0.11,127542,0.05,90761,0.07,0.34,0.06
2011,5226,0.05,52478,0.11,112971,0.05,83525,0.07,0.36,0.06
2012,6233,0.06,47299,0.13,102703,0.06,69064,0.09,0.43,0.07
2013,6029,0.06,51650,0.14,108199,0.06,64933,0.11,0.35,0.07
2014,11538,0.07,72799,0.13,151369,0.06,81066,0.12,0.21,0.07
2015,17091,0.06,107706,0.12,222660,0.06,96973,0.14,0.19,0.07
2016,16008,0.06,137994,0.12,285114,0.06,146639,0.12,0.14,0.08
2017,14171,0.06,153182,0.13,317334,0.06,214921,0.09,0.12,0.07
8 changes: 8 additions & 0 deletions data-raw/surfclam403Biomass.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#' Northeast US Surfclam
#'
#' @description Total biomass (mt) fom 1963-2019. Assessment report list only 6+ age classes. This data set is an estimate of total population biomass (from assessment model)
#'
#' @source email communication April 6, 2021
#'
#' @contact Dan Hennen
#'
Yr,Value,StdDev,CV,upper,lower
1963,1956810,451274,0.230617178,2841307.04,1072312.96
1964,1968280,451545,0.229410958,2853308.2,1083251.8
Expand Down
74 changes: 63 additions & 11 deletions data-raw/survdat_biomass.r
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,54 @@ if (pullFromDB) {

### read in atlantic surfclam data. Poorly sampled in bottom trawl survey

clam <- readr::read_csv(file=here::here("data-raw","surfclam403Biomass.csv")) # from Dan Hennen swept are biomass
clam <- readr::read_csv(file=here::here("data-raw","surfclam403Biomass.csv"),skip=8)
# from Dan Hennen swept are biomass
clam <- clam %>%
dplyr::select(Yr,Value,StdDev) %>%
dplyr::rename(YEAR = Yr) %>%
dplyr::mutate(tot.biomass = 1000*Value) %>%
dplyr::mutate(SVSPP=403) %>%
dplyr::mutate(tot.biomass.var = StdDev*2) %>%
dplyr::mutate(tot.biomass.var = StdDev^2) %>%
dplyr::mutate(units = "kg") %>%
dplyr::select(-StdDev,-Value) %>%
tidyr::pivot_longer(.,cols= c("tot.biomass","tot.biomass.var"),names_to = "variable",values_to = "value") %>%
dplyr::mutate(variable = as.factor(variable))

### read in ocean quahog data. Poorly sampled in bottom trawl survey

quahog <- readr::read_csv(file=here::here("data-raw","quahog754Biomass.csv"),skip=8)
# from Dan Hennen swept are biomass
quahog <- quahog %>%
dplyr::select(Yr,Value,StdDev) %>%
dplyr::rename(YEAR = Yr) %>%
dplyr::mutate(tot.biomass = 1000*Value) %>%
dplyr::mutate(SVSPP=754) %>%
dplyr::mutate(tot.biomass.var = StdDev^2) %>%
dplyr::mutate(units = "kg") %>%
dplyr::select(-StdDev,-Value) %>%
tidyr::pivot_longer(.,cols= c("tot.biomass","tot.biomass.var"),names_to = "variable",values_to = "value") %>%
dplyr::mutate(variable = as.factor(variable))

#### scallop data from stock smart
# scallop <- assessmentdata::stockAssessmentData %>%
# dplyr::filter(ITIS==79718, AssessmentYear == 2018) %>%
# dplyr::select(Year,Value,Metric, Description, Units)
# # from 65 Stock assessment table A9.4 p80

scallop <- readr::read_csv(file=here::here("data-raw","scallop401Biomass.csv"),skip=9)

scallops <- scallop %>%
dplyr::select(Year,Bms,CV_2) %>%
dplyr::rename(YEAR = Year) %>%
dplyr::mutate(tot.biomass = 1000*Bms) %>%
dplyr::mutate(SVSPP=401) %>%
dplyr::mutate(tot.biomass.var = (Bms*CV_2)^2) %>%
dplyr::mutate(units = "kg") %>%
dplyr::select(-Bms,-CV_2) %>%
tidyr::pivot_longer(.,cols= c("tot.biomass","tot.biomass.var"),names_to = "variable",values_to = "value") %>%
dplyr::mutate(variable = as.factor(variable))



##############################################################################
######################## USE domain from EPU shape file #####################
Expand All @@ -59,11 +95,13 @@ biomassEPU <- survdat::calc_swept_area(surveyData=data,
tibble::as_tibble()


# remove clams
biomassEPU <- biomassEPU %>% dplyr::filter(SVSPP != 403)
# remove clams, quahogs, scallops
biomassEPU <- biomassEPU %>% dplyr::filter(!(SVSPP %in% c(403,754,401)))

## join clam data from assessment
## join clam, quahog, scallop data from assessment
biomassEPU <- rbind(biomassEPU,clam)
biomassEPU <- rbind(biomassEPU,quahog)
biomassEPU <- rbind(biomassEPU,scallops)

# pull out total bio, abund with standard error for each species over time
sweptAreaBiomassEPU <- biomassEPU %>%
Expand All @@ -90,7 +128,6 @@ boxids <- neusBox %>%
dplyr::filter(BOX_ID != c("23","24") ) %>%
dplyr::pull(BOX_ID)

#### WAIT FOR SEAN TO MERGE PULL REQUEST. CURRENTLY post_strat is BROKEN
biomassNEUS <- NULL
for (boxid in boxids){
biomassBox <- survdat::calc_swept_area(surveyData=data,
Expand All @@ -102,6 +139,14 @@ for (boxid in boxids){
biomassBox$box <- boxid
biomassNEUS <- rbind(biomassNEUS,biomassBox)
}
# remove clams from survdat since poorly sampled in bottom trawl
biomassNEUS <- biomassNEUS %>% dplyr::filter(!(SVSPP %in% c(403,754,401)))

## join clam, quahog , scallop data from assessment
biomassNEUS <- rbind(biomassNEUS,clam)
biomassNEUS <- rbind(biomassNEUS,quahog)
biomassNEUS <- rbind(biomassNEUS,scallops)


sweptAreaBiomassBox <- biomassNEUS %>%
dplyr::filter(variable %in% c("tot.biomass","tot.bio.var","tot.abundance","tot.abundance.var")) %>%
Expand All @@ -114,7 +159,7 @@ saveRDS(sweptAreaBiomassBox,file = here::here("data","sweptAreaBiomassNEUSBox.RD


#############################################################################
################## Aggreate over Box but add in clams #######################
######### Aggreate over Box but add in clams, quahog, scallop################
#############################################################################

biomass <- survdat::calc_swept_area(surveyData=data,
Expand All @@ -124,10 +169,12 @@ biomass <- survdat::calc_swept_area(surveyData=data,
filterBySeason = "FALL",
tidy=T)
# remove clams from survdat since poorly sampled in bottom trawl
biomass <- biomass %>% dplyr::filter(SVSPP != 403)
biomassAllNEUS <- biomass %>% dplyr::filter(!(SVSPP %in% c(403,754,401)))

## join clam data from assessment
biomassAllNEUS <- rbind(biomass,clam)
## join clam, quahog, scallop data from assessment
biomassAllNEUS <- rbind(biomassAllNEUS,clam)
biomassAllNEUS <- rbind(biomassAllNEUS,quahog)
biomassAllNEUS <- rbind(biomassAllNEUS,scallops)

sweptAreaBiomassNEUS <- biomassAllNEUS %>%
dplyr::filter(variable %in% c("tot.biomass","tot.bio.var","tot.abundance","tot.abundance.var")) %>%
Expand All @@ -138,4 +185,9 @@ sweptAreaBiomassNEUS <- biomassAllNEUS %>%

saveRDS(sweptAreaBiomassNEUS,file = here::here("data","sweptAreaBiomassNEUS.RDS"))




ggplot2::ggplot(data = quahog) +
ggplot2::geom_line(mapping = ggplot2::aes(x=YEAR,y=value)) +
ggplot2::facet_wrap(~variable,scales="free")

Binary file modified data/sweptAreaBiomassEPU.RDS
Binary file not shown.
Binary file modified data/sweptAreaBiomassNEUS.RDS
Binary file not shown.
Binary file modified data/sweptAreaBiomassNEUSBox.RDS
Binary file not shown.

0 comments on commit 1b04e1a

Please sign in to comment.