Skip to content

Commit

Permalink
create regulations indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
CarissaGervasi-NOAA committed Jul 16, 2024
1 parent 8600eed commit d4be3dd
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 0 deletions.
22 changes: 22 additions & 0 deletions indicator_data/FRsection.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"year2","amendments"
"1985",14
"1986",1
"1989",1
"1990",6
"1991",2
"1993",4
"1994",1
"1996",2
"1997",6
"1999",1
"2005",6
"2009",2
"2010",1
"2011",2
"2012",4
"2013",3
"2014",1
"2016",3
"2017",2
"2018",1
"2021",1
22 changes: 22 additions & 0 deletions indicator_data/amendments.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"year2","amendments"
"1985",1
"1986",1
"1989",1
"1990",2
"1991",2
"1993",1
"1994",1
"1996",1
"1997",1
"1999",1
"2005",3
"2009",1
"2010",1
"2011",1
"2012",4
"2013",2
"2014",1
"2016",4
"2017",3
"2018",1
"2021",1
22 changes: 22 additions & 0 deletions indicator_data/regulations.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"year2","amendments"
"1985",64
"1986",1
"1989",1
"1990",6
"1991",4
"1993",13
"1994",1
"1996",8
"1997",7
"1999",2
"2005",45
"2009",4
"2010",5
"2011",2
"2012",81
"2013",21
"2014",1
"2016",10
"2017",11
"2018",1
"2021",1
Binary file added indicator_objects/FRsection.RData
Binary file not shown.
Binary file added indicator_objects/regulations.RData
Binary file not shown.
Binary file added indicator_plots/total_landings_plot_TAP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions indicator_processing/PlotAllIndicators.R
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,8 @@ load("indicator_objects/tier3.RData")
plotIndicatorTimeSeries(ind, coltoplot = 1:2, plotrownum = 2, plotcolnum = 1, trendAnalysis = TRUE, dateformat = "%b%Y", sublabel = TRUE, widadj = 1, hgtadj = 0.4, anom = "none", yposadj = 1.2, sameYscale = F, cex.axis = 1.3, cex.lab = 1.5, cex.main = 1.5)
dev.off()


png(filename = "indicator_plots/total_landings_plot_TAP.png", width = 9, height = 8, units = "in", res = 300)
load("indicator_objects/total_landings.RData")
plotIndicatorTimeSeries(ind, coltoplot = 1:9, plotrownum = 3, plotcolnum = 3, trendAnalysis = TRUE, dateformat = "%b%Y", sublabel = TRUE, widadj = 0.9, hgtadj = 0.5, anom = "none", yposadj = 1, cex.axis = 1.2, cex.lab = 1.4, cex.main = 1.3)
dev.off()
95 changes: 95 additions & 0 deletions indicator_processing/non_automated/regulations.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Number of amendments / regulations indicator

# Last updated 6/19/2024 by Carissa Gervasi

rm(list = ls())
dev.off()

library(dplyr)

dat = read.csv("indicator_data/regulations.csv")


head(dat)

dat$year2 = as.numeric(dat$year2)
dat$amendments = as.numeric(dat$amendments)

styear = min(dat$year2)
enyear = max(dat$year2)


# Create a dataframe with the full date range
full_dates <- data.frame(
year2 = styear:enyear)

# Merge the two dataframes, keeping all dates and filling NAs where there are no matches
dat <- full_dates %>%
left_join(dat, by = "year2")



# save as indicator object ----------------------
datdata <- styear:enyear
inddata <- data.frame(dat$amendments)
labs <- c("Number of new regulations in effect" , "Sum of regulations", "")
indnames <- data.frame(matrix(labs, nrow = 3, byrow = F))
inddata <- list(labels = indnames, indicators = inddata, datelist = datdata)
class(inddata) <- "indicatordata"

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

ind <- inddata
plotIndicatorTimeSeries(ind, coltoplot = 1, plotrownum = 1, plotcolnum = 1, trendAnalysis = TRUE, dateformat = "%b%Y", sublabel = TRUE, widadj = 1, hgtadj = 0.7, anom = "none", yposadj = 1)

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





############################### using FR_Section



rm(list = ls())
dev.off()

library(dplyr)

dat = read.csv("indicator_data/FRsection.csv")


head(dat)

dat$year2 = as.numeric(dat$year2)
dat$amendments = as.numeric(dat$amendments)

styear = min(dat$year2)
enyear = max(dat$year2)


# Create a dataframe with the full date range
full_dates <- data.frame(
year2 = styear:enyear)

# Merge the two dataframes, keeping all dates and filling NAs where there are no matches
dat <- full_dates %>%
left_join(dat, by = "year2")



# save as indicator object ----------------------
datdata <- styear:enyear
inddata <- data.frame(dat$amendments)
labs <- c("Number of new management actions" , "Sum of regulations", "")
indnames <- data.frame(matrix(labs, nrow = 3, byrow = F))
inddata <- list(labels = indnames, indicators = inddata, datelist = datdata)
class(inddata) <- "indicatordata"

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

ind <- inddata
plotIndicatorTimeSeries(ind, coltoplot = 1, plotrownum = 1, plotcolnum = 1, trendAnalysis = TRUE, dateformat = "%b%Y", sublabel = TRUE, widadj = 1, hgtadj = 0.7, anom = "none", yposadj = 1, type = "allLines")

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

0 comments on commit d4be3dd

Please sign in to comment.