From e439a81b76e4d4ac88529a976e9a966067edc6f3 Mon Sep 17 00:00:00 2001 From: R0slyn <roslyn.henry.08@aberdeen.ac.uk> Date: Tue, 20 Aug 2019 16:29:55 +0100 Subject: [PATCH] Adding fruitveg and sugar into irrigation max reader and lpj outputer classes. --- scripts/summariseLandUseOneSim.R | 7 +++---- src/ac/ed/lurg/landuse/IrrigationMaxAmountReader.java | 4 ++++ src/ac/ed/lurg/output/LpjgOutputer.java | 8 +++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/summariseLandUseOneSim.R b/scripts/summariseLandUseOneSim.R index 01938da0..35a3385b 100644 --- a/scripts/summariseLandUseOneSim.R +++ b/scripts/summariseLandUseOneSim.R @@ -30,7 +30,7 @@ summariseLandUseOutput = function(simDir, writeFile=TRUE) { print (paste("Processing", year, "from", fileName)) luDt = data.table(read.table(fileName, header=TRUE)) - for (cropType in c('maize', 'rice', 'wheat', 'energycrops', 'oilcrops', 'pulses', 'starchyRoots')) { + for (cropType in c('maize', 'rice', 'wheat', 'energycrops', 'oilcrops', 'pulses', 'starchyRoots', "fruitveg", "sugar")) { cropSummary = cropIntensitySummary(luDt, cropType) if (nrow(cropSummary) >0) cropSumDt = rbind(cropSumDt, cbind(cropSummary, year=year)) @@ -40,7 +40,7 @@ summariseLandUseOutput = function(simDir, writeFile=TRUE) { } } - dryMatterDt = data.table(cropType = c("wheat", "maize", "rice", "oilcrops", "pulses", "starchyRoots", "energycrops"), dryMatter= c(0.87, 0.86, 0.89, 0.88, 0.31, 0.21, 1.0)) + dryMatterDt = data.table(cropType = c("wheat", "maize", "rice", "oilcrops", "pulses", "starchyRoots", "energycrops", "fruitveg", "sugar"), dryMatter= c(0.87, 0.86, 0.89, 0.88, 0.31, 0.21, 1.0, 0.1, 1.0)) cropSumDt = merge(cropSumDt, dryMatterDt, by = "cropType") resDt = rbind(cropSumDt, cropSumDt[cropType != 'energycrops', list(cropType='avgExcEC', @@ -70,5 +70,4 @@ if (dir.exists(ensDir)) { summariseLandUseOutput(simDir = ensDir) } else { print(paste(ensDir, "does not exist. Stopping")) -} - +} \ No newline at end of file diff --git a/src/ac/ed/lurg/landuse/IrrigationMaxAmountReader.java b/src/ac/ed/lurg/landuse/IrrigationMaxAmountReader.java index 13aa847c..640bae20 100644 --- a/src/ac/ed/lurg/landuse/IrrigationMaxAmountReader.java +++ b/src/ac/ed/lurg/landuse/IrrigationMaxAmountReader.java @@ -31,6 +31,8 @@ public class IrrigationMaxAmountReader extends AbstractTabularRasterReader<Irrig double oilcrops = getValueForCol(rowValues, LPJCropTypes.OILCROPS + highFertIrrigString) / ModelConfig.IRRIGIATION_EFFICIENCY; double pulses = getValueForCol(rowValues, LPJCropTypes.PULSES + highFertIrrigString) / ModelConfig.IRRIGIATION_EFFICIENCY; double starchy_roots = getValueForCol(rowValues, LPJCropTypes.STARCHY_ROOTS + highFertIrrigString) / ModelConfig.IRRIGIATION_EFFICIENCY; + double fruitveg = getValueForCol(rowValues, LPJCropTypes.FRUITVEG + highFertIrrigString) / ModelConfig.IRRIGIATION_EFFICIENCY; + double sugar = getValueForCol(rowValues, LPJCropTypes.SUGAR + highFertIrrigString) / ModelConfig.IRRIGIATION_EFFICIENCY; item.setMaxIrrigAmount(CropType.WHEAT, c3Cereals); item.setMaxIrrigAmount(CropType.MAIZE, c4Cereals); @@ -39,6 +41,8 @@ public class IrrigationMaxAmountReader extends AbstractTabularRasterReader<Irrig item.setMaxIrrigAmount(CropType.OILCROPS, oilcrops); item.setMaxIrrigAmount(CropType.PULSES, pulses); item.setMaxIrrigAmount(CropType.STARCHY_ROOTS, starchy_roots); + item.setMaxIrrigAmount(CropType.FRUITVEG, fruitveg); + item.setMaxIrrigAmount(CropType.SUGAR, sugar); item.setMaxIrrigAmount(CropType.SETASIDE, 0.0); } } \ No newline at end of file diff --git a/src/ac/ed/lurg/output/LpjgOutputer.java b/src/ac/ed/lurg/output/LpjgOutputer.java index 847c6a46..6b0219d2 100644 --- a/src/ac/ed/lurg/output/LpjgOutputer.java +++ b/src/ac/ed/lurg/output/LpjgOutputer.java @@ -34,7 +34,7 @@ public class LpjgOutputer extends AbstractLandUseOutputer { BufferedWriter outputWriter = null; try { outputWriter = new BufferedWriter(new FileWriter(outputFileName, false)); - outputWriter.write("Lon Lat Year CerealsC3 Oilcrops StarchyRoots Pulses Maize Miscanthus Rice Pasture"); + outputWriter.write("Lon Lat Year CerealsC3 Oilcrops StarchyRoots Pulses Maize Miscanthus Rice Pasture FruitVeg Sugar"); outputWriter.newLine(); for (Entry<RasterKey, LandUseItem> entry : landUseRaster.entrySet()) { @@ -55,9 +55,11 @@ public class LpjgOutputer extends AbstractLandUseOutputer { double pulses = extractor.extract(item, CropType.PULSES); double starchyRoots = extractor.extract(item, CropType.STARCHY_ROOTS); double pasture = extractor.extract(item, CropType.PASTURE); + double fruitVeg = extractor.extract(item, CropType.FRUITVEG); + double sugar = extractor.extract(item, CropType.SUGAR); - outputWriter.write(String.format("%.2f %.2f %d %.14f %.14f %.14f %.14f %.14f %.14f %.14f %.14f", lat, lon, year, - c3cereal, oilcrops, starchyRoots, pulses, maize, miscanthus, rice, pasture)); + outputWriter.write(String.format("%.2f %.2f %d %.14f %.14f %.14f %.14f %.14f %.14f %.14f %.14f %.14f %.14f", lat, lon, year, + c3cereal, oilcrops, starchyRoots, pulses, maize, miscanthus, rice, pasture, fruitVeg, sugar)); outputWriter.newLine(); } } -- GitLab