Skip to content
Snippets Groups Projects
Commit 5bb28899 authored by ALEXANDER Peter's avatar ALEXANDER Peter
Browse files

Merge branch 'master' of https://git.ecdf.ed.ac.uk/lul/plumv2

parents e9d86f8b e5a166a7
No related branches found
No related tags found
No related merge requests found
Country
United Kingdom
...@@ -372,6 +372,9 @@ public class ModelConfig { ...@@ -372,6 +372,9 @@ public class ModelConfig {
public static final boolean DEBUG_LIMIT_COUNTRIES = getBooleanProperty("DEBUG_LIMIT_COUNTRIES", false); public static final boolean DEBUG_LIMIT_COUNTRIES = getBooleanProperty("DEBUG_LIMIT_COUNTRIES", false);
public static final String DEBUG_COUNTRY_NAME = getProperty("DEBUG_COUNTRY_NAME", "United States of America"); public static final String DEBUG_COUNTRY_NAME = getProperty("DEBUG_COUNTRY_NAME", "United States of America");
public static final String GAMS_COUNTRY_TO_SAVE = getProperty("GAMS_COUNTRY_TO_SAVE", "China");; public static final String GAMS_COUNTRY_TO_SAVE = getProperty("GAMS_COUNTRY_TO_SAVE", "China");;
public static final boolean EXCLUDE_COUNTRIES_IN_LIST = getBooleanProperty("EXCLUDE_COUNTRIES_IN_LIST", false);
public static final String EXCLUDED_COUNTRIES_FILE = DATA_DIR + File.separator + "countries_excluded.csv";
public static final double PASTURE_MAX_IRRIGATION_RATE = getDoubleProperty("DEFAULT_MAX_IRRIGATION_RATE", 50.0); // shouldn't need this but some areas crops don't have a value, but was causing them to be selected public static final double PASTURE_MAX_IRRIGATION_RATE = getDoubleProperty("DEFAULT_MAX_IRRIGATION_RATE", 50.0); // shouldn't need this but some areas crops don't have a value, but was causing them to be selected
public static final int LPJG_TIMESTEP_SIZE = getIntProperty("LPJG_TIMESTEP_SIZE", 5); public static final int LPJG_TIMESTEP_SIZE = getIntProperty("LPJG_TIMESTEP_SIZE", 5);
......
...@@ -5,6 +5,8 @@ import java.util.HashMap; ...@@ -5,6 +5,8 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import ac.ed.lurg.ModelConfig; import ac.ed.lurg.ModelConfig;
import ac.ed.lurg.demand.BaseConsumpManager; import ac.ed.lurg.demand.BaseConsumpManager;
...@@ -17,6 +19,7 @@ public class CompositeCountryManager { ...@@ -17,6 +19,7 @@ public class CompositeCountryManager {
private Map<SingleCountry, CompositeCountry> mapFromSingleCountry; private Map<SingleCountry, CompositeCountry> mapFromSingleCountry;
private Map<CompositeCountry, List<SingleCountry>> mapFromCompositeCountry; private Map<CompositeCountry, List<SingleCountry>> mapFromCompositeCountry;
private StringTabularReader countryGroups; private StringTabularReader countryGroups;
private Set<String> countryExclusionList = new HashSet<String>();
public CompositeCountryManager(BaseConsumpManager baseConsumpManager) { public CompositeCountryManager(BaseConsumpManager baseConsumpManager) {
super(); super();
...@@ -24,6 +27,10 @@ public class CompositeCountryManager { ...@@ -24,6 +27,10 @@ public class CompositeCountryManager {
countryGroups = new StringTabularReader(",", new String[]{"Country", "PlumGroup"}); countryGroups = new StringTabularReader(",", new String[]{"Country", "PlumGroup"});
countryGroups.read(ModelConfig.COUNTRY_GROUPING_FILE); countryGroups.read(ModelConfig.COUNTRY_GROUPING_FILE);
} }
if (ModelConfig.EXCLUDE_COUNTRIES_IN_LIST) {
countryExclusionList = new StringTabularReader(",", new String[] {"Country"}).read(ModelConfig.EXCLUDED_COUNTRIES_FILE)
.stream().map(m -> m.get("Country")).collect(Collectors.toSet());
}
populate(baseConsumpManager); populate(baseConsumpManager);
} }
...@@ -38,14 +45,14 @@ public class CompositeCountryManager { ...@@ -38,14 +45,14 @@ public class CompositeCountryManager {
private void populate(BaseConsumpManager baseConsumpManager) { private void populate(BaseConsumpManager baseConsumpManager) {
mapFromSingleCountry = new HashMap<SingleCountry, CompositeCountry>(); mapFromSingleCountry = new HashMap<SingleCountry, CompositeCountry>();
HashSet<String> countryExclusionList = new HashSet<String>();
for (SingleCountry c : baseConsumpManager.getAllCountries()) { for (SingleCountry c : baseConsumpManager.getAllCountries()) {
CompositeCountry cc; CompositeCountry cc;
if (ModelConfig.PREDEFINED_COUNTRY_GROUPING) if (countryExclusionList.contains(c.getCountryName()))
continue;
else if (ModelConfig.PREDEFINED_COUNTRY_GROUPING)
cc = getForName(getCountryGroup(c),c.getRegion()); cc = getForName(getCountryGroup(c),c.getRegion());
else if (baseConsumpManager.getPopForGrouping(c) < ModelConfig.POPULATION_AGGREG_LIMIT || countryExclusionList.contains(c.getCountryName())) else if (baseConsumpManager.getPopForGrouping(c) < ModelConfig.POPULATION_AGGREG_LIMIT)
cc = getForName(c.getRegion() + "_other", c.getRegion()); cc = getForName(c.getRegion() + "_other", c.getRegion());
else else
cc = getForName(c.getCountryName(),c.getRegion()); cc = getForName(c.getCountryName(),c.getRegion());
......
...@@ -73,7 +73,7 @@ public class TradeManager { ...@@ -73,7 +73,7 @@ public class TradeManager {
CompositeCountry cc = compositeCountryManager.getForSingleCountry(country); CompositeCountry cc = compositeCountryManager.getForSingleCountry(country);
if (cc == null) { if (cc == null) {
LogWriter.printlnError("CompositeCountryManager: Can find country for " + country); continue;
} }
else { else {
CropToDoubleMap countryData = tradeMap.get(cc); CropToDoubleMap countryData = tradeMap.get(cc);
......
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