Skip to content

Commit

Permalink
nekton index to fw5, replace old fim plot
Browse files Browse the repository at this point in the history
  • Loading branch information
fawda123 committed Jun 4, 2024
1 parent 2184577 commit 5a2ca2d
Show file tree
Hide file tree
Showing 17 changed files with 13,867 additions and 64 deletions.
126 changes: 67 additions & 59 deletions R/dat_proc.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,65 +74,73 @@ sgdat <- sgdat |>

save(sgdat, file = here::here('data/sgdat.RData'))

# FIM data from FTP ---------------------------------------------------------------------------

ftp_url <- "ftp://ftp.floridamarine.org/users/fim/DataMgt/Inshore_SAS_Data/FIM_inshore_SAS_database_library_20240222.zip"

temp_dir <- tempdir()

# Download the zip file from FTP to temporary directory
temp_file <- paste0(temp_dir, "/", basename(ftp_url))
download.file(url = ftp_url, destfile = temp_file, mode = "wb", quiet = FALSE)

# Unzip the file
unzip(temp_file, exdir = temp_dir)

# extracted file path
file_path <- paste0(temp_dir, "/", gsub('\\.zip$', '/', basename(ftp_url)))

# import original SAS data
phyraw <- read_sas(paste0(file_path, 'tbm_physical.sas7bdat'))
bioraw <- read_sas(paste0(file_path, 'tbm_biology_number.sas7bdat'))
sppraw <- read_sas(paste0(file_path, 'species_codes.sas7bdat'))

unlink(temp_dir, recursive = TRUE)

# physical (site) data
# filter zones A-E for TB proper
# filter gear type 20 (21.3-m seine)
# filter by stratum (if wanted) to return shoreline ('S') and/or offshore (>5 m from shore, 'A','B'), we can include both, but will need to add to methods section
# filter reference with loc info
# filter by project "AM" to return standard monitoring sites, others are special projects - may not change the output much
phydat <- phyraw |>
mutate(
date = ymd(date)
) |>
filter(Zone %in% c('A', 'B', 'C', 'D', 'E')) |>
#filter(Project =='AM')
filter(Gear == 20) |>
#filter (Stratum %in% c('A','B')) |>
select(Reference, date)

# species codes
sppdat <- sppraw |>
select(NODCCODE, Commonname)

# species count data
biodat <- bioraw |>
select(Reference, Species_record_id, NODCCODE, Number) |>
left_join(sppdat, by = 'NODCCODE')

# filter by species of interest
sppdat <- biodat |>
filter(Commonname %in% c('Pink Shrimp', 'Red Drum', 'Spotted Seatrout')) |>
select(Reference, Number, Commonname)

# join all an create complete
fimdat <- left_join(phydat, sppdat, by = 'Reference', relationship = 'one-to-many') |>
complete(Commonname, nesting(Reference, date), fill = list(Number = 0)) |>
na.omit()

save(fimdat, file = here('data/fimdat.RData'))
# nekton data ---------------------------------------------------------------------------------

data('fimdata', package = 'tbeptools')

tbniscr <- anlz_tbniscr(fimdata)

save(tbniscr, file = here::here('data/tbniscr.RData'))

# # FIM data from FTP ---------------------------------------------------------------------------
#
# ftp_url <- "ftp://ftp.floridamarine.org/users/fim/DataMgt/Inshore_SAS_Data/FIM_inshore_SAS_database_library_20240222.zip"
#
# temp_dir <- tempdir()
#
# # Download the zip file from FTP to temporary directory
# temp_file <- paste0(temp_dir, "/", basename(ftp_url))
# download.file(url = ftp_url, destfile = temp_file, mode = "wb", quiet = FALSE)
#
# # Unzip the file
# unzip(temp_file, exdir = temp_dir)
#
# # extracted file path
# file_path <- paste0(temp_dir, "/", gsub('\\.zip$', '/', basename(ftp_url)))
#
# # import original SAS data
# phyraw <- read_sas(paste0(file_path, 'tbm_physical.sas7bdat'))
# bioraw <- read_sas(paste0(file_path, 'tbm_biology_number.sas7bdat'))
# sppraw <- read_sas(paste0(file_path, 'species_codes.sas7bdat'))
#
# unlink(temp_dir, recursive = TRUE)
#
# # physical (site) data
# # filter zones A-E for TB proper
# # filter gear type 20 (21.3-m seine)
# # filter by stratum (if wanted) to return shoreline ('S') and/or offshore (>5 m from shore, 'A','B'), we can include both, but will need to add to methods section
# # filter reference with loc info
# # filter by project "AM" to return standard monitoring sites, others are special projects - may not change the output much
# phydat <- phyraw |>
# mutate(
# date = ymd(date)
# ) |>
# filter(Zone %in% c('A', 'B', 'C', 'D', 'E')) |>
# #filter(Project =='AM')
# filter(Gear == 20) |>
# #filter (Stratum %in% c('A','B')) |>
# select(Reference, date)
#
# # species codes
# sppdat <- sppraw |>
# select(NODCCODE, Commonname)
#
# # species count data
# biodat <- bioraw |>
# select(Reference, Species_record_id, NODCCODE, Number) |>
# left_join(sppdat, by = 'NODCCODE')
#
# # filter by species of interest
# sppdat <- biodat |>
# filter(Commonname %in% c('Pink Shrimp', 'Red Drum', 'Spotted Seatrout')) |>
# select(Reference, Number, Commonname)
#
# # join all an create complete
# fimdat <- left_join(phydat, sppdat, by = 'Reference', relationship = 'one-to-many') |>
# complete(Commonname, nesting(Reference, date), fill = list(Number = 0)) |>
# na.omit()
#
# save(fimdat, file = here('data/fimdat.RData'))

# epc ph data ---------------------------------------------------------------------------------

Expand Down
27 changes: 27 additions & 0 deletions _site/site_libs/crosstalk-1.1.1/css/crosstalk.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Adjust margins outwards, so column contents line up with the edges of the
parent of container-fluid. */
.container-fluid.crosstalk-bscols {
margin-left: -30px;
margin-right: -30px;
white-space: normal;
}

/* But don't adjust the margins outwards if we're directly under the body,
i.e. we were the top-level of something at the console. */
body > .container-fluid.crosstalk-bscols {
margin-left: auto;
margin-right: auto;
}

.crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column {
display: inline-block;
padding-right: 12px;
vertical-align: top;
}

@media only screen and (max-width:480px) {
.crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column {
display: block;
padding-right: inherit;
}
}
Loading

0 comments on commit 5a2ca2d

Please sign in to comment.