Skip to content
Snippets Groups Projects
Commit e439a81b authored by R0slyn's avatar R0slyn
Browse files

Adding fruitveg and sugar into irrigation max reader and lpj outputer classes.

parent f6ac192f
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
......@@ -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();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment