#added a few additions to the NARCLIM NC code and added an R code for
generating BASH code for automating the download for a number of sites and clim_varsDevelopment1
parent
2c102d4594
commit
1154e4eb1c
@ -0,0 +1,59 @@
|
|||||||
|
#code for preparing a text file with BASH code for batch download of NARCLIM data for the HUNTER WQ modeling of
|
||||||
|
#future climate scenarios
|
||||||
|
|
||||||
|
#NARCLIM Variables
|
||||||
|
#evspsblmean water_evaporation flux (actual ET) long_name: Surface evaporation standard_name: water_evaporation_flux units: kg m-2 s-1
|
||||||
|
#tasmean mean near surface temperature
|
||||||
|
#pracc precipitation daily precipitation sum (sum of convective prcacc and stratiform prncacc precip)
|
||||||
|
|
||||||
|
Clim_Var <- 'evspsblmean'
|
||||||
|
Datatype <- 'T_GCMS' #T_GCMS for GCM forcing, T_NNRP for reanalysis (only 1950-2009)
|
||||||
|
Biasboolean <- 'False' #use bias corrected data?
|
||||||
|
|
||||||
|
Directory <- 'C:/Users/z5025317/OneDrive - UNSW/WRL_Postdoc_Manual_Backup/WRL_Postdoc/Projects/Paper#1/Data/NARCLIM_Site_CSVs'
|
||||||
|
Filename <- 'NARCLIM_Point_Sites.csv'
|
||||||
|
|
||||||
|
#Load CSV with location names and lat lon coordinates
|
||||||
|
Location.df <- data.frame(read.csv(paste(Directory, Filename, sep=""), header=T))
|
||||||
|
|
||||||
|
#create empty vector for storing the command line text and open file
|
||||||
|
Vector.for.command.line.txt <- c()
|
||||||
|
Vector.for.command.line.txt <- c(Vector.for.command.line.txt, "module load python")
|
||||||
|
text1 <- c(paste("Datatype='",Datatype,"'", sep=""),
|
||||||
|
paste("Bias_corrected='",Biasboolean,"'", sep=""), paste("ClimVarName='",Clim_Var,"'", sep=""))
|
||||||
|
Vector.for.command.line.txt <- c(Vector.for.command.line.txt, text1)
|
||||||
|
for (i in 1:(length(Location.df$Name))){
|
||||||
|
#name<-as.character(Location.df$Name[i])
|
||||||
|
#name<-gsub('([[:punct:]])|\\s+','_',name)
|
||||||
|
if(i<10){
|
||||||
|
name<-paste('Catchment_0', as.character(i), sep="")
|
||||||
|
}else{
|
||||||
|
name<-paste('Catchment_', as.character(i), sep="")
|
||||||
|
}
|
||||||
|
latitude=round(as.numeric(Location.df$Lat[i]),3)
|
||||||
|
longitude=round(as.numeric(Location.df$Long[i]),3)
|
||||||
|
text <- c(paste("latitude=",latitude,"", sep=""), paste("longitude=",longitude,"", sep=""),
|
||||||
|
paste("name='",name,"'", sep=""),
|
||||||
|
"python /srv/ccrc/data02/z5025317/Code_execution/\\
|
||||||
|
P1_NARCliM_NC_to_CSV_CCRC_SS.py \\
|
||||||
|
--lat $latitude --lon $longitude --varName $ClimVarName --domain 'd02' --timestep \\
|
||||||
|
'DAY' --LocationName $name --Datatype $Datatype --BiasBool $Bias_corrected")
|
||||||
|
Vector.for.command.line.txt <- c(Vector.for.command.line.txt, text)
|
||||||
|
if(i==10|i==20|i==31){
|
||||||
|
Vector.for.command.line.txt <- c(Vector.for.command.line.txt, " ")
|
||||||
|
text.file.name <- paste('C:/Users/z5025317/OneDrive - UNSW/Hunter_CC_Modeling/07_Modelling/01_Input/BC_Generation/Code/NARCLIM_Download_and_Processing/',Clim_Var, "_", Datatype, "_", Biasboolean,substring(as.character(i), 1,1), ".txt", sep="")
|
||||||
|
#open and fill text file
|
||||||
|
fileConn <- file(text.file.name)
|
||||||
|
writeLines(Vector.for.command.line.txt, fileConn)
|
||||||
|
close(fileConn)
|
||||||
|
#
|
||||||
|
if(i==10|i==20){
|
||||||
|
Vector.for.command.line.txt <- c()
|
||||||
|
Vector.for.command.line.txt <- c(Vector.for.command.line.txt, "module load python")
|
||||||
|
text1 <- c(paste("Datatype='",Datatype,"'", sep=""),
|
||||||
|
paste("Bias_corrected='",Biasboolean,"'", sep=""), paste("ClimVarName='",Clim_Var,"'", sep=""))
|
||||||
|
Vector.for.command.line.txt <- c(Vector.for.command.line.txt, text1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue