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

added method for outputting prices for crafty and land use for just UK for RUGS scenario stuff.

parent eb8998ac
No related branches found
No related tags found
No related merge requests found
......@@ -226,6 +226,8 @@ public class ModelConfig {
public static final String DOMESTIC_OUTPUT_FILE = OUTPUT_DIR + File.separator + "domestic.txt";
public static final String COUNTRY_DEMAND_FILE = OUTPUT_DIR + File.separator + "countryDemand.txt";
public static final String FOOD_BALANCE_SHEET_FILE = OUTPUT_DIR + File.separator + "fbs.txt";
public static final String CRAFTY_PRICES_FILE = OUTPUT_DIR + File.separator + "craftyPriceFile.txt";
public static final String UK_LAND_COVER_OUTPUT_FILE = OUTPUT_DIR + File.separator + "ukLC.txt";
public static final boolean OUTPUT_FOR_LPJG = getBooleanProperty("OUTPUT_FOR_LPJG", true);
public static final boolean INTERPOLATE_OUTPUT_YEARS = getBooleanProperty("INTERPOLATE_OUTPUT_YEARS", true);
......
......@@ -167,6 +167,8 @@ public class ModelMain {
// doesn't change through time
if (ModelConfig.GENERATE_NEW_YIELD_CLUSTERS && timestep.isInitialTimestep())
clusterIdRaster.putAll(ca.getYieldClusters());
if (ca.getCountry().getName().equals("United Kingdom")) writeUKLandCoverFile(timestep, ca);
}
internationalMarket.determineInternationalTrade(countryAgents, gen2EcDDemand, timestep);
......@@ -312,6 +314,46 @@ public class ModelMain {
LogWriter.print(e);
}
}
private void writeCraftyPricesFile(Timestep timestep){
try {
StringBuffer sbHeadings = new StringBuffer("Year, Country, Crop,Import_price, Export_price");
BufferedWriter outputFile = getFileWriter(timestep, ModelConfig.CRAFTY_PRICES_FILE, sbHeadings.toString());
for (CropType crop : CropType.getAllItems()) {
for (CountryAgent country : countryAgents) {
Map<CropType, CropUsageData> cropUsageAllCrops = country.getCropUsageData();
CropUsageData cropUsage = cropUsageAllCrops.get(crop);
if (cropUsage == null)
continue;
Double importPrice = null;
Double exportPrice = null;
if (crop.isImportedCrop()) {
CountryPrice px = country.getCurrentCountryPrices().get(crop);
importPrice = px.getImportPrice();
exportPrice = px.getExportPrice();
}
StringBuffer sbData = new StringBuffer();
sbData.append(String.format("%d,%s,%s", timestep.getYear(), country.getCountry(), crop.getGamsName()));
sbData.append(String.format(",%.3f,%.3f",importPrice, exportPrice));
outputFile.write(sbData.toString());
outputFile.newLine();
}
}
outputFile.close();
} catch (IOException e) {
LogWriter.print(e);
}
}
private void writeDomesticProductionFile(Timestep timestep) {
try {
......@@ -361,6 +403,40 @@ private void writeDomesticProductionFile(Timestep timestep) {
}
}
private void writeUKLandCoverFile(Timestep timestep, CountryAgent ca){
try {
StringBuffer sbHeadings = new StringBuffer("Year,Cropland,Pasture,ManForest,UnmanForest,Natural,AbPasture,EnergyCrop,FertCrop,IrrigCrop");
BufferedWriter outputFile = getFileWriter(timestep, ModelConfig.UK_LAND_COVER_OUTPUT_FILE, sbHeadings.toString());
StringBuffer sbData = new StringBuffer();
Collection<RasterKey> countryKeys = countryBoundaryRaster.getKeysFor(ca.getCountry());
RasterSet<LandUseItem> ukLandUse = globalLandUseRaster.createSubsetForKeys(countryKeys);
sbData.append(String.format("%d,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f", timestep.getYear(),
LandUseItem.getTotalLandCover(ukLandUse.values(), LandCoverType.CROPLAND),
LandUseItem.getTotalLandCover(ukLandUse.values(), LandCoverType.PASTURE),
LandUseItem.getTotalLandCover(ukLandUse.values(), LandCoverType.MANAGED_FOREST),
LandUseItem.getTotalLandCover(ukLandUse.values(), LandCoverType.UNMANAGED_FOREST),
LandUseItem.getTotalLandCover(ukLandUse.values(), LandCoverType.OTHER_NATURAL),
LandUseItem.getAbandonedPasture(ukLandUse.values()))
);
sbData.append(String.format(",%.1f", LandUseItem.getTotalCropArea(ukLandUse.values(), CropType.ENERGY_CROPS)));
sbData.append(String.format(",%.1f", LandUseItem.getFertiliserTotal(ukLandUse.values(), CropType.getCropsLessPasture()) / 1000));
sbData.append(String.format(",%.1f", LandUseItem.getIrrigationTotal(ukLandUse.values(), CropType.getCropsLessPasture())));
outputFile.write(sbData.toString());
outputFile.newLine();
outputFile.close();
} catch (IOException e) {
LogWriter.print(e);
}
}
private void writeCountryDemandFile(Timestep timestep){
try {
......@@ -395,6 +471,7 @@ private void writeDomesticProductionFile(Timestep timestep) {
writeGlobalMarketFile(timestep);
writeDemandFile(timestep);
writeDomesticProductionFile(timestep);
writeCraftyPricesFile(timestep);
writeCountryDemandFile(timestep);
writeGlobalFoodBalanceSheet(timestep, landUseRaster);
......
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