diff --git a/07_Modelling/01_Input/BC_Generation/Code/R_Preparing_BASH_script_for_NARCLIM_batch_download.R b/07_Modelling/01_Input/BC_Generation/Code/R_Preparing_BASH_script_for_NARCLIM_batch_download.R new file mode 100644 index 0000000..8da2a5a --- /dev/null +++ b/07_Modelling/01_Input/BC_Generation/Code/R_Preparing_BASH_script_for_NARCLIM_batch_download.R @@ -0,0 +1,37 @@ +#code for preparing a text file with BASH code for batch download of NARCLIM data for the HUNTER WQ modeling of +#future climate scenarios +Clim_Var <- 'pracc' +#'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) +Datatype <- 'T_NNRP' +Biasboolean <- 'False' + +#Load CSV with location names and lat lon coordinates +Filename <- 'Catchment_Prev_Hunter_Model_Centroids_VH_WGS84_attribute_Table.csv' +Directory <- 'C:/Users/z5025317/OneDrive - UNSW/Hunter_CC_Modeling/07_Modelling/01_Input/BC_Generation/catchments/' +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("Biasboolean='",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.Names))){ + name<-as.character(Location.df$Name[i]) + name<-gsub('([[:punct:]])|\\s+','_',name) + latitude=round(as.numeric(Location.df$Lat[1]),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 $Biasboolean;", + ' ') + Vector.for.command.line.txt <- c(Vector.for.command.line.txt, text) + } +Vector.for.command.line.txt <- c(Vector.for.command.line.txt, 'stop') +text.file.name <- paste('C:/Users/z5025317/OneDrive - UNSW/Hunter_CC_Modeling/07_Modelling/01_Input/BC_Generation/Code/',Clim_Var, "_", Datatype, "_", Biasboolean, ".txt", sep="") +#open and fill text file +fileConn <- file(text.file.name) +writeLines(Vector.for.command.line.txt, fileConn) +close(fileConn)