-
Notifications
You must be signed in to change notification settings - Fork 2
/
CCRP_Generate_Climate_Futures-customGCM-sameQuads.Rmd
158 lines (103 loc) · 5.1 KB
/
CCRP_Generate_Climate_Futures-customGCM-sameQuads.Rmd
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
title: "NPS park climate futures"
author: "Climate Change Response Program"
date: "`r format(Sys.time(), '%d %B %Y')`"
output: html_document
---
```{r setup, warning=FALSE, include = FALSE}
knitr::opts_chunk$set(
echo = FALSE,
collapse = TRUE,
warning = TRUE, # set to FALSE when done
message = TRUE # set to FALSE when done
)
library(here); library(plyr); # Use here::here when package lubridate is used
library(plotrix); library(zoo); library(ggplot2); library(grid); library(cowplot); library(reshape2); library(raster); library(ncdf4); library(reshape2); library(WriteXLS); library(data.table); library(RColorBrewer); library(ggrepel); library(lubridate); library(dplyr); library(forcats); library(openxlsx); library("WaterBalance"); library(sf); library(raster); library(rgdal); library(R.utils); library(tmap); library(tmaptools); library(ggspatial); library(basemaps)
library(gridExtra); library(SPEI); library(tidyr); library(tibble); library(sp); library(skimr); library(stringr); library(ggpubr); library(lemon); library(ggfortify); library(extRemes); library(sp);library(terra);library(rasterVis); library(sf)
```
# For loop that reads names from csv file for park
```{r user-inputs-1, warning=FALSE, include = FALSE}
rm(list = ls())
#### Use existing RCF file at OutDir
```
```
```{r WarmWet/HotDry, message=FALSE, warning=FALSE, include = FALSE}
# Specify Climate Futures
OutDir <- "C:/Users/arunyon/OneDrive - DOI/Documents/Projects/SFAN-P4CC-workshop/PORE/PORE/"
DataDir = paste0(OutDir,'input-data/') # for .csv's
DataFile <- list.files(path = DataDir, pattern = 'Final_Environment.RData', full.names = TRUE)
# Environment needs to be added if not parsing MACA data
load(DataFile)
OutDir <- "C:/Users/arunyon/OneDrive - DOI/Documents/Projects/SFAN-P4CC-workshop/PORE/PORE/"
DataDir = paste0(OutDir,'input-data/') # for .csv's
FutureSubset <- c("Warm Wet", "Hot Dry")
CFs = FutureSubset
custom_GCMs = c("CNRM-CM5.rcp45", "MIROC-ESM-CHEM.rcp85") # In order as FutureSubset
CF_abbreviation <- "Custom-CFs"
colors2<- colors5[c(1,4)] # Select pair of climate futures - WarmWet/HotDry
colors3<-c("white",colors2)
col<- c("darkgray",colors2) # WarmWet/HotDry
#col<- c("darkgray","#F3D3CB","#12045C") # HotWet/WarmDry
## Adjust CFs
WB_GCMs <- data.frame(GCM = custom_GCMs, CF = CFs)
#Change selected CFs in Future_Means df
Future_Means$select <- NA
Future_Means$select[Future_Means$GCM == WB_GCMs$GCM[1]] = WB_GCMs$CF[1]
Future_Means$select[Future_Means$GCM == WB_GCMs$GCM[2]] = WB_GCMs$CF[2]
CFDir = paste0(OutDir,"Custom-CFs/") # for .csv's
if(dir.exists(CFDir) == FALSE){
dir.create(CFDir)
}
TableDir = paste0(CFDir,"tables/") # for .csv's
if(dir.exists(TableDir) == FALSE){
dir.create(TableDir)
}
FigDir = paste0(CFDir,"figures/") # for .csv's
if(dir.exists(FigDir) == FALSE){
dir.create(FigDir)
}
# Run scripts
source(here::here("scripts", "Threshold_Bar_Charts.R")) # Requires "PARK_lat_long_Final_Environment.RData". Outputs plots and Excel Workbook
source(here::here("scripts","Daily_WB_Model.R"))
source(here::here("scripts", "Drought_characteristics.R"))
source(here::here("scripts", "Return_Events.R"))
source(here::here("scripts", "Summary plots.R"))
source(here::here("scripts", "Report_plots.R"))
```
```{r WarmDry/HotWet, message=FALSE, warning=FALSE, include = FALSE}
# Specify Climate Futures
DataFile <- list.files(path = DataDir, pattern = 'Final_Environment.RData', full.names = TRUE) # Environment needs to be added if not parsing MACA data
load(DataFile)
FutureSubset <- CFs_all[c(4,2)]; CFs = FutureSubset # Pick pair of climate futures.
CF_abbreviation <- "WD-HW"
# WB_GCMs <- subset(WB_GCMs, CF %in% CFs)
# colors2<- c("#9A9EE5","#E10720") # Select pair of climate futures - WarmWet/HotDry
colors2<- colors5[c(3,2)] # Select pair of climate futures - HotWet/WarmDry
colors3<-c("white",colors2)
# col<- c("darkgray","#9A9EE5","#E10720") # WarmWet/HotDry
col<- c("darkgray", colors2) # HotWet/WarmDry
CFDir = paste0(OutDir,"WarmDry_HotWet/") # for .csv's
if(dir.exists(CFDir) == FALSE){
dir.create(CFDir)
}
TableDir = paste0(CFDir,"tables/") # for .csv's
if(dir.exists(TableDir) == FALSE){
dir.create(TableDir)
}
FigDir = paste0(CFDir,"figures/") # for .csv's
if(dir.exists(FigDir) == FALSE){
dir.create(FigDir)
}
if (exists("FutureSubset") == FALSE) stop("Please specify Climate Futures") # At the top of the script, please enter a combination of futures, e.g. Warm Wet/Hot Dry
source(here::here("scripts", "Threshold_Bar_Charts.R")) # Requires "PARK_lat_long_Final_Environment.RData". Outputs plots and Excel Workbook
source(here::here("scripts","Daily_WB_Model.R"))
source(here::here("scripts", "Drought_characteristics.R"))
# source(here::here("scripts", "WBgrid_plotting.R")) # Run the Water Balance Model
source(here::here("scripts", "Return_Events.R"))
source(here::here("scripts", "Summary plots.R"))
source(here::here("scripts", "Report_plots.R"))
```
```{r Copy-and-delete-files, message=FALSE, warning=FALSE, include = FALSE}
source(here::here("scripts", "write_metadata.R"))
source(here::here("scripts", "copy_paste_delete_files.R")) # copies files and folders to specified local folder
```