diff --git a/.Rhistory b/.Rhistory index 098ff20..41239ad 100644 --- a/.Rhistory +++ b/.Rhistory @@ -1,38 +1,4 @@ datdata <- 2001:2021 -inddata <- data.frame(cbind(RUVdensity_PRICO_BAL_VETU$species_data.density, RUVdensity_PRICO_EPI_GUTT$species_data.density, RUVdensity_PRICO_LUT_ANAL$species_data.density, RUVdensity_PRICO_OCY_CHRY$species_data.density, RUVdensity_PRICO_SPA_AURO$species_data.density, RUVdensity_PRICO_SPA_VIRI$species_data.density)) -labs <- c("PR" , "Density", "queen triggerfish", -"PR" , "Density", "red hind", -"PR" , "Density", "mutton snapper", -"PR" , "Density", "yellowtail snapper", -"PR" , "Density", "redband parrotfish", -"PR" , "Density", "stoplight parrotfish") -indnames <- data.frame(matrix(labs, nrow = 6, byrow = F)) -inddata <- list(labels = indnames, indicators = inddata, datelist = datdata) -class(inddata) <- "indicatordata" -save(inddata, file = "indicator_objects/RVC_PR.RData") -View(RUVdensity_PRICO_SPA_VIRI) -View(RUVdensity_PRICO_SPA_VIRI) -load("../indicator_objects/RVC_PR.RData") -plotIndicatorTimeSeries(inddata, coltoplot = 1:6, trendAnalysis = T, sublabel = T) -load("../indicator_objects/landings.RData") -load("../indicator_objects/RVC_PR.RData") -load("../indicator_objects/landings.RData") -load("../indicator_objects/fish_density.RData") -# Puerto Rico -datdata <- 2001:2021 -inddata <- data.frame(cbind(RUVdensity_PRICO_BAL_VETU$species_data.density, RUVdensity_PRICO_EPI_GUTT$species_data.density, RUVdensity_PRICO_LUT_ANAL$species_data.density, RUVdensity_PRICO_OCY_CHRY$species_data.density, RUVdensity_PRICO_SPA_AURO$species_data.density, RUVdensity_PRICO_SPA_VIRI$species_data.density)) -labs <- c("PR" , "Density", "queen triggerfish", -"PR" , "Density", "red hind", -"PR" , "Density", "mutton snapper", -"PR" , "Density", "yellowtail snapper", -"PR" , "Density", "redband parrotfish", -"PR" , "Density", "stoplight parrotfish") -indnames <- data.frame(matrix(labs, nrow = 3, byrow = F)) -inddata <- list(labels = indnames, indicators = inddata, datelist = datdata) -class(inddata) <- "indicatordata" -save(inddata, file = "indicator_objects/RVC_PR.RData") -# St. Thomas & St. John -datdata <- 2001:2021 inddata <- data.frame(cbind(RUVdensity_STTSTJ_BAL_VETU$species_data.density, RUVdensity_STTSTJ_EPI_GUTT$species_data.density, RUVdensity_STTSTJ_LUT_ANAL$species_data.density, RUVdensity_STTSTJ_OCY_CHRY$species_data.density, RUVdensity_STTSTJ_SPA_AURO$species_data.density, RUVdensity_STTSTJ_SPA_VIRI$species_data.density)) labs <- c("STTSTJ" , "Density", "queen triggerfish", "STTSTJ" , "Density", "red hind", @@ -510,3 +476,37 @@ rm(list = ls()) library(plotTimeSeries) directory <- rprojroot::find_rstudio_root_file() plot(1) +rm(list = ls()) +directory <- rprojroot::find_rstudio_root_file() +setwd(directory) +dir("indicator_objects") +library(plotTimeSeries) +library(spam) +load("DegreeHeatingWeeks.RData") +# load libraries --------------------------------- +rm(list = ls()) +library(plotTimeSeries) +directory <- rprojroot::find_rstudio_root_file() +setwd(directory) +dir("indicator_objects") +load("DegreeHeatingWeeks.RData") +setwd(directory) +dir("indicator_objects") +load("indicator_objects/DegreeHeatingWeeks.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:2, trendAnalysis = T, sublabel = T, dateformat = "%Y%m", plotrownum = 2, plotcolnum = 1) +rm(list = ls()) +directory <- rprojroot::find_rstudio_root_file() +setwd(directory) +library(plotTimeSeries) +library(spam) +load("indicator_objects/DegreeHeatingWeeks.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:2, trendAnalysis = T, sublabel = T, dateformat = "%Y%m", plotrownum = 2, plotcolnum = 1) +load("../indicator_objects/OA.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = T) +load("../indicator_objects/ACEindex.RData") +load("indicator_objects/OA.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = T) +load("indicator_objects/ACEindex.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = T) +load("indicator_objects/Sargassum.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = T) diff --git a/indicator_objects/PlotAllIndicators.R b/indicator_objects/PlotAllIndicators.R new file mode 100644 index 0000000..f0a2a45 --- /dev/null +++ b/indicator_objects/PlotAllIndicators.R @@ -0,0 +1,189 @@ +# +# script to plot ALL indicators for report - DRAFT, STILL WORKING ON +# C. Gervasi Jun 6 2024 + +rm(list = ls()) + +# find root directory for project --------------- + +directory <- rprojroot::find_rstudio_root_file() +setwd(directory) + + +library(plotTimeSeries) +library(spam) + +### 1. Degree heating weeks + +load("indicator_objects/DegreeHeatingWeeks.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:2, trendAnalysis = T, sublabel = T, dateformat = "%Y%m", plotrownum = 2, plotcolnum = 1) + +### 2. Ocean acidification via aragonite saturation state + +load("indicator_objects/OA.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = T) + +### 3. Hurricane activity + +load("indicator_objects/ACEindex.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = T) + +### 4. Turbidity + +load("indicator_objects/turbidity.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:3, plotrownum = 2, trendAnalysis = T, dateformat = "%m-%Y", sublabel = T) + +### 5. Sea surface temperature + +load("indicator_objects/Carib_SST.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:3, trendAnalysis = T, sublabel = T, dateformat = "%m-%Y") + +### 6. Marine debris + +load("indicator_objects/marine_debris.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = F) + +### 7. Identified point source pollution sites + +load("indicator_objects/pollution.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:2, trendAnalysis = F, sublabel = T) + +### 8. Primary productivity via ocean color + +load("indicator_objects/carib_Chl.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = T, dateformat = "%m-%Y") + +### 9. Coastal development via land cover + +# Just a figure + +### 10. Number of major earthquakes + +load("indicator_objects/earthquakes.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = T) + +### 11. Fishery/market disturbance indicator + +load("indicator_objects/disturbance.RData") +plotIndicatorTimeSeries(inddata, coltoplot = 1:3, trendAnalysis = T, sublabel = T) + +### 12. Sargassum inundation + +load("indicator_objects/Sargassum.RData") +plotIndicatorTimeSeries(ind, trendAnalysis = T) + +### 13. Tourism via hotel occupancy + +load("indicator_objects/hotel_occupancy_rates_USVI_and_PR.RData") +plotIndicatorTimeSeries(inddata, coltoplot = 1:2, sublabel = T, trendAnalysis = T, dateformat = "%Y%b") + +load("indicator_objects/hotel_occupancy.RData") +plotIndicatorTimeSeries(inddata, coltoplot = 1:2, sublabel = T, trendAnalysis = T,dateformat = "%Y%b") + ### 14. Population change + +#14 - MAPS but also should be census data + +### 15. Fishery independent surveys of economically important species + +load("../indicator_objects/RVC_PR.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:6, trendAnalysis = T, sublabel = T) + +load("../indicator_objects/RVC_STSJ.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:6, trendAnalysis = T, sublabel = T) + +load("../indicator_objects/RVC_STX.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:6, trendAnalysis = T, sublabel = T) + +#Indicator 16.1 - abundance of commercial fish based on TCRMP and PRCRMP + +#Indicator 16.2 - slope of the size spectrum based on TCRMP and PRCRMP + +### 17. Commercial landings + +load("../indicator_objects/landings.RData") +plotIndicatorTimeSeries(inddata, coltoplot = 1:6, trendAnalysis = T, sublabel = T) + +load("../indicator_objects/fish_density.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:3, plotrownum = 2, trendAnalysis = T, sublabel = T) + +### 18. Pelagic:demersal ratio + +#Indicator 18 + +### 19 Maximum length and size structure + +#Indicator 19 - Lmax indicator + +### 20. Changes in target species / landing composition + +load("../indicator_objects/total_landings.RData") +plotIndicatorTimeSeries(inddata, coltoplot = 1:9, plotrownum = 3, plotcolnum = 3, trendAnalysis = T, sublabel = T) + +### 21. Total, lobster and conch revenues + +# Just figures + +### 22. Total, lobster and conch trips + +# Indicator 22 - number of trips + +### 23. Ocean economy employment and wages + +load("../indicator_objects/OceanNAICS.RData") +plotIndicatorTimeSeries(inddata, coltoplot = 1:8, plotrownum = 2, trendAnalysis = T, sublabel = T) + +### 24. GDP + +load("../indicator_objects/GDP.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:2, trendAnalysis = T, sublabel = T) + +### 25. Unemployment + +load("../indicator_objects/unemployment.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:2, trendAnalysis = T, sublabel = T, dateformat = "%Y%b") + +### 26. Gini coefficient for distribution of landings and revenue + +load("../indicator_objects/gini.RData") +plotIndicatorTimeSeries(inddata, coltoplot = 1:3, plotrownum = 2, trendAnalysis = T, sublabel = T) + +### 27. Commercial fishing community engagement and reliance + +# Indicator 27 - working with Tarsila on + +### 28. Recreational fishing engagement and participation + +load("../indicator_objects/total_rec_catch.RData") +plotIndicatorTimeSeries(inddata, coltoplot = 1:2, trendAnalysis = T, sublabel = T) + +### 29. Commercial fishing engagement and participation + +# Indicator 29 + +### 30. Changes in gear type + +# Just plots + +### 31. Number of seasonal closures implemented + +#Indicator 31 + +### 32. Number of education and outreach events + +#Indicator 32 + +### 33. Number of enforcement actions + +#Indicator 33 + +### 34 Percent coral cover + +load("../indicator_objects/NCRMP_coral_cover_richness.RData") +plotIndicatorTimeSeries(inddata, coltoplot = 1:6, sublabel = T, trendAnalysis = F) + +### 35. Coral species diversity + +load("../indicator_objects/coral_spprichness_cover.RData") +plotIndicatorTimeSeries(ind, coltoplot = 1:4, sublabel = T, trendAnalysis = T) + + \ No newline at end of file diff --git a/indicator_processing/CalculateAllIndicators.R b/indicator_processing/CalculateAllIndicators.R index ccc51fa..b20f4ab 100644 --- a/indicator_processing/CalculateAllIndicators.R +++ b/indicator_processing/CalculateAllIndicators.R @@ -84,3 +84,7 @@ enyear <- terminal_year save(ind, file = "indicator_objects/INDICATOR_NAME.RData") ## + + + + diff --git a/indicator_processing/PlotAllIndicators.R b/indicator_processing/PlotAllIndicators.R deleted file mode 100644 index 72223a7..0000000 --- a/indicator_processing/PlotAllIndicators.R +++ /dev/null @@ -1,87 +0,0 @@ -# -# script to plot ALL indicators for report -# C. Gervasi Jun 6 2024 - -# load libraries --------------------------------- -rm(list = ls()) - -library(plotTimeSeries) - -# find root directory for project --------------- - -directory <- rprojroot::find_rstudio_root_file() - -# source all .RData files in indicator_objects folder -------------- - -# run all scripts in folder --------------------- - -setwd(directory) -dir("indicator_objects") - -# fully automated - pull from internet ---------- - -#source("sst.RData") # sea surface temperature -source("ACEindex.RData") # hurricane energy index -source("carib_Chl.RData") # primary productivity -source("DegreeHeatingWeeks.RData") # degree heating weeks -source("earthquakes.RData") # earthquakes -#source("kd490.R") # turbidity from Kd490 # THIS DOWNLOAD CAN BE FINICKY -source("unemployment.RData") # unemployment rate -source("GDP.RData") # Gross Domestic Product - -# partially automated - pull from data in folder ---------------------- - -source("marine_debris.RData") # marine debris -source("OA.RData") # ocean acidification -source("indicator_processing/non_automated/CRMP_compile.R") # fishery-indepenedent fish density, slope of size spectrum, coral cover indicators -source("indicator_processing/non_automated/Sargassum_inundation.R") # sargassum indicator -source("indicator_processing/non_automated/SAU_recreational_catch.R") # recreational catch based on Sea Around Us database -source("indicator_processing/non_automated/pollution.R") # reported superfund sites etc. - -# fishery indicators - includes confidential data ---------------------- - -confpath <- "C:/Users/mandy.karnauskas/Desktop/CONFIDENTIAL/CaribbeanData/" - -dir("indicator_processing/fishery_dependent/") - -source("indicator_processing/fishery_dependent/INDICATOR_total_landings.R") # calc total landings by group -source("indicator_processing/fishery_dependent/INDICATOR_gearchanges.R") # produces plots but no indicator objects -source("indicator_processing/fishery_dependent/INDICATOR_gini.R") # calculate gini index based on revenues -# not done below - -# -source("indicator_processing/fishery_dependent/INDICATOR_disturbance.R") # -source("indicator_processing/fishery_dependent/INDICATOR_fishery_indicators_PR.R") # -source("indicator_processing/fishery_dependent/INDICATOR_fishery_indicators_STT.R") # -source("indicator_processing/fishery_dependent/INDICATOR_fishery_indicators_STX.R") # - - - - - -############################################################### - -# Notes for standardizing scripts: - -# Top: - -# specification file and libraries ----------------------------- -rm(list = ls()) -dev.off() - -library(maps) -library(plotTimeSeries) - -load("../spec_file.RData") - -# define years -------------------------------- -styear <- 1961 -enyear <- terminal_year - - -# Bottom: -# save all indicators as "ind" object - -save(ind, file = "../../indicator_objects/INDICATOR_NAME.RData") - -##