forked from OSUCliMates/DataDash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.R
62 lines (55 loc) · 2.37 KB
/
setup.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#Attach Packages
library(shiny)
library(tidyverse)
library(tidync)
library(colorspace)
library(gridExtra)
library(sf)
library(viridis)
library(shinycssloaders)
library(shinythemes)
#library(ggpubr)
library(shinyjs)
#filenames
#LENS_precfile <- "/home/ST505/CESM-LENS/historical/PREC.nc"
#setup for reference plot
us <- map_data("state")
BigDF <- readRDS("Data/allUSShiny.rds") %>%
rename(lon = lon2)
#setup for range plot
range_dat <- readRDS(file="Data/dec_mem_range.rds")
# PRECIPITATION DEVIATION FROM AVERAGE
# Code to calculate this dataset found in era_precip_deviation.R in Examples folder in CliMates
# if using Months:
#precip_deviation <- readRDS("/home/ST505/precalculated_data/era_precip_deviation.rds")
# if using Quarters:
precip_deviation <- readRDS("Data/era_precip_quarter_deviation.rds")
# read in list of ERA and CESM unique loation lat/long pairs - used for locaiton selection
location_points <- read.csv("Data/lat_lon_pairs.csv")
#function for finding numeric derivative
nderiv <- function(x){
y<-numeric(length=length(x$cum_prec))
y[1] <- 0
for(i in 2:length(x$cum_prec)){
y[i]<- x$cum_prec[i]-x$cum_prec[i-1]
}
y[1] <- y[2] #makes it look nicer
y
}
# theme
theme_dd <- function () {theme(
#plot.background = element_rect(fill = "transparent", color=NA),
plot.background = element_rect(fill = "darkgray"),
panel.grid.major.y = element_line(color = "grey90"),
panel.grid.major.x = element_line(color = "grey90"),
#plot.margin = unit(c(1, 1.5, 1, 1), "cm"),
plot.title = element_text(size = 20, face="bold", hjust = 0.5, vjust = 0.5),
axis.text = element_text(size = 12, face = "bold"),
#axis.title = element_text(size = 16),
panel.background= element_rect(fill = "white"),
#panel.background = element_rect(fill = "transparent",colour = NA),
panel.border = element_rect(colour = "black", fill=NA, size=2),
legend.background = element_rect(fill = "white"),
legend.text = element_text(size = 12),
legend.title = element_text(size=16)
)}