Skip to content

Commit

Permalink
Initial code, survey data and outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
gambler1650 committed May 23, 2024
1 parent f582b37 commit 391df7d
Show file tree
Hide file tree
Showing 7 changed files with 560 additions and 0 deletions.
53 changes: 53 additions & 0 deletions R/get_thresholds_survdat_atlantis.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Use pulled survdat.rds file to get environmental thresholds for Atlantis groups


survdat_dt <- readRDS("C:/Users/robert.gamble/Desktop/Env_Thresholds/SurvDat/surveyPull.rds")

summary_table <- group_by(survdat_dt$survdat,SVSPP,SEASON)
summary_table_SEASON <- summarise(summary_table, min_bottom_temp = min(BOTTEMP, na.rm=T), max_bottom_temp = max(BOTTEMP, na.rm=T),
min_surface_temp = min(SURFTEMP,na.rm=T), max_surface_temp = max(SURFTEMP,na.rm=T),
min_bottom_sal = min(BOTSALIN,na.rm=T), max_bottom_sal = max(BOTSALIN,na.rm=T),
min_surface_sal = min(SURFSALIN,na.rm=T), max_surface_sal = max(SURFSALIN,na.rm=T))

summary_table_SPECIES <- group_by(survdat_dt$survdat,SVSPP)
summary_table_SPECIES <- summarise(summary_table_SPECIES, min_bottom_temp = min(BOTTEMP, na.rm=T), max_bottom_temp = max(BOTTEMP, na.rm=T),
min_surface_temp = min(SURFTEMP,na.rm=T), max_surface_temp = max(SURFTEMP,na.rm=T),
min_bottom_sal = min(BOTSALIN,na.rm=T), max_bottom_sal = max(BOTSALIN,na.rm=T),
min_surface_sal = min(SURFSALIN,na.rm=T), max_surface_sal = max(SURFSALIN,na.rm=T))

atlantis_groups <- read.csv("C:/Users/robert.gamble/Desktop/Env_Thresholds/SurvDat/atlantis_codes_svspp_survey_thresholds.csv")
atlantis_group_table <- group_by(atlantis_groups,Code)
combined_table_SEASON <- full_join(summary_table_SEASON, atlantis_group_table)
combined_table_SEASON <- filter(combined_table_SEASON, !is.na(Code))

combined_table_SEASON <- group_by(combined_table_SEASON,Code,SEASON)
summary_table_ATLANTIS_SEASON <- summarise(combined_table_SEASON,min_bottom_temp = min(min_bottom_temp), max_bottom_temp = max(max_bottom_temp),
min_surface_temp = min(min_surface_temp), max_surface_temp = max(max_surface_temp),
min_bottom_sal = min(min_bottom_sal), max_bottom_sal = max(max_bottom_sal),
min_surface_sal = min(min_surface_sal), max_surface_sal = max(max_surface_sal))
summary_table_ATLANTIS_SEASON <- filter(summary_table_ATLANTIS_SEASON,!is.na(SEASON))
summary_table_ATLANTIS_SEASON$min_bottom_sal[(summary_table_ATLANTIS_SEASON$min_bottom_sal == 'Inf') | (summary_table_ATLANTIS_SEASON$min_bottom_sal == '-Inf')] <- 'NA'
summary_table_ATLANTIS_SEASON$max_bottom_sal[(summary_table_ATLANTIS_SEASON$max_bottom_sal == 'Inf') | (summary_table_ATLANTIS_SEASON$max_bottom_sal == '-Inf')] <- 'NA'
summary_table_ATLANTIS_SEASON$min_surface_sal[(summary_table_ATLANTIS_SEASON$min_surface_sal == 'Inf') | (summary_table_ATLANTIS_SEASON$min_surface_sal == '-Inf')] <- 'NA'
summary_table_ATLANTIS_SEASON$max_surface_sal[(summary_table_ATLANTIS_SEASON$max_surface_sal == 'Inf') | (summary_table_ATLANTIS_SEASON$max_surface_sal == '-Inf')] <- 'NA'

combined_table_SPECIES <- full_join(summary_table_SPECIES, atlantis_group_table)
combined_table_SPECIES <- filter(combined_table_SPECIES, !is.na(Code))
combined_table_SPECIES <- group_by(combined_table_SPECIES,Code)
summary_table_ATLANTIS_SPECIES <- summarise(combined_table_SPECIES,min_bottom_temp = min(min_bottom_temp), max_bottom_temp = max(max_bottom_temp),
min_surface_temp = min(min_surface_temp), max_surface_temp = max(max_surface_temp),
min_bottom_sal = min(min_bottom_sal), max_bottom_sal = max(max_bottom_sal),
min_surface_sal = min(min_surface_sal), max_surface_sal = max(max_surface_sal))
summary_table_ATLANTIS_SPECIES <- mutate(summary_table_ATLANTIS_SPECIES, isNA_temp=min_bottom_temp+max_bottom_temp+
min_surface_temp+max_surface_temp, isNA_sal = min_bottom_sal+max_bottom_sal+
min_surface_sal+max_surface_sal)
summary_table_ATLANTIS_SPECIES <- filter(summary_table_ATLANTIS_SPECIES,(!is.na(isNA_temp) | !is.na(isNA_sal)))
summary_table_ATLANTIS_SPECIES <- select(summary_table_ATLANTIS_SPECIES,-isNA_temp,-isNA_sal)

summary_table_ATLANTIS_SPECIES$min_bottom_sal[(summary_table_ATLANTIS_SPECIES$min_bottom_sal == 'Inf') | (summary_table_ATLANTIS_SPECIES$min_bottom_sal == '-Inf')] <- 'NA'
summary_table_ATLANTIS_SPECIES$max_bottom_sal[(summary_table_ATLANTIS_SPECIES$max_bottom_sal == 'Inf') | (summary_table_ATLANTIS_SPECIES$max_bottom_sal == '-Inf')] <- 'NA'
summary_table_ATLANTIS_SPECIES$min_surface_sal[(summary_table_ATLANTIS_SPECIES$min_surface_sal == 'Inf') | (summary_table_ATLANTIS_SPECIES$min_surface_sal == '-Inf')] <- 'NA'
summary_table_ATLANTIS_SPECIES$max_surface_sal[(summary_table_ATLANTIS_SPECIES$max_surface_sal == 'Inf') | (summary_table_ATLANTIS_SPECIES$max_surface_sal == '-Inf')] <- 'NA'

write.csv(summary_table_ATLANTIS_SEASON,"C:/Users/robert.gamble/Desktop/Env_Thresholds/SurvDat/atlantis_seasonal_thresholds.csv",row.names=FALSE)
write.csv(summary_table_ATLANTIS_SPECIES,"C:/Users/robert.gamble/Desktop/Env_Thresholds/SurvDat/atlantis_group_thresholds.csv",row.names=FALSE)
19 changes: 19 additions & 0 deletions R/surveyPull.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#' Pull survey data for envirnomental thresholds project
#'
#' Require temp, depth, salinity for each species at tow level to determine
#' observed species tolerace ranges
#'
#' @return survdat data pull list


channel <- dbutils::connect_to_database("NEFSC_USERS",username)

data <- survdat::get_survdat_data(channel = channel,
filterByYear = NA,
all.season = T,
shg.check = T,
conversion.factor = T,
use.SAD = F,
getBio = F,
getLengths = F,
getWeightLength = F)
13 changes: 13 additions & 0 deletions READ-EDAB-enviroThresholds.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
Binary file added data/surveyPull.rds
Binary file not shown.
191 changes: 191 additions & 0 deletions inputs/atlantis_codes_svspp_survey_thresholds.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
Code,Name,SVSPP
PSH,Dusky shark,3
SK,Roughtail stingray,4
SSH,Sandbar shark,9
DSH,Sand tiger,12
SMO,Smooth dogfish,13
DSH,Chain dogfish,14
DOG,Spiny dogfish,15
DSH,Atlantic angel shark,16
BLS,Blue shark,17
SK,Bluntnose stingray,18
SK,Bullnose ray,19
SK,Atlantic torpedo,21
SK,Barndoor skate,22
WSK,Winter skate,23
SK,Clearnose skate,24
SK,Rosette skate,25
LSK,Little skate,26
SK,Smooth skate,27
SK,Thorny skate,28
BPF,Round herring,31
HER,Atlantic herring,32
FDE,Alewife,33
FDE,Blueback herring,34
FDE,American shad,35
MEN,Menhaden,36
FDE,Hickory shad,37
ANC,Bay anchovy,43
ANC,Striped anchovy,44
BPF,Argentine,46
MPF,Lanternfish,56
FDF,Eel unclassified,60
FDF,Conger eel,63
OHK,Offshore hake,69
SHK,Silver hake,72
COD,Atlantic cod,73
HAD,Haddock,74
POL,Pollock,75
WHK,White hake,76
RHK,Red hake,77
FDF,Spotted hake,78
FDF,Fourbeard rockling,83
FDF,Cusk,84
FDF,Threebeard rockling,85
FDF,Grenadier unclassified,90
FDF,Roughhead grenadier,92
HAL,Atlantic halibut,101
PLA,American plaice,102
SUF,Summer flounder,103
FOU,Fourspot flounder,104
YTF,Yellowtail flounder,105
WIF,Winter flounder,106
WTF,Witch flounder,107
WPF,Windowpane flounder,108
FLA,Gulfstream flounder,109
FDF,Longspine snipefish,111
FDF,John Dory,112
BPF,Atlantic silverside,113
FDF,Threespine stickleback,115
FDF,Northern pipefish,116
FLA,Hogchoker,118
FDF,Trumpetfish,119
MAK,Atlantic mackerel,121
BPF,Chub mackerel,124
BUT,Butterfish,131
FDF,Atlantic moonfish,132
FDF,Lookdown,133
BLF,Bluefish,135
DRM,Atlantic croaker,136
STB,Striped Bass,139
BSB,Black sea bass,141
SCU,Scup,143
DRM,Weakfish,145
DRM,Northern kingfish,146
DRM,Black drum,147
DRM,Silver perch,148
DRM,Spot,149
TYL,Tilefish,151
FDF,Longspine scorpionfish,154
RED,Acadian redfish,155
FDF,Blackbelly rosefish,156
FDF,Sculpins unclassified,160
FDF,Moustache sculpin,161
FDF,Shorthorn sculpin,162
FDF,Longhorn sculpin,163
FDF,Sea raven,164
FDF,Lumpfish,168
FDF,Northern searobin,171
FDF,Striped searobin,172
FDF,Armored searobin,173
FDF,Searobin uncl,174
FDF,Cunner,176
TAU,Tautog,177
FDF,Oyster toadfish,185
FDF,Wrymouth,191
OPT,Ocean pout,193
FDF,Northern puffer,196
GOO,Goosefish,197
MPF,Weitzmans pearlsides,229
SK,Cownose ray,270
SK,Spotted eagle ray,271
NSH,Bristled longbeak,296
NSH,Aesop shrimp,297
LOB,Lobster,301
NSH,Northern shrimp other pandalids,306
OSH,Other penaeids,307
RCB,Red deep-sea crab,310
BMS,Cancer crab,311
BMS,Jonah crab,312
BMS,Atantic rock crab,313
BMS,Blue crab,314
BMS,Spider crab,317
BMS,Horseshoe crab,318
BMS,Lady crab,322
BMS,Snow crab,325
BMS,Green crab,327
BG,Benthic grazer,331
BMS,Knobbed whelk,337
BFF,Iceland scallop,340
DSH,Nurse shark,350
PSH,White shark,351
PSH,Shortfin mako,352
POR,Porbeagle shark,353
PSH,Silky shark,355
DSH,Bull shark,356
PSH,Blacktip shark,357
PSH,Tiger shark,358
DSH,Lemon shark,359
DSH,Sharpnose shark,360
DSH,Scalloped hammerhead,362
PSH,Great hammerhead,363
SK,Atlantic stingray,373
SK,Yellow stingray,377
FDF,Shortnose sturgeon,379
FDF,Atlantic sturgeon,380
SDF,American eel,384
SCA,Sea scallop,401
BFF,Bay scallop,402
CLA,Atlantic surf clam,403
BFF,Atlantic calico scallop,404
BFF,Arctic surfclam,407
QHG,Ocean quahog,409
FDF,Pipefish unclassified,421
FDE,Gizzard shad,426
FDF,Largescale lizardfish,433
FDF,Shortjaw lizardfish,434
FDF,Inshore lizardfish,435
FDF,Offshore lizardfish,437
FDF,Red lizardfish,438
FDF,Tomcod,453
FDF,Atlantic needlefish,471
FDF,Fourspine stickleback,488
FDF,Whitenose pipefish,491
FDF,Dusky pipefish,494
FDF,Chain pipefish,495
ISQ,Illex squid,502
LSQ,Loligo squid,503
BC,Octopus unclassified,510
BC,Common octopus,511
BC,Spoonarm octopus,512
BC,Unicorn octopus,513
FDF,Sand perch,530
TYL,Blueline tilefish,621
FDF,Sheepshead,631
FDF,Hogfish,682
BIL,Swordfish,700
TUN,Albacore,703
TUN,Blackfin tuna,705
TUN,Bigeye tuna,706
BIL,Blue marlin,707
BIL,White marlin,708
BPF,American sandlance,734
TUN,Little tunny,743
BFT,Atlantic bluefin tuna,747
BPF,Harvest fish,749
FDF,Lizardfish unclassified,852
SAL,Atlantic salmon,894
FDF,Blackspotted stickleback,901
FDF,Ninespine stickleback,902
OSH,Brown shrimp,913
OSH,Pink shrimp,914
OSH,White shrimp,915
DSH,Thresher shark,925
PSH,Finetooth shark,928
PSH,Blacknose shark,929
PSH,Bignose shark,929
REP,Loggerhead seaturtle,950
REP,Green seaturtle,951
REP,Leatherback seaturtle,952
REP,Hawksbill seaturtle,953
REP,Kemp's Ridley seaturtle,954
52 changes: 52 additions & 0 deletions thresholds/atlantis_group_thresholds.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"Code","min_bottom_temp","max_bottom_temp","min_surface_temp","max_surface_temp","min_bottom_sal","max_bottom_sal","min_surface_sal","max_surface_sal"
"ANC",2,29.4,0,29.9,"22.1","36.487","20.286","36.493"
"BG",6.2,24.7,9.2,28.1,"NA","NA","NA","NA"
"BLF",6.3,29.4,0,29.9,"22.1","36.389","20.356","36.574"
"BPF",1.1,28.2,0,29.76,"24.138","36.554","20.286","36.574"
"BSB",2.99,29.85,0,29.9,"27.345","36.404","23.547","36.414"
"BUT",0,29.85,0,29.76,"22.1","36.846","20.356","36.613"
"CLA",3.9,24.24,3.3,26.77,"30.189","34.754","29.387","34.624"
"COD",-1,19.2,-0.6,26.7,"26.547","35.535","24.249","34.957"
"DOG",1.1,22.91,0,28.58,"23.52","36.255","20.286","36.478"
"DRM",2.8,29.4,0,29.9,"22.1","36.62","20.356","36.613"
"FDE",0,26.78,0,27.25,"23.267","36.168","15.925","36.111"
"FLA",1.1,28.51,0,29.76,"24.655","36.846","23.231","36.613"
"FOU",0.9,26.75,0,29.76,"26.547","36.44","23.547","36.613"
"GOO",0,23.63,0,29.21,"29.705","36.342","24.249","36.478"
"HAD",0,18.96,0,27.03,"30.613","35.742","24.249","35.891"
"HAL",1.8,13.9,0,20.82,"31.056","34.96","27.148","33.873"
"HER",1.23,26.6,0,27,"23.267","36.418","15.925","36.38"
"ISQ",0,29.85,0,29.76,"27.643","36.512","23.547","36.624"
"LOB",0,24.3,0,27.4,"26.547","36.107","15.925","36.466"
"LSK",-1.4,23.45,-1.4,28.36,"23.52","35.995","15.925","36.363"
"LSQ",2.41,29.85,0,29.76,"22.1","36.875","20.615","36.624"
"MAK",0,22.53,0,27.4,"26.032","35.932","24.729","36.111"
"MEN",3.5,26.2,0,26.42,"23.52","35.344","21.177","35.325"
"MPF",2.6,27.55,0,29.76,"31.697","36.489","25.318","36.624"
"NSH",1.35,18.6,0,26.3,"30.895","35.853","24.249","36.17"
"OHK",0,17.64,0,29.76,"32.234","36.344","29.884","36.624"
"OPT",0.1,19.12,0,27.03,"26.547","35.772","15.925","36.187"
"PLA",1,16.9,0,25.2,"26.547","35.588","24.249","35.691"
"POL",1.3,18.56,0,24.3,"30.577","35.63","27.021","35.445"
"POR",11.34,11.34,12.59,12.59,"34.476","34.476","32.746","32.746"
"QHG",4.91,17.51,5.51,19.22,"32.453","34.52","31.746","33.927"
"RCB",3,14.8,0,26.67,"32.286","35.672","30.185","35.789"
"RED",1,18.53,0,26.1,"31.251","35.754","25.318","35.968"
"RHK",0,22.49,0,27.4,"25.809","36.361","15.925","36.407"
"SAL",8.7,8.7,8.4,8.4,"NA","NA","NA","NA"
"SCA",1.44,22.59,0,28.58,"29.986","36.312","24.754","36.355"
"SCU",3.35,28.51,0,29.31,"22.1","36.741","22.1","36.578"
"SDF",5.33,20.1,5.35,23.34,"26.995","35.726","25.031","34.708"
"SHK",0,24.46,0,29.76,"23.52","36.383","15.925","36.606"
"SMO",5.32,27.7,0,29.02,"26.938","36.489","20.356","36.592"
"SSH",8.1,25.67,0,28,"22.1","36.418","22.1","36.578"
"STB",1.96,20.97,0,22.54,"23.267","35.244","18.355","34.42"
"SUF",1.74,29.4,0,29.9,"22.1","36.741","20.356","36.556"
"TAU",1.7,27.7,0,28.4,"27.732","34.355","24.94","34.225"
"TYL",3.25,19.66,2,28.8,"31.032","36.359","31.017","36.43"
"WHK",1.6,25.3,0,29.13,"29.029","35.835","24.249","36.389"
"WIF",-1.4,23.12,-1.4,27,"26.547","35.459","15.925","35.679"
"WPF",-1.2,27.7,-0.9,28.7,"23.267","36.341","15.925","36.354"
"WSK",-1.4,21.88,-1.4,25.2,"24.138","36.431","15.925","36.43"
"WTF",0,18.53,0,26.73,"30.691","35.894","24.249","36.478"
"YTF",-1,19.39,-0.6,27,"26.547","35.786","15.925","35.764"
Loading

0 comments on commit 391df7d

Please sign in to comment.