diff --git a/debug_config.properties b/debug_config.properties index 4cac63778f44c65aa7d25d9c0a8ab8c669c415a5..0e466a7cfdba364c4de5735ba808880b2084a067 100644 --- a/debug_config.properties +++ b/debug_config.properties @@ -1,23 +1,24 @@ BASE_DIR=/Users/peteralexander/Documents/R_Workspace/UNPLUM -YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ/yield_anpp_rcps-2016-01-29/rcp8p5_past_fert/output-2016-01-29 +#YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ/yield_anpp_rcps-2016-01-29/rcp8p5_past_fert/output-2016-01-29 -#YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ/output-2016-10-26.processed -#SPATIAL_DIR_NAME=halfdeg -#CELL_SIZE_X=0.5 -#ANPP_FILENAME=anpp.out.2011-2015 -#YIELD_FILENAME=yield.out.2011-2015 -#MIN_FERT_AMOUNT=0 -#MID_FERT_AMOUNT=200 -#MAX_FERT_AMOUNT=1000 -#FERT_AMOUNT_PADDING=4 +YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ/sam-03Nov2016 +SPATIAL_DIR_NAME=halfdeg +CELL_SIZE_X=0.5 +ANPP_FILENAME=anpp.out.2011-2015 +YIELD_FILENAME=yield.out.2011-2015 +IRRIG_MAX_WATER_FILENAME=gsirrigation.out.2011-2015 +MIN_FERT_AMOUNT=0 +MID_FERT_AMOUNT=200 +MAX_FERT_AMOUNT=1000 +FERT_AMOUNT_PADDING=4 +PASTURE_FERT_RESPONSE_FROM_LPJ=false CLEANUP_GAMS_DIR=false # Properties for testing CHANGE_YIELD_DATA_YEAR=false CHANGE_DEMAND_YEAR=true -#MAX_IMPORT_CHANGE=0.2 -#DEBUG_LIMIT_COUNTRIES=false +DEBUG_LIMIT_COUNTRIES=false SSP_SCENARIO=SSP2_v9_130325 END_TIMESTEP=18 @@ -26,6 +27,6 @@ TIMESTEP_SIZE=5 NUM_CEREAL_CATEGORIES=5 NUM_PASTURE_CATEGORIES=3 -LAND_CHANGE_COST=.6 +LAND_CHANGE_COST=.8 -#INTERPOLATE_OUTPUT_YEARS = true +INTERPOLATE_OUTPUT_YEARS = false diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index 44d75ef3cfd6398b6a04547ddcfcacfff3202540..57c3eeccaacc290c2b20bf7d2391994d9fa43e5a 100644 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -103,6 +103,7 @@ public class ModelConfig { public static final int LPJG_MONITOR_TIMEOUT_SEC = getIntProperty("LPJG_MONITOR_TIMEOUT", 60*60*2); public static final String ANPP_FILENAME = getProperty("ANPP_FILENAME", "anpp_plum.out"); public static final String YIELD_FILENAME = getProperty("YIELD_FILENAME", "yield_plum.out"); + public static final boolean PASTURE_FERT_RESPONSE_FROM_LPJ = getBooleanProperty("PASTURE_FERT_RESPONSE_FROM_LPJ", true);; public static final double CALIB_FACTOR_WHEAT = getDoubleProperty("CALIB_FACTOR_WHEAT", 0.966); public static final double CALIB_FACTOR_MAIZE = getDoubleProperty("CALIB_FACTOR_MAIZE", 0.631); @@ -158,14 +159,14 @@ public class ModelConfig { public static final double UNHANDLED_CROP_AREA = getDoubleProperty("UNHANDLED_CROP_AREA", 0.4); // includes fruit veg forage crops set aside and failed crop - public static final double OTHER_INTENSITY_COST = getDoubleProperty("OTHER_INTENSITY_COST", 0.3); + public static final double OTHER_INTENSITY_COST = getDoubleProperty("OTHER_INTENSITY_COST", 0.4); public static final double OTHER_INTENSITY_PARAM = getDoubleProperty("OTHER_INTENSITY_PARAM", 5.0); public static final double IRRIG_COST_SCALE_FACTOR = getDoubleProperty("IRRIG_COST_SCALE_FACTOR", 0.01); public static final double FERTILISER_COST_PER_T = getDoubleProperty("FERTILISER_COST_PER_T", 0.87 * 1.4 * 2); // £900/t N * 1.4$/£ * 2NPK/N public static final double FERTILISER_MAX_COST = FERTILISER_COST_PER_T * MAX_FERT_AMOUNT/1000; - public static final double DOMESTIC_PRICE_MARKUP = getDoubleProperty("DOMESTIC_PRICE_MARKUP", 1.5); + public static final double DOMESTIC_PRICE_MARKUP = getDoubleProperty("DOMESTIC_PRICE_MARKUP", 1.0); public static final double TRANSPORT_LOSSES = getDoubleProperty("TRANSPORT_LOSSES", 0.1); // in international trade public static final double TRADE_BARRIER_FACTOR = getDoubleProperty("TRADE_BARRIER_FACTOR", 1.5); // price factor in international trade, transport cost and real trade barriers diff --git a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java index 0cc19a4bbfe2896f8e9cf426ebf06f4c62926da5..18c12dc21341d038d8fb54d01e9e2b171a6269c8 100644 --- a/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java +++ b/src/ac/ed/lurg/country/gams/GamsRasterOptimiser.java @@ -283,7 +283,7 @@ public class GamsRasterOptimiser { CropType crop = CropType.WHEAT; if (yresp != null && (yresp.getYieldMax(crop) < yresp.getYieldFertOnly(crop) || yresp.getYieldMax(crop) < yresp.getYieldIrrigOnly(crop))) { - logErrorWithCoord("Inconsistency F only:" + yresp.getYieldFertOnly(crop) + ", I only" + yresp.getYieldIrrigOnly(crop) + ", max " + yresp.getYieldMax(crop) + " at ", key, yieldRaster); + logErrorWithCoord(String.format("Inconsistency: F only: %.4f, I only %.4f, max %.4f at ", yresp.getYieldFertOnly(crop), yresp.getYieldIrrigOnly(crop), yresp.getYieldMax(crop)), key, yieldRaster); } } diff --git a/src/ac/ed/lurg/landuse/IrrigationMaxAmountReader.java b/src/ac/ed/lurg/landuse/IrrigationMaxAmountReader.java index 6ff16aa88ee43e2ba4acbb7462375fed88527349..88a855b2cd0811d000f8147946d85b32e3106a0c 100644 --- a/src/ac/ed/lurg/landuse/IrrigationMaxAmountReader.java +++ b/src/ac/ed/lurg/landuse/IrrigationMaxAmountReader.java @@ -19,7 +19,7 @@ public class IrrigationMaxAmountReader extends AbstractTabularRasterReader<Irrig private YieldRaster yieldSurfaces; public IrrigationMaxAmountReader(RasterSet<IrrigationItem> irigCosts, YieldRaster yieldSurfaces) { - super(" +", MIN_COLS, irigCosts); + super("\\s+", MIN_COLS, irigCosts); this.yieldSurfaces = yieldSurfaces; } diff --git a/src/ac/ed/lurg/types/FertiliserRate.java b/src/ac/ed/lurg/types/FertiliserRate.java index bd3ff4f731ee9e865aada64d0fc66c3284c5da57..b7f096a29a3fb255ca1659a6a9bbd86fd84b325d 100644 --- a/src/ac/ed/lurg/types/FertiliserRate.java +++ b/src/ac/ed/lurg/types/FertiliserRate.java @@ -3,7 +3,7 @@ package ac.ed.lurg.types; import ac.ed.lurg.ModelConfig; public enum FertiliserRate { - NO_FERT(String.format( "%0" + ModelConfig.FERT_AMOUNT_PADDING + ".0f", ModelConfig.MIN_FERT_AMOUNT)), + NO_FERT(ModelConfig.MIN_FERT_AMOUNT == 0 ? "0" : String.format( "%0" + ModelConfig.FERT_AMOUNT_PADDING + ".0f", ModelConfig.MIN_FERT_AMOUNT)), MID_FERT(String.format("%0" + ModelConfig.FERT_AMOUNT_PADDING + ".0f", ModelConfig.MID_FERT_AMOUNT)), MAX_FERT(String.format("%0" + ModelConfig.FERT_AMOUNT_PADDING + ".0f", ModelConfig.MAX_FERT_AMOUNT)); diff --git a/src/ac/ed/lurg/yield/LPJCropTypes.java b/src/ac/ed/lurg/yield/LPJCropTypes.java index 689a9d546b3bcdd0e552ba23613228a61c00603e..c952315e8decb01ccaa86dd7d43423e12f66fea0 100644 --- a/src/ac/ed/lurg/yield/LPJCropTypes.java +++ b/src/ac/ed/lurg/yield/LPJCropTypes.java @@ -7,8 +7,8 @@ public enum LPJCropTypes { SPRING_WHEAT("TeSW"), RICE("TrRi"), MAIZE("TeCo"), - PASTURE_C3("PC3GN"), - PASTURE_C4("PC4GN"); + PASTURE_C3("PC3G"), + PASTURE_C4("PC4G"); private String lpjName; diff --git a/src/ac/ed/lurg/yield/LPJYieldResponseMapReader.java b/src/ac/ed/lurg/yield/LPJYieldResponseMapReader.java index e0c3c9bf2979dcb1c0d2f740fa99af7e1e793100..63f1405096e42102cde39d95621e33d6d6ef57dd 100644 --- a/src/ac/ed/lurg/yield/LPJYieldResponseMapReader.java +++ b/src/ac/ed/lurg/yield/LPJYieldResponseMapReader.java @@ -45,15 +45,17 @@ public class LPJYieldResponseMapReader { private void readNppFile(YieldRaster yieldRaster, String fileToRead) { // Passed in YieldRaster is updated - AbstractTabularRasterReader<YieldResponsesItem> nppReader = new AbstractTabularRasterReader<YieldResponsesItem>("[ |\t]+", 10, yieldRaster) { + AbstractTabularRasterReader<YieldResponsesItem> nppReader = new AbstractTabularRasterReader<YieldResponsesItem>("\\s+", 10, yieldRaster) { protected void setData(RasterKey key, YieldResponsesItem item, Map<String, Double> rowValues) { double adjFactor = 2 * 10 * ModelConfig.PASTURE_HARVEST_FRACTION; // 2 for carbon units, 10 for kg/m2 to t/ha, and 0.5 for half grazed - - String lowFertString = YieldType.getYieldType(FertiliserRate.NO_FERT, IrrigationRate.NO_IRRIG).getFertIrrigString(); - boolean isC3 = (getValueForCol(rowValues, LPJCropTypes.PASTURE_C3 + lowFertString) > getValueForCol(rowValues, LPJCropTypes.PASTURE_C4 + lowFertString)); - + for (FertiliserRate fert : FertiliserRate.values()) { - double pastureYield = (isC3 ? getValueForCol(rowValues, LPJCropTypes.PASTURE_C3 + fert.getId()) : getValueForCol(rowValues, LPJCropTypes.PASTURE_C4 + fert.getId())) * adjFactor; + double pastureYield; + if (ModelConfig.PASTURE_FERT_RESPONSE_FROM_LPJ) + pastureYield = Math.max(getValueForCol(rowValues, LPJCropTypes.PASTURE_C3 + "N" + fert.getId()), getValueForCol(rowValues, LPJCropTypes.PASTURE_C4 + "N" + fert.getId())) * adjFactor; + else + pastureYield = Math.max(getValueForCol(rowValues, LPJCropTypes.PASTURE_C3.toString()), getValueForCol(rowValues, LPJCropTypes.PASTURE_C4.toString())) * adjFactor; + item.setYield(YieldType.getYieldType(fert, IrrigationRate.NO_IRRIG), CropType.PASTURE, pastureYield); item.setYield(YieldType.getYieldType(fert, IrrigationRate.MAX_IRRIG), CropType.PASTURE, pastureYield); } @@ -65,7 +67,7 @@ public class LPJYieldResponseMapReader { private void readYieldFile(YieldRaster yieldRaster, String fileToRead) { // Passed in YieldRaster is updated - AbstractTabularRasterReader<YieldResponsesItem> yieldReader = new AbstractTabularRasterReader<YieldResponsesItem>(" +", 10, yieldRaster) { + AbstractTabularRasterReader<YieldResponsesItem> yieldReader = new AbstractTabularRasterReader<YieldResponsesItem>("\\s+", 10, yieldRaster) { protected void setData(RasterKey key, YieldResponsesItem item, Map<String, Double> rowValues) { double adjFactor = 10; // 10 for kg/m2 to t/ha @@ -102,6 +104,6 @@ public class LPJYieldResponseMapReader { } private void setCalibratedYield(YieldResponsesItem item, YieldType yieldType, CropType crop, double yield) { - item.setYield(yieldType, crop, yield * crop.getCalibrationFactor()); // this can't go on YieldResponsesItem.setYield as this is called from else where + item.setYield(yieldType, crop, yield * crop.getCalibrationFactor()); // applying the calibration factor can't go in YieldResponsesItem.setYield as this is also called from elsewhere } } \ No newline at end of file