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

Change calibration factors, and add scripts for starting scenarios

parent a97f105d
No related branches found
No related tags found
No related merge requests found
DATA_DIR=<somewhere common for the data>
GAMS_MODEL=<where the gams code file is located>
SPATIAL_DIR_NAME=halfdeg
CELL_SIZE_X=0.5
YIELD_DIR=<might actually need to be in scenario specific one, or change to have a base plus RCP specific dir or something>LPJG_PLUM_expt1.2_rcp26_forED
#!/bin/sh
filename="$1"
common_prop_file=./common.properties
output_dir=./scenarios/
if [[ $* == *-O* ]]; then overwrite=1
else overwrite=0
fi
if [ "$#" -lt 1 ]; then
echo "Need to specify scenario table file"
exit
fi
echo "Generating scenarios into $output_dir"
while read -r datarow $filename
do
IFS=',' read -r -a array <<< "$datarow"
if [ -z "$header" ]; then
header=( "${array[@]}" )
else
scenario="${array[0]}"
scenario_dir=$output_dir$scenario
echo $scenario
if [ ! -d "$scenario_dir" ]; then
mkdir $scenario_dir
elif [ $overwrite -ne 1 ]; then
echo "Already have scenario $scenario, set -O to overwrite existing scenarios"
continue;
fi
config_file=$scenario_dir/config.properties
cp $common_prop_file $config_file
echo "BASE_DIR=$scenario_dir" >> $config_file
for index in "${!array[@]}"
do
echo "${header[index]}"="${array[index]}" >> $config_file
done
echo "$scenario generated"
fi
done < $filename
#!/bin/sh
if [ "$#" -lt 1 ]; then
echo "Need to specify scenario table file"
exit
fi
filename="$1"
output_dir=/Users/peteralexander/Documents/R_Workspace/UNPLUM/dummy/scenarios/
echo "Starting scenarios in $output_dir"
while read -r datarow $filename
do
IFS=',' read -r -a array <<< "$datarow"
if [ -z "$header" ]; then
header=( "${array[@]}" )
else
scenario="${array[0]}"
scenario_dir=$output_dir$scenario
echo $scenario
if [ ! -d "$scenario_dir" ]; then
echo "Scenario $scenario dir is missing, so skipping"
continue;
fi
echo "qsub runPlum.sh scenario_dir"
fi
done < $filename
scenario,SSP_SCENARIO,MAX_IMPORT_CHANGE,TECHNOLOGY_CHANGE_ANNUAL_RATE,FRED
s1,SSP2_v9_130325,0.3,0.01,F1
s2,SSP1_v9_130325,0.5,0.04,F2
s3,SSP1_v9_130325,0.5,0.04,F3
s4,SSP1_v9_130325,0.5,0.04,F3
s5,SSP1_v9_130325,0.5,0.04,F3
...@@ -106,12 +106,12 @@ public class ModelConfig { ...@@ -106,12 +106,12 @@ public class ModelConfig {
public static final String YIELD_FILENAME = getProperty("YIELD_FILENAME", "yield.out"); public static final String YIELD_FILENAME = getProperty("YIELD_FILENAME", "yield.out");
public static final boolean PASTURE_FERT_RESPONSE_FROM_LPJ = getBooleanProperty("PASTURE_FERT_RESPONSE_FROM_LPJ", true);; 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_WHEAT = getDoubleProperty("CALIB_FACTOR_WHEAT", 0.976);
public static final double CALIB_FACTOR_MAIZE = getDoubleProperty("CALIB_FACTOR_MAIZE", 0.631); public static final double CALIB_FACTOR_MAIZE = getDoubleProperty("CALIB_FACTOR_MAIZE", 0.667);
public static final double CALIB_FACTOR_RICE = getDoubleProperty("CALIB_FACTOR_RICE", 1.232); public static final double CALIB_FACTOR_RICE = getDoubleProperty("CALIB_FACTOR_RICE", 1.247);
public static final double CALIB_FACTOR_OILCROPS = getDoubleProperty("CALIB_FACTOR_OILCROPS", 0.192); public static final double CALIB_FACTOR_OILCROPS = getDoubleProperty("CALIB_FACTOR_OILCROPS", 0.192);
public static final double CALIB_FACTOR_PULSES = getDoubleProperty("CALIB_FACTOR_PULSES", 0.583); public static final double CALIB_FACTOR_PULSES = getDoubleProperty("CALIB_FACTOR_PULSES", 0.583);
public static final double CALIB_FACTOR_STARCHY_ROOTS = getDoubleProperty("CALIB_FACTOR_STARCHY_ROOTS", 6.027); public static final double CALIB_FACTOR_STARCHY_ROOTS = getDoubleProperty("CALIB_FACTOR_STARCHY_ROOTS", 6.067);
// Spatial (gridded) data // Spatial (gridded) data
public static final double CELL_SIZE_X = getDoubleProperty("CELL_SIZE_X", 0.5); public static final double CELL_SIZE_X = getDoubleProperty("CELL_SIZE_X", 0.5);
...@@ -167,8 +167,9 @@ public class ModelConfig { ...@@ -167,8 +167,9 @@ public class ModelConfig {
public static final double TECHNOLOGY_CHANGE_ANNUAL_RATE = IS_CALIBRATION_RUN ? 0.0 : getDoubleProperty("TECHNOLOGY_CHANGE_ANNUAL_RATE", 0.0); public static final double TECHNOLOGY_CHANGE_ANNUAL_RATE = IS_CALIBRATION_RUN ? 0.0 : getDoubleProperty("TECHNOLOGY_CHANGE_ANNUAL_RATE", 0.0);
public static final int TECHNOLOGY_CHANGE_START_STEP = getIntProperty("TECHNOLOGY_CHANGE_START_STEP", 0); public static final int TECHNOLOGY_CHANGE_START_STEP = getIntProperty("TECHNOLOGY_CHANGE_START_STEP", 0);
public static final double BIOENERGY_CHANGE_ANNUAL_RATE = IS_CALIBRATION_RUN ? 0.0 : getDoubleProperty("BIOENERGY_CHANGE_ANNUAL_RATE", 0.0); public static final double BIOENERGY_CHANGE_ANNUAL_RATE = IS_CALIBRATION_RUN ? 0.0 : getDoubleProperty("BIOENERGY_CHANGE_ANNUAL_RATE", 0.0); // 6.2/2.31/20
public static final int BIOENERGY_CHANGE_START_YEAR = getIntProperty("BIOENERGY_CHANGE_START_YEAR", 2010); public static final int BIOENERGY_CHANGE_START_YEAR = getIntProperty("BIOENERGY_CHANGE_START_YEAR", 2010);
public static final int BIOENERGY_CHANGE_END_YEAR = getIntProperty("BIOENERGY_CHANGE_END_YEAR", 2030);
public static final double MARKET_LAMBA = getDoubleProperty("MARKET_LAMBA", 0.3); // controls international market price adjustment rate public static final double MARKET_LAMBA = getDoubleProperty("MARKET_LAMBA", 0.3); // controls international market price adjustment rate
......
...@@ -76,7 +76,7 @@ public class DemandManager { ...@@ -76,7 +76,7 @@ public class DemandManager {
if (bioenergyBaseDemand != null && bioenergyBaseDemand.containsKey(country)) { if (bioenergyBaseDemand != null && bioenergyBaseDemand.containsKey(country)) {
Double d = bioenergyBaseDemand.get(country).get(commodity); Double d = bioenergyBaseDemand.get(country).get(commodity);
int yearsOfChange = year - ModelConfig.BIOENERGY_CHANGE_START_YEAR; int yearsOfChange = Math.min(ModelConfig.BIOENERGY_CHANGE_END_YEAR - ModelConfig.BIOENERGY_CHANGE_START_YEAR, year - ModelConfig.BIOENERGY_CHANGE_START_YEAR);
double bioenergyDemandAdj = yearsOfChange > 0 ? (1.0 + yearsOfChange * ModelConfig.BIOENERGY_CHANGE_ANNUAL_RATE) : 1.0 ; double bioenergyDemandAdj = yearsOfChange > 0 ? (1.0 + yearsOfChange * ModelConfig.BIOENERGY_CHANGE_ANNUAL_RATE) : 1.0 ;
return d == null ? 0 : d.doubleValue() * bioenergyDemandAdj; return d == null ? 0 : d.doubleValue() * bioenergyDemandAdj;
......
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