Skip to content

Commit

Permalink
fix file paths to work with main dir
Browse files Browse the repository at this point in the history
  • Loading branch information
MandyKarnauskas-NOAA committed May 16, 2024
1 parent c5c45d5 commit 3fb83e7
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 414,341 deletions.
10 changes: 10 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# load libraries ---------------------------------
rm(list = ls())
library(plotTimeSeries)
directory <- rprojroot::find_rstudio_root_file()
setwd(directory)
plot(1)
setwd(directory)
setwd("indicator_processing/non_automated")
dir()
source("RVC.R")
414,277 changes: 0 additions & 414,277 deletions chl.csv

This file was deleted.

Binary file modified indicator_objects/GDP.RData
Binary file not shown.
Binary file modified indicator_objects/pollution.RData
Binary file not shown.
Binary file added indicator_objects/total_rec_catch.RData
Binary file not shown.
Binary file removed indicator_objects/turbidity.RData
Binary file not shown.
Binary file modified indicator_objects/unemployment.RData
Binary file not shown.
45 changes: 17 additions & 28 deletions indicator_processing/CalculateAllIndicators.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,35 @@ directory <- rprojroot::find_rstudio_root_file()

# first process automated downloads --------------

setwd(directory)


# run all scripts in folder ---------------------

plot(1)

# fully automated - pull from internet ----------

setwd(directory)
setwd("indicator_processing/automated_download/")
dir()

source("ACE_index_Carib.R") # hurricane energy index
source("chl_caribbean.R") # primary productivity
source("DHW.R") # degree heating weeks
source("earthquakes.R") # earthquakes
source("kd490.R") # turbidity from Kd490
source("sst.R") # sea surface temperature
source("Unemployment.R") # unemployment rate
source("GDP.R") # Gross Domestic Product

# pull from data in folder ----------------------

setwd(directory)
setwd("indicator_processing/non_automated")
dir()

source("marine_debris.R") # marine debris
source("OA.R") # ocean acidification
source("CRMP_compile.R") # fishery-indepenedent fish density, slope of size spectrum, coral cover indicators
dir("indicator_processing/automated_download/")

source("Sargassum_inundation.R") # sargassum indicator
source("indicator_processing/automated_download/sst.R") # sea surface temperature
source("indicator_processing/automated_download/ACE_index_Carib.R") # hurricane energy index
source("indicator_processing/automated_download/chl_caribbean.R") # primary productivity
source("indicator_processing/automated_download/DHW.R") # degree heating weeks
source("indicator_processing/automated_download/earthquakes.R") # earthquakes
source("indicator_processing/automated_download/kd490.R") # turbidity from Kd490 # THIS DOWNLOAD CAN BE FINICKY
source("indicator_processing/automated_download/Unemployment.R") # unemployment rate
source("indicator_processing/automated_download/GDP.R") # Gross Domestic Product

# partially automated - pull from data in folder ----------------------

dir("indicator_processing/non_automated")

source("indicator_processing/non_automated/marine_debris.R") # marine debris
source("indicator_processing/non_automated/OA.R") # 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.

source("SAU_recreational_catch.R")
source("pollution.R")
source("RVC.R")


###############################################################
Expand Down
4 changes: 2 additions & 2 deletions indicator_processing/automated_download/ACE_index_Carib.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dev.off()
library(maps)
library(plotTimeSeries)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")

# define years --------------------------------
styear <- 1961
Expand Down Expand Up @@ -158,7 +158,7 @@ class(s) <- "indicatordata"
plotIndicatorTimeSeries(s, widadj = 0.5)

ind <- s
save(ind, file = "../../indicator_objects/ACEindex.RData")
save(ind, file = "indicator_objects/ACEindex.RData")

#################################################################################

Expand Down
4 changes: 2 additions & 2 deletions indicator_processing/automated_download/DHW.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dev.off()
library(maps)
library(plotTimeSeries)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")

options(download.file.method="libcurl")

Expand Down Expand Up @@ -65,7 +65,7 @@ class(ind) <- "indicatordata"

# save and plot -----------------------------------

save(ind, file = "../../indicator_objects/DegreeHeatingWeeks.RData")
save(ind, file = "indicator_objects/DegreeHeatingWeeks.RData")

plotIndicatorTimeSeries(ind, coltoplot = 1:2, plotrownum = 2, sublabel = T, dateformat = "%Y%m", yposadj = 0.7,
sameYscale = T, type = "allLines")
Expand Down
2 changes: 1 addition & 1 deletion indicator_processing/automated_download/GDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ library(maps)
library(plotTimeSeries)
library(rvest)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")

# data download --------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions indicator_processing/automated_download/Unemployment.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dev.off()
library(maps)
library(plotTimeSeries)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")


# load data -------------------------------------
Expand Down Expand Up @@ -65,7 +65,7 @@ class(inddata) <- "indicatordata"
ind <- inddata
plotIndicatorTimeSeries(ind, plotrownum = 2, coltoplot = 1:2, sublabel = TRUE, dateformat = "%Y%b", trendAnalysis = T)

save(ind, file = "../../indicator_objects/unemployment.RData")
save(ind, file = "indicator_objects/unemployment.RData")

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

4 changes: 2 additions & 2 deletions indicator_processing/automated_download/chl_caribbean.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dev.off()
library(maps)
library(plotTimeSeries)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")

# download data ------------------------------------------------

Expand Down Expand Up @@ -63,7 +63,7 @@ class(s) <- "indicatordata"
# save and plot ------------------------------------------------------

ind <- s
save(ind, file = "../../indicator_objects/carib_Chl.RData")
save(ind, file = "indicator_objects/carib_Chl.RData")

plotIndicatorTimeSeries(ind, dateformat = "%m-%Y", sublabel = T, trendAnalysis = T, anom = "mon",
widadj = 0.7, hgtadj = 0.8, type = "allLines")
Expand Down
4 changes: 2 additions & 2 deletions indicator_processing/automated_download/earthquakes.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ library(plotTimeSeries)
library(xml2)
library(rvest)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")


# download data directly from site -----------------------------
Expand Down Expand Up @@ -71,7 +71,7 @@ class(ind) <- "indicatordata"

plotIndicatorTimeSeries(ind)

save(ind, file = "../../indicator_objects/earthquakes.RData")
save(ind, file = "indicator_objects/earthquakes.RData")

#################################################################################

Expand Down
4 changes: 2 additions & 2 deletions indicator_processing/automated_download/kd490.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dev.off()
library(maps)
library(plotTimeSeries)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")

# define urls --------------------------------

Expand Down Expand Up @@ -83,7 +83,7 @@ class(ind) <- "indicatordata"

# save and plot ---------------------------------------

save(ind, file = "../../indicator_objects/turbidity.RData")
save(ind, file = "indicator_objects/turbidity.RData")

plotIndicatorTimeSeries(ind, coltoplot = 1:3, plotrownum = 3, dateformat = "%m-%Y", sublabel = T, trendAnalysis = F, widadj = 1.5)
plotIndicatorTimeSeries(ind, coltoplot = 1:3, plotrownum = 3, dateformat = "%m-%Y", sublabel = T, trendAnalysis = F, widadj = 1.5, anom = "mon")
Expand Down
4 changes: 2 additions & 2 deletions indicator_processing/automated_download/sst.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dev.off()
library(maps)
library(plotTimeSeries)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")

# devtools::install_github("mdsumner/ncdf4")
# library(ncdf4)
Expand Down Expand Up @@ -81,7 +81,7 @@ ind <- s

# save and plot ---------------------------------------

save(ind, file = "../../indicator_objects/Carib_SST.RData")
save(ind, file = "indicator_objects/Carib_SST.RData")

plotIndicatorTimeSeries(ind, coltoplot = 1:3, plotrownum = 3, dateformat = "%m-%Y", sublabel = T,
trendAnalysis = T, widadj = 0.5, anom = "mon", type = "allLines") # outtype = "png", hgtadj = 0.8)
Expand Down
Empty file.
7 changes: 3 additions & 4 deletions indicator_processing/non_automated/CRMP_compile.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
rm(list = ls())
dev.off()

directory <- rprojroot::find_rstudio_root_file()

setwd(directory)
dir()
#directory <- rprojroot::find_rstudio_root_file()
#setwd(directory)
#dir()

library(plotTimeSeries)

Expand Down
6 changes: 3 additions & 3 deletions indicator_processing/non_automated/OA.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ dev.off()
library(maps)
library(plotTimeSeries)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")

dat <- read.table("../../indicator_data/surface_omega_series.txt", skip = 0, header = F)
dat <- read.table("indicator_data/surface_omega_series.txt", skip = 0, header = F)

head(dat)
tail(dat)
Expand All @@ -43,6 +43,6 @@ plotIndicatorTimeSeries(s)

ind <- s

save(ind, file = "../../indicator_objects/OA.RData")
save(ind, file = "indicator_objects/OA.RData")


15 changes: 11 additions & 4 deletions indicator_processing/non_automated/SAU_recreational_catch.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
#
####################################################################

# specification file and libraries -----------------------------
rm(list = ls())
dev.off()

library(maps)
library(plotTimeSeries)

load("indicator_processing/spec_file.RData")

styear <- 1995

# load data -------------------------------------
d <- read.csv("../indicator_data/SAU/SAU EEZ 630,850 v50-1.csv")
d <- read.csv("indicator_data/SAU/SAU EEZ 630,850 v50-1.csv")
head(d)

# look at fields ------------------------------
Expand Down Expand Up @@ -55,10 +62,10 @@ indnames <- data.frame(matrix(labs, nrow = 3, byrow = F))
inddata <- list(labels = indnames, indicators = inddats, datelist = datdata) #, ulim = ulidata, llim = llidata)
class(inddata) <- "indicatordata"

setwd("C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_plots/")
plotIndicatorTimeSeries(inddata, coltoplot = 1:2, plotrownum = 2, sublabel = T, sameYscale = F, outtype = "png")
plotIndicatorTimeSeries(inddata, coltoplot = 1:2, plotrownum = 2, sublabel = T, sameYscale = F)

# plot and save ----------------------------------
save(inddata, file = "C:/Users/mandy.karnauskas/Desktop/Caribbean-ESR/indicator_objects/total_rec_catch.RData")
ind <- inddata
save(ind, file = "indicator_objects/total_rec_catch.RData")


6 changes: 3 additions & 3 deletions indicator_processing/non_automated/Sargassum_inundation.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ dev.off()
library(maps)
library(plotTimeSeries)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")

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

# load data -------------------------------------

d <- read.csv("../../indicator_data/sargassum_innundation_monthly_mean_hu.csv", skip = 2)
d <- read.csv("indicator_data/sargassum_innundation_monthly_mean_hu.csv", skip = 2)

d$yr <- substr(d$X, 1, 4)
d$vars <- (d$ulim - d$X.1)^2
Expand All @@ -38,5 +38,5 @@ plotIndicatorTimeSeries(inddata)

ind <- inddata

save(ind, file = "../../indicator_objects/Sargassum.RData")
save(ind, file = "indicator_objects/Sargassum.RData")

6 changes: 3 additions & 3 deletions indicator_processing/non_automated/marine_debris.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ library(plotTimeSeries)
library(xml2)
library(rvest)

load("../spec_file.RData")
load("indicator_processing/spec_file.RData")

# download data directly from site -----------------------------

Expand All @@ -27,7 +27,7 @@ table <- html_table(page, fill = TRUE) #Parses tables into data frames
table
# automated download does not work ############

dat <- read.csv("../../indicator_data/beach-litter.csv", skip = 0, header = T)
dat <- read.csv("indicator_data/beach-litter.csv", skip = 0, header = T)

d <- dat[which(dat$Entity == "Puerto Rico" | dat$Entity == "United States Virgin Islands"), ]
d$Entity <- droplevels(d$Entity)
Expand All @@ -49,6 +49,6 @@ plotIndicatorTimeSeries(s, coltoplot = 1:2, plotrownum = 2, sublabel = T)

ind <- s

save(ind, file = "../../indicator_objects/marine_debris.RData")
save(ind, file = "indicator_objects/marine_debris.RData")


10 changes: 6 additions & 4 deletions indicator_processing/non_automated/pollution.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ USVI_ind = USVI$sum
# save as indicator object ----------------------
datdata <- as.integer(USVI$year)
inddata <- data.frame(PR_ind, USVI_ind)
labs <- c("Pollution sites" , "Number added", "Puerto Rico",
"Pollution sites" , "Number added", "USVI")
labs <- c("Pollution sites reported" , "Number added", "Puerto Rico",
"Pollution sites reported" , "Number added", "USVI")
indnames <- data.frame(matrix(labs, nrow = 3, byrow = F))
inddata <- list(labels = indnames, indicators = inddata, datelist = datdata)
class(inddata) <- "indicatordata"

# plot and save ----------------------------------
save(inddata, file = "indicator_objects/pollution.RData")
ind <- inddata

plotIndicatorTimeSeries(inddata, coltoplot = 1:2, sublabel = TRUE)
plotIndicatorTimeSeries(ind, plotrownum = 2, coltoplot = 1:2, sublabel = TRUE)

save(ind, file = "indicator_objects/pollution.RData")

0 comments on commit 3fb83e7

Please sign in to comment.