From e753d71ace3dd026ac3a2461bea77229455b2cb5 Mon Sep 17 00:00:00 2001 From: Heather Wander Date: Tue, 28 Nov 2023 12:17:32 -0500 Subject: [PATCH] updating directories --- scripts/Extract_Delaware_P_T_data.R | 10 +++++----- ...reManuscript_SpatialDistributionClusters.R | 20 +++++++++---------- scripts/SupFigure_MapClusters.R | 16 +++++++-------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/scripts/Extract_Delaware_P_T_data.R b/scripts/Extract_Delaware_P_T_data.R index e2db5e0..bed013d 100644 --- a/scripts/Extract_Delaware_P_T_data.R +++ b/scripts/Extract_Delaware_P_T_data.R @@ -22,14 +22,14 @@ library(data.table) # Read realsat data -lakes_realsat <- read.csv('data/all_groups.csv') +lakes_realsat <- read.csv('data/Code_data/all_groups.csv') lakes_realsat <- lakes_realsat %>% select(ID,long,lat) %>% rename(Lon=long,Lat=lat) -mynetcdf <- 'data/us_average_P_1985_2015.nc' +mynetcdf <- 'data/Code_data/us_average_P_1985_2015.nc' ncFile <- nc_open(mynetcdf) ilongitude <- ncvar_get(ncFile,"lon") ilatitude <- ncvar_get(ncFile,"lat") @@ -38,7 +38,7 @@ Lon <- ilongitude Lat <- ilatitude image.plot(pr_mean) -mynetcdf_t <- 'data/us_average_T_1985_2015.nc' +mynetcdf_t <- 'data/Code_data/us_average_T_1985_2015.nc' ncFile_t <- nc_open(mynetcdf_t) ilongitude <- ncvar_get(ncFile_t,"lon") ilatitude <- ncvar_get(ncFile_t,"lat") @@ -114,7 +114,7 @@ data_pr_temp <- data_pr_temp[, c(1,3,4,2,5)] # Read elevation file -file <- 'data/us_elevation.nc' +file <- 'data/Code_data/us_elevation.nc' ncFile_alt <- nc_open(file) ilongitude <- ncvar_get(ncFile_t,"lon") ilatitude <- ncvar_get(ncFile_t,"lat") @@ -155,4 +155,4 @@ data_elevation <- data_elevation %>% data_final <- left_join(data_pr_temp,data_elevation,by=c('ID','Lon','Lat')) -write.csv(data_final,'data/pr_temp_elev_us_1985_2015.csv') +write.csv(data_final,'data/Code_data/pr_temp_elev_us_1985_2015.csv') diff --git a/scripts/FigureManuscript_SpatialDistributionClusters.R b/scripts/FigureManuscript_SpatialDistributionClusters.R index 969a054..a7b35c0 100644 --- a/scripts/FigureManuscript_SpatialDistributionClusters.R +++ b/scripts/FigureManuscript_SpatialDistributionClusters.R @@ -4,22 +4,22 @@ rm(list = ls()) Sys.setenv(TZ='UTC') if (!require("pacman"))install.packages("pacman") -pacman::p_load(rgdal, sf) +pacman::p_load(rgdal, sf, tidyverse) # Get density plot by latitude -data <- read.csv('data/all_groups.csv') +data <- read.csv('data/Code_data/all_groups.csv') data <- data %>% mutate(cluster = case_when( - Group_num %in% 1 ~ "Cluster 1: No change over time", - Group_num %in% 2 ~ "Cluster 2: Substantial increase and then maintain", - Group_num %in% 3 ~ "Cluster 3: Steady increase over time", - Group_num %in% 4 ~ "Cluster 4: Steady decrease over time", - Group_num %in% 5 ~ "Cluster 5: Peaks", - Group_num %in% 6 ~ "Cluster 6: Troughs", - Group_num %in% 7 ~ "Cluster 7: Outliers" + Group_num %in% 1 ~ "Group 1: No change over time", + Group_num %in% 2 ~ "Group 2: Substantial increase and then maintain", + Group_num %in% 3 ~ "Group 3: Steady increase over time", + Group_num %in% 4 ~ "Group 4: Steady decrease over time", + Group_num %in% 5 ~ "Group 5: Peaks", + Group_num %in% 6 ~ "Group 6: Troughs", + Group_num %in% 7 ~ "Group 7: Outliers" )) @@ -53,7 +53,7 @@ p2 <- ggplot(data, mapping = aes(x = lat, color = cluster))+ theme_figure() # read shape file for map -shp <- readOGR(dsn = file.path(paste0(getwd(),'/data/s_22mr22.shp')), stringsAsFactors = F) +shp <- readOGR(dsn = file.path(paste0(getwd(),'/data/Code_data/s_22mr22.shp')), stringsAsFactors = F) data <- na.omit(data) diff --git a/scripts/SupFigure_MapClusters.R b/scripts/SupFigure_MapClusters.R index 82cd5e6..07cf62f 100644 --- a/scripts/SupFigure_MapClusters.R +++ b/scripts/SupFigure_MapClusters.R @@ -8,17 +8,17 @@ if (!require("pacman"))install.packages("pacman") pacman::p_load(tidyverse, sf, rgdal) # Read data -data <- read.csv('data/all_groups.csv') +data <- read.csv('data/Code_data/all_groups.csv') data <- data %>% mutate(cluster = case_when( - Group_num %in% 1 ~ "Cluster 1: No change over time", - Group_num %in% 2 ~ "Cluster 2: Substantial increase and then maintain", - Group_num %in% 3 ~ "Cluster 3: Steady increase over time", - Group_num %in% 4 ~ "Cluster 4: Steady decrease over time", - Group_num %in% 5 ~ "Cluster 5: Peaks", - Group_num %in% 6 ~ "Cluster 6: Troughs", - Group_num %in% 7 ~ "Cluster 7: Outliers" + Group_num %in% 1 ~ "Group 1: No change over time", + Group_num %in% 2 ~ "Group 2: Substantial increase and then maintain", + Group_num %in% 3 ~ "Group 3: Steady increase over time", + Group_num %in% 4 ~ "Group 4: Steady decrease over time", + Group_num %in% 5 ~ "Group 5: Peaks", + Group_num %in% 6 ~ "Group 6: Troughs", + Group_num %in% 7 ~ "Group 7: Outliers" ))