Skip to content
Snippets Groups Projects
Commit 65ea262e authored by Peter Alexander's avatar Peter Alexander
Browse files

Further changes for 0.5 deg LPJ data

parent 4a3daa95
No related branches found
No related tags found
No related merge requests found
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
......@@ -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
......
......@@ -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);
}
}
......
......@@ -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;
}
......
......@@ -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));
......
......@@ -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;
......
......@@ -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
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