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

more irrig tweaks

parent c5d3d962
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ import ac.ed.lurg.landuse.CropUsageReader;
import ac.ed.lurg.landuse.IrrigationItem;
import ac.ed.lurg.landuse.IrrigationMaxAmountReader;
import ac.ed.lurg.landuse.IrrigationRasterSet;
import ac.ed.lurg.landuse.IrrigiationCostReader;
import ac.ed.lurg.landuse.LandCoverItem;
import ac.ed.lurg.landuse.LandCoverReader;
import ac.ed.lurg.landuse.LandUseItem;
......@@ -98,7 +99,7 @@ public class ModelMain {
tradeManager = new TradeManager(compositeCountryManager);
fpuManager = new FPUManager(desiredProjection);
currentIrrigationData = new IrrigationRasterSet(desiredProjection);
currentIrrigationData = getFixedIrrigationData();
countryBoundaryRaster = getCountryBoundaryRaster();
clusterIdRaster = (ModelConfig.IS_CALIBRATION_RUN) ? new RasterSet<IntegerRasterItem>(desiredProjection) : getClusterRaster();
......@@ -551,6 +552,12 @@ public class ModelMain {
}
private IrrigationRasterSet getFixedIrrigationData() {
IrrigationRasterSet fixedIrrigData = new IrrigationRasterSet(desiredProjection);
new IrrigiationCostReader(fixedIrrigData).getRasterDataFromFile(ModelConfig.IRRIGATION_COST_FILE);
return fixedIrrigData;
}
private RasterSet<IrrigationItem> getUpdateIrrigationData(Timestep timestep, YieldRaster yieldSurfaces) {
String rootDir = timestep.getYearSubDir(ModelConfig.YIELD_DIR);
new IrrigationMaxAmountReader(currentIrrigationData, yieldSurfaces).getRasterDataFromFile(rootDir + File.separator + ModelConfig.IRRIG_MAX_WATER_FILENAME);
......
......
......@@ -35,6 +35,7 @@ public class FPUManager {
public void getFPUBoundaryRaster(RasterHeaderDetails desiredProjection) {
fpuBoundaries = new RasterSet<IntegerRasterItem>(desiredProjection) {
private static final long serialVersionUID = -8620255271155259176L;
protected IntegerRasterItem createRasterData() {
return new IntegerRasterItem(0);
}
......@@ -48,7 +49,9 @@ public class FPUManager {
public void readOtherUses() {
LazyHashMap<Integer, Map<Integer, Double>> usageMap = new LazyHashMap<Integer, Map<Integer, Double>>() {
protected Map<Integer, Double> createValue() { return new HashMap<Integer, Double>(); }
protected Map<Integer, Double> createValue() {
return new HashMap<Integer, Double>();
}
};
String filename = ModelConfig.OTHER_WATER_USES_FILE;
......@@ -66,7 +69,6 @@ public class FPUManager {
if (tokens.length < 3)
LogWriter.printlnError("Too few columns in " + filename + ", " + line);
fpu = Integer.parseInt(tokens[FPU_COL]);
year = Integer.parseInt(tokens[YEAR_COL]);
waterUsage = Double.parseDouble(tokens[USAGE_COL]);
......@@ -85,9 +87,6 @@ public class FPUManager {
fpuOtherUses = usageMap;
}
public List<RasterKey> getKeysFor(IntegerRasterItem fpu) {
List<RasterKey> keys = fpuMap.get(fpu);
if (keys == null)
......@@ -95,5 +94,4 @@ public class FPUManager {
return keys;
}
}
......@@ -5,6 +5,7 @@ import java.util.Map;
import ac.ed.lurg.ModelConfig;
import ac.ed.lurg.Timestep;
import ac.ed.lurg.utils.LogWriter;
import ac.sac.raster.IntegerRasterItem;
import ac.sac.raster.RasterHeaderDetails;
import ac.sac.raster.RasterKey;
......@@ -16,10 +17,8 @@ public class IrrigationRasterSet extends RasterSet<IrrigationItem>{
public IrrigationRasterSet(RasterHeaderDetails header) {
super(header);
new IrrigiationCostReader(this).getRasterDataFromFile(ModelConfig.IRRIGATION_COST_FILE); //this isn't very nice in here...
}
protected IrrigationItem createRasterData() {
return new IrrigationItem();
}
......@@ -33,8 +32,6 @@ public class IrrigationRasterSet extends RasterSet<IrrigationItem>{
double waterAvailabilityAdj = 1.0 + yearsOfIrrigChange * ModelConfig.WATER_AVAILIBILITY_RATE_OF_CHANGE;
int year = timestep.getYear();
for (IntegerRasterItem fpu : keyset) {
fpuKeys = fpuManager.getKeysFor(fpu);
......@@ -46,23 +43,24 @@ public class IrrigationRasterSet extends RasterSet<IrrigationItem>{
for (Map.Entry<RasterKey, IrrigationItem> entry : irrigData.entrySet()) {
if (entry.getValue() != null) {
fpuRunOff += entry.getValue().getRunOff()*fpuManager.fpuBoundaries.getAreaMha(entry.getKey())*0.01;
fpuRunOff += entry.getValue().getRunOff() * fpuManager.fpuBoundaries.getAreaMha(entry.getKey())
* 0.01;
cellCount++;
}
}
Double fpuRunOffAvailable = fpuRunOff*0.4 * ModelConfig.ENVIRONMENTAL_WATER_CONSTRAINT; //0.4 from elliott paper
Double fpuRunOffAvailable = fpuRunOff * 0.4 * ModelConfig.ENVIRONMENTAL_WATER_CONSTRAINT; // 0.4
// from
// elliott
// paper
otherUses = fpuManager.fpuOtherUses.get(fpu.getInt()).get(year) * waterAvailabilityAdj;
if (fpuRunOffAvailable - otherUses < 0) {
waterAvailForIrrigPerCell = 0;
}
else waterAvailForIrrigPerCell = (fpuRunOffAvailable - otherUses) / cellCount;
} else
waterAvailForIrrigPerCell = (fpuRunOffAvailable - otherUses) / cellCount;
for (Map.Entry<RasterKey, IrrigationItem> entry : irrigData.entrySet()) {
if (entry.getValue() != null) {
......@@ -75,5 +73,4 @@ public class IrrigationRasterSet extends RasterSet<IrrigationItem>{
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment