Skip to content

Commit

Permalink
finalize SAU rec landings
Browse files Browse the repository at this point in the history
  • Loading branch information
MandyKarnauskas-NOAA committed Feb 8, 2024
1 parent ec5f656 commit 3fa5cc0
Show file tree
Hide file tree
Showing 29 changed files with 133,881 additions and 6,654 deletions.
9 changes: 0 additions & 9 deletions indicator_data/NCRMP_coral_cover_richness.csv

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

Downloaded 22-December-2022
Downloaded 08-February-2024

CATCH DATA, STOCK STATUS, MARINE TROPHIC INDEX, MULTINATIONAL FOOTPRINT, AND ASSOCIATED METHODS

Data version 50.0
Data version 50.1

Please note that the data (‘reconstructed data’) are a combination of official reported data and reconstructed estimates of unreported data (including major discards).

Expand Down
25 changes: 0 additions & 25 deletions indicator_data/SAU_PR/readme.txt

This file was deleted.

Binary file not shown.
Binary file not shown.
4,984 changes: 0 additions & 4,984 deletions indicator_data/SAU_USVI/SAU EEZ 850 v50-0.csv

This file was deleted.

127,173 changes: 127,173 additions & 0 deletions indicator_data/ibtracs.csv

Large diffs are not rendered by default.

76 changes: 0 additions & 76 deletions indicator_data/mrip_effort_series.csv

This file was deleted.

Binary file removed indicator_objects/.RData
Binary file not shown.
Binary file modified indicator_objects/ACEindex.RData
Binary file not shown.
Binary file added indicator_objects/DegreeHeatingWeeks.RData
Binary file not shown.
Binary file added indicator_objects/coral_spprichness_cover.RData
Binary file not shown.
Binary file added indicator_objects/fish_density.RData
Binary file not shown.
Binary file modified indicator_objects/total_rec_catch.RData
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added indicator_plots/Commercial fish density.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added indicator_plots/Coral species richness.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added indicator_plots/Total recreational catch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 15 additions & 10 deletions indicator_processing/automated_download/ACE_index_Carib.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,32 @@
# ACE index calculations done according to methods from:
# GEOPHYSICAL RESEARCH LETTERS, VOL. 38, L19702, doi:10.1029/2011GL049265, 2011

# data source: https://www.ncdc.noaa.gov/ibtracs/index.php?name=ib-v4-access
# data source: https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r00/access/csv/
# (download .csv file for N. Atlantic basin)

# specification file and libraries -----------------------------
rm(list = ls())
library(maps)
library(plotTimeSeries)

load("spec_file.RData")
#load("spec_file.RData")

# define years --------------------------------
styear <- 1961
enyear <- 2023

# download data directly from site -----------------------------
options(download.file.method="libcurl")

url <- "https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r00/access/csv/ibtracs.NA.list.v04r00.csv"
url <- "https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r00/access/csv/ibtracs.NA.list.v04r00.csv"

download.file(url = url, destfile = "../indicator_data/ibtracs.csv")
dat <- read.csv( "../indicator_data/ibtracs.csv", skip = 2, header = F)
datn <- read.csv( "../indicator_data/ibtracs.csv", skip = 0, header = T)
download.file(url = url, destfile = "C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_data/ibtracs.csv")
dat <- read.csv("C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_data/ibtracs.csv", skip = 2, header = F)
datn <- read.csv("C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_data/ibtracs.csv", skip = 0, header = T)
names(dat) <- names(datn)

# define years and cut columns --------------------------------
styear <- 1961
enyear <- terminal_year
# cut columns --------------------------------

head(dat)
dat <- dat[, 1:17]
Expand Down Expand Up @@ -111,7 +114,7 @@ nam <- unique(d2$uniq)
length(nam)

dev.off()
par(mfrow = c(7, 8), mex = 0.3)
par(mfrow = c(8, 8), mex = 0.3)
for (i in 1:length(nam)) {
map('world', add=F, fill=T, col=8, xlim=c(-72, -62), ylim=c(15, 22))
ptcol <- as.numeric(strftime(d2$tim[which(d2$uniq == nam[i])], format = "%j"))
Expand Down Expand Up @@ -149,7 +152,9 @@ indnames <- data.frame(matrix(labs, nrow = 3, byrow = F))
s <- list(labels = indnames, indicators = inddata, datelist = datdata) #, ulim = ulidata, llim = llidata)
class(s) <- "indicatordata"

plotIndicatorTimeSeries(s)
setwd("C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_plots/")

plotIndicatorTimeSeries(s, widadj = 0.5, outtype = "png")

inddata <- s
save(inddata, file = "C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_objects/ACEindex.RData")
Expand Down
5 changes: 4 additions & 1 deletion indicator_processing/automated_download/DHW.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
rm(list = ls())
options(download.file.method="libcurl")

styear <- 2012
enyear <- 2023

# download data and calculate mean -------------------

for (i in 1:2) {
Expand All @@ -13,7 +16,7 @@ for (i in 1:2) {
download.file(url = url, destfile = "C:/Users/mandy.karnauskas/Downloads/dhw.txt")
d <- read.table("C:/Users/mandy.karnauskas/Downloads/dhw.txt", skip = 21, header = T)

d <- d[which(d$YYYY >=1985 & d$YYYY <= 2021), ]
d <- d[which(d$YYYY >= styear & d$YYYY <= 2023), ]

head(d)
d$yrmon <- paste0(d$YYYY, sprintf("%02.f", d$MM))
Expand Down
6 changes: 5 additions & 1 deletion indicator_processing/automated_download/sst.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ rm(list = ls())
#devtools::install_github("mdsumner/ncdf4")
#library(ncdf4)

# define years --------------------------------
styear <- 1982
enyear <- 2023

# empty data -------------------------------------------------
dat <- data.frame(row.names = c("year", "mon", "PR_mean", "PR_min", "PR_max", "VI_mean", "VI_min", "VI_max"))

# download by year to avoid timeout errors --------------------
for (yr in 1982:2021) {
for (yr in styear:enyear) {

# url from ERDDAP for OISST, download and read ----------------
url <- paste0("https://coastwatch.pfeg.noaa.gov/erddap/griddap/ncdcOisst21Agg.csv?sst[(", yr, "-01-01T12:00:00Z):1:(", yr, "-12-31T12:00:00Z)][(0.0):1:(0.0)][(17):1:(19)][(292):1:(296)]")
Expand Down
140 changes: 140 additions & 0 deletions indicator_processing/non_automated/CRMP_compile.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@

## compile TCRMP and PRCRMP into data plots
## M. Karnauskas 2/8/2024
#
# run PRCRMP_benthic.R, TCRMP_benthic.R, PRCRMP_fish.R and TCRMP_fish.R first
#

rm(list = ls())

library(plotTimeSeries)

# load coral indicator data -------------------------

setwd("C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_data/")

load("PRCRMP/coralspprich_PR.RData")
PRsr <- out1
load("PRCRMP/percoralcov_PR.RData")
PRcc <- out1
load("TCRMP/coralspprich_USVI.RData")
VIsr <- out1
load("TCRMP/percoralcov_USVI.RData")
VIcc <- out1

# extract years from linear mixed model ----------------------

y1 <- as.numeric(gsub("YEAR", "", rownames(summary(PRsr)$coef)))
y2 <- as.numeric(gsub("YEAR", "", rownames(summary(PRcc)$coef)))
y3 <- as.numeric(gsub("SampleYear", "", rownames(summary(VIsr)$coef)))
y4 <- as.numeric(gsub("SampleYear", "", rownames(summary(VIcc)$coef)))

y1 == y2
y3 == y4
yrs <- (min(c(y1, y2, y3, y4))) : (max(c(y1, y2, y3, y4)))

# extract coefficients from linear mixed model ----------------------

mat <- data.frame(matrix(data = NA, nrow = length(yrs), ncol = 4))
rownames(mat) <- yrs
mat[match(y1, yrs), 1] <- summary(PRsr)$coef[, 1]
mat[match(y2, yrs), 2] <- summary(PRcc)$coef[, 1]
mat[match(y3, yrs), 3] <- summary(VIsr)$coef[, 1]
mat[match(y4, yrs), 4] <- summary(VIcc)$coef[, 1]

matse <- data.frame(matrix(data = NA, nrow = length(yrs), ncol = 4))
rownames(matse) <- yrs
matse[match(y1, yrs), 1] <- summary(PRsr)$coef[, 2]
matse[match(y2, yrs), 2] <- summary(PRcc)$coef[, 2]
matse[match(y3, yrs), 3] <- summary(VIsr)$coef[, 2]
matse[match(y4, yrs), 4] <- summary(VIcc)$coef[, 2]

# format indicator object --------------------

datdata <- yrs
inddata <- data.frame(mat)
ulidata <- data.frame(mat + matse)
llidata <- data.frame(mat - matse)
labs <- c("Coral species richness" , "average number per transect", "Puerto Rico",
"Percent coral cover" , "percent cover", "Puerto Rico",
"Coral species richness" , "average number per transect", "USVI",
"Percent coral cover" , "percent cover", "USVI")
indnames <- data.frame(matrix(labs, nrow = 3, byrow = F))
s <- list(labels = indnames, indicators = inddata, datelist = datdata, ulim = ulidata, llim = llidata)
class(s) <- "indicatordata"

setwd("C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_plots/")

plotIndicatorTimeSeries(s, coltoplot = 1:4, plotrownum = 2, sublabel = T, sameYscale = F,
widadj = 1, hgtadj = 1, trendAnalysis = T, type = "allLines", CItype = "band", outtype = "png")

inddata <- s
save(inddata, file = "C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_objects/coral_spprichness_cover.RData")



## compile TCRMP and PRCRMP into data plots
## M. Karnauskas 2/8/2024
#
# run PRCRMP_benthic.R, TCRMP_benthic.R, PRCRMP_fish.R and TCRMP_fish.R first
#

rm(list = ls())

library(plotTimeSeries)

# load fish indicator data -------------------------

setwd("C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_data/")

load("PRCRMP/fish_density_PR.RData")
PR <- fin
load("TCRMP/fish_density_USVI.RData")
VI <- findens
load("TCRMP/slopeSizeSpec_USVI.RData")
sl <- fin

# extract years ----------------------

PR$yrs == VI$yrs
PR$yrs == sl$yrs
yrs <- (min(c(PR$yrs, VI$yrs, sl$yrs))) : (max(c(PR$yrs, VI$yrs, sl$yrs)))

# extract coefficients from linear mixed model ----------------------

mat <- data.frame(matrix(data = NA, nrow = length(yrs), ncol = 3))
rownames(mat) <- yrs
mat[match(PR$yrs, yrs), 1] <- PR$ind_norm
mat[match(VI$yrs, yrs), 2] <- VI$ind_norm
mat[match(sl$yrs, yrs), 3] <- sl$stind

matse <- data.frame(matrix(data = NA, nrow = length(yrs), ncol = 3))
rownames(matse) <- yrs
matse[match(PR$yrs, yrs), 1] <- PR$indse_norm
matse[match(VI$yrs, yrs), 2] <- VI$indse_norm
matse[match(sl$yrs, yrs), 3] <- sl$stindse

# format indicator object --------------------

datdata <- yrs
inddata <- data.frame(mat)
ulidata <- data.frame(mat + matse)
llidata <- data.frame(mat - matse)
labs <- c("Commercial fish density" , "average number per transect", "Puerto Rico",
"Commercial fish density" , "average number per transect", "USVI",
"Slope of the size spectrum" , "slope of log distribution", "USVI")
indnames <- data.frame(matrix(labs, nrow = 3, byrow = F))
s <- list(labels = indnames, indicators = inddata, datelist = datdata, ulim = ulidata, llim = llidata)
class(s) <- "indicatordata"

setwd("C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_plots/")

plotIndicatorTimeSeries(s, coltoplot = 1:3, plotrownum = 3, sublabel = T, sameYscale = F,
widadj = 1, hgtadj = 1, trendAnalysis = T, type = "allLines", CItype = "band", outtype = "png")

inddata <- s
save(inddata, file = "C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_objects/fish_density.RData")

######################### END ############################


Loading

0 comments on commit 3fa5cc0

Please sign in to comment.