diff --git a/scripts/summariseUKlanduse.R b/scripts/summariseUKlanduse.R index f8af01322d78e6de62344454269e4f727d8e357d..199fac37acba3fffd2ae53bd9666c2e801bfcf32 100644 --- a/scripts/summariseUKlanduse.R +++ b/scripts/summariseUKlanduse.R @@ -23,7 +23,7 @@ cropIntensitySummary = function (luDt, cropType) { area = sum(area))] } -summariseLandUseOutput = function(simDir, writeFile=TRUE) { +summariseLandUseOutput = function(simDir) { countryCells = data.table(read.table("/exports/csce/eddie/geos/groups/LURG/models/PLUM/plumv2/data/halfdeg/ukCells.txt", header=TRUE)) years = list.files(simDir, pattern="[0-9]+") @@ -57,20 +57,16 @@ summariseLandUseOutput = function(simDir, writeFile=TRUE) { } else { print(paste("Can't find file, so skipping:", fileName)) } - - + } - - - if (writeFile) write.table(resDt, file.path(simDir, "ukLC.csv"), sep=",", row.names=FALSE, quote=FALSE) + + write.table(resDt, file.path(simDir, "ukLC.csv"), sep=",", row.names=FALSE, quote=FALSE) resDt } baseOutputDir="/exports/csce/eddie/geos/groups/LURG/models/PLUM/output" -ensemble = commandArgs(trailingOnly = TRUE)[1] - -for (directory in list.dirs(path = file.path(baseOutputDir,ensemble), full.names = TRUE, recursive = FALSE)){ +for (directory in list.dirs(full.names = TRUE, recursive = FALSE)){ for (scenario in basename(list.dirs(path = directory, full.names = TRUE, recursive = FALSE))){ ensDir=file.path(directory,scenario) if (dir.exists(ensDir)) { diff --git a/scripts/summariseUKlanduse.sh b/scripts/summariseUKlanduse.sh old mode 100644 new mode 100755 index af86b6f31b6cad25ba2801ab7e938e2910cbb779..7dba28ae88fd5815c92022dc2c3e9c53c8f8ef8c --- a/scripts/summariseUKlanduse.sh +++ b/scripts/summariseUKlanduse.sh @@ -8,9 +8,10 @@ if [ "$#" -ne 1 ]; then exit fi +cd $1 source /etc/profile module load R -R < /exports/csce/eddie/geos/groups/LURG/models/PLUM/plumv2/scripts/summariseUKlanduse.R --no-save $1 +R < /exports/csce/eddie/geos/groups/LURG/models/PLUM/plumv2/scripts/summariseUKlanduse.R --no-save concatUKLCFile=ukLC_concat.txt echo "Scenario,Year,IrrigCrops,FertCrops,Cropland,Pasture,ManForest,UnmanForest,Natural,AbPasture" > $concatUKLCFile