Created
January 9, 2023 01:32
-
-
Save JustinWenzhaoLi/46350d2b76f7d9508f3d5a04b428005e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setwd("I:/OneDrive - University of Texas at Arlington/Summer Papers/Texas_Water_Study/WRM_journal/CMIP5_downloader/evspsbl_Amon_GFDL-CM3_rcp85_r1i1p1_200601-202012") | |
| 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 = 180) | |
| for (p in 1:length(file_list)) { | |
| id <- gsub(".tif", "", file_list[p]) | |
| name <- paste0("evspsbl_Amon_GFDL-CM3_rcp85_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) | |
| # export the dataframe to csv | |
| write.csv(lookUpTable, 'evspsbl_Amon_GFDL-CM3_rcp85_r1i1p1_LUT.csv', row.names = FALSE) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment