Skip to content

Commit

Permalink
Merge pull request #6 from hlwander/master
Browse files Browse the repository at this point in the history
updating directories
  • Loading branch information
hlwander authored Nov 28, 2023
2 parents c29b08b + e753d71 commit 9b2b433
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions scripts/Extract_Delaware_P_T_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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')
20 changes: 10 additions & 10 deletions scripts/FigureManuscript_SpatialDistributionClusters.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
))


Expand Down Expand Up @@ -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)

Expand Down
16 changes: 8 additions & 8 deletions scripts/SupFigure_MapClusters.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
))


Expand Down

0 comments on commit 9b2b433

Please sign in to comment.