Skip to content

Instantly share code, notes, and snippets.

@JustinWenzhaoLi
Created January 8, 2023 23:29
Show Gist options
  • Select an option

  • Save JustinWenzhaoLi/370b24233dadd7a06086f49fbf6587ba to your computer and use it in GitHub Desktop.

Select an option

Save JustinWenzhaoLi/370b24233dadd7a06086f49fbf6587ba to your computer and use it in GitHub Desktop.
setwd("I:/OneDrive - University of Texas at Arlington/Summer Papers/Texas_Water_Study/WRM_journal/CMIP5_downloader/evspsbl_Amon_GISS-E2-R_rcp45_r1i1p1_200601-202512")
file_list <- list.files(
full.names = FALSE
)
# reorder by gtools
library(gtools)
file_list <- mixedsort(file_list)
# create dataframe
lookUpTable <- data.frame(matrix(ncol = 3, nrow = 0))
x <- c("id_no", "name","system:time_start")
colnames(lookUpTable) <- x
period <- seq(as.Date("2006/01/01"), by = "month", length.out = 240)
for (p in 1:length(file_list)) {
id <- gsub(".tif", "", file_list[p])
name <- paste0("evspsbl_Amon_GISS-E2-R_rcp45_r1i1p1_", period[p])
time_id <- as.numeric(as.POSIXct(paste0(period[p], ' 00:00:00'), tz = "GMT"))*1000
lookUpTable[nrow(lookUpTable) + 1,] = c(id,name,time_id)
}
head(lookUpTable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment