-
Notifications
You must be signed in to change notification settings - Fork 2
/
Variable_calculations.Rmd
100 lines (63 loc) · 3.07 KB
/
Variable_calculations.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
---
title: "Calculate variables"
author: "Amber Runyon"
date: "7/23/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Initials
```{r Initials, echo=FALSE, message=FALSE, warning=FALSE}
rm(list = ls())
area <- 'WRST_simple' #wrst_mtns, copper_plateau, coastal_mtns, eastern_coast, WRST_simple
library(stars);library(dplyr);library(ggplot2);library(ggthemes);library(viridis);library(here);library(ggrepel);library(rlang);library(units)
met.dir <- "E:/NCAR_AK/met"
vic.dir <- "E:/NCAR_AK/vic_hydro"
working.dir <- "C:/Users/achildress/Documents/wrst_temp"
data.dir <- paste(working.dir, "Data", area, sep="/")
dir.create(data.dir,showWarnings=FALSE)
historical.period <- as.character(seq(1950,1999,1))
future.period <- as.character(seq(2025,2055,1))
daymet.period <- as.character(seq(1980,2016,1))
GCMs <- c("inmcm4.rcp85","ACCESS1-3.rcp45","CanESM2.rcp85")
CFs <- c("Climate Future 1", "Climate Future 2", "Climate Future 3")
cols <- c("#12045C","#ffcccc","#E10720")
CF_GCM <- data.frame(CF=CFs,GCM=GCMs,CF_col=cols)
```
## Load Spatial Data
```{r Load spatial data}
# Spatial
boundary.dir <- "C:/Users/achildress/DOI/NPS-WRST-Resource Stewardship Strategy - Climate/3.0 Climate futures development (Summer 2021)/Data/Boundary_shapefiles/"
shp <- st_read(paste0(boundary.dir, area, ".shp")) # Wrangell Mountains
shp <- st_transform(shp, 3338)
# plot(st_geometry(shp))
```
## Met monthly parse and variable creation
Loop through met GCM.rcp and summarize each variable
```{r Create met monthly variables, results=hide, eval=TRUE}
memory.limit(size = 60000)
source(here::here("Code", "Metric-development", "met","met-monthly-stars.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "met","met-monthly-variables.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "met","Annual.tmeanF.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "met","Annual.precipIn.R"),echo = FALSE)
```
## Vic monthly parse and variable creation
```{r Create vic monthly variables, results=hide, eval=TRUE}
memory.limit(size = 60000)
source(here::here("Code", "Metric-development", "vic","vic-monthly-stars.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "vic","max.SWE.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "vic","MAMSON.SWE.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "vic","water.balance.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "vic","SWE.precip.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "vic","soil.temp.R"),echo = FALSE)
```
## Daily variable creation
```{r Create daily variables, results=hide, eval=TRUE}
gc()
memory.limit(60000)
source(here::here("Code", "Metric-development", "met","met-daily-stars_by_year.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "vic","SWE-runoff-Pr99.R"),echo = FALSE)
source(here::here("Code", "Metric-development", "met","Pr99v2.R"),echo = FALSE)
source(here::here("Code", "Metric-development","daily-all-geographies.R"),echo = FALSE,eval=FALSE)
```