Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PLUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Land Use Lab
PLUM
Commits
d897f009
Commit
d897f009
authored
6 years ago
by
R0slyn
Browse files
Options
Downloads
Patches
Plain Diff
added method for outputting prices for crafty and land use for just UK for RUGS scenario stuff.
parent
eb8998ac
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ac/ed/lurg/ModelConfig.java
+2
-0
2 additions, 0 deletions
src/ac/ed/lurg/ModelConfig.java
src/ac/ed/lurg/ModelMain.java
+77
-0
77 additions, 0 deletions
src/ac/ed/lurg/ModelMain.java
with
79 additions
and
0 deletions
src/ac/ed/lurg/ModelConfig.java
+
2
−
0
View file @
d897f009
...
...
@@ -226,6 +226,8 @@ public class ModelConfig {
public
static
final
String
DOMESTIC_OUTPUT_FILE
=
OUTPUT_DIR
+
File
.
separator
+
"domestic.txt"
;
public
static
final
String
COUNTRY_DEMAND_FILE
=
OUTPUT_DIR
+
File
.
separator
+
"countryDemand.txt"
;
public
static
final
String
FOOD_BALANCE_SHEET_FILE
=
OUTPUT_DIR
+
File
.
separator
+
"fbs.txt"
;
public
static
final
String
CRAFTY_PRICES_FILE
=
OUTPUT_DIR
+
File
.
separator
+
"craftyPriceFile.txt"
;
public
static
final
String
UK_LAND_COVER_OUTPUT_FILE
=
OUTPUT_DIR
+
File
.
separator
+
"ukLC.txt"
;
public
static
final
boolean
OUTPUT_FOR_LPJG
=
getBooleanProperty
(
"OUTPUT_FOR_LPJG"
,
true
);
public
static
final
boolean
INTERPOLATE_OUTPUT_YEARS
=
getBooleanProperty
(
"INTERPOLATE_OUTPUT_YEARS"
,
true
);
...
...
This diff is collapsed.
Click to expand it.
src/ac/ed/lurg/ModelMain.java
+
77
−
0
View file @
d897f009
...
...
@@ -167,6 +167,8 @@ public class ModelMain {
// doesn't change through time
if
(
ModelConfig
.
GENERATE_NEW_YIELD_CLUSTERS
&&
timestep
.
isInitialTimestep
())
clusterIdRaster
.
putAll
(
ca
.
getYieldClusters
());
if
(
ca
.
getCountry
().
getName
().
equals
(
"United Kingdom"
))
writeUKLandCoverFile
(
timestep
,
ca
);
}
internationalMarket
.
determineInternationalTrade
(
countryAgents
,
gen2EcDDemand
,
timestep
);
...
...
@@ -312,6 +314,46 @@ public class ModelMain {
LogWriter
.
print
(
e
);
}
}
private
void
writeCraftyPricesFile
(
Timestep
timestep
){
try
{
StringBuffer
sbHeadings
=
new
StringBuffer
(
"Year, Country, Crop,Import_price, Export_price"
);
BufferedWriter
outputFile
=
getFileWriter
(
timestep
,
ModelConfig
.
CRAFTY_PRICES_FILE
,
sbHeadings
.
toString
());
for
(
CropType
crop
:
CropType
.
getAllItems
())
{
for
(
CountryAgent
country
:
countryAgents
)
{
Map
<
CropType
,
CropUsageData
>
cropUsageAllCrops
=
country
.
getCropUsageData
();
CropUsageData
cropUsage
=
cropUsageAllCrops
.
get
(
crop
);
if
(
cropUsage
==
null
)
continue
;
Double
importPrice
=
null
;
Double
exportPrice
=
null
;
if
(
crop
.
isImportedCrop
())
{
CountryPrice
px
=
country
.
getCurrentCountryPrices
().
get
(
crop
);
importPrice
=
px
.
getImportPrice
();
exportPrice
=
px
.
getExportPrice
();
}
StringBuffer
sbData
=
new
StringBuffer
();
sbData
.
append
(
String
.
format
(
"%d,%s,%s"
,
timestep
.
getYear
(),
country
.
getCountry
(),
crop
.
getGamsName
()));
sbData
.
append
(
String
.
format
(
",%.3f,%.3f"
,
importPrice
,
exportPrice
));
outputFile
.
write
(
sbData
.
toString
());
outputFile
.
newLine
();
}
}
outputFile
.
close
();
}
catch
(
IOException
e
)
{
LogWriter
.
print
(
e
);
}
}
private
void
writeDomesticProductionFile
(
Timestep
timestep
)
{
try
{
...
...
@@ -361,6 +403,40 @@ private void writeDomesticProductionFile(Timestep timestep) {
}
}
private
void
writeUKLandCoverFile
(
Timestep
timestep
,
CountryAgent
ca
){
try
{
StringBuffer
sbHeadings
=
new
StringBuffer
(
"Year,Cropland,Pasture,ManForest,UnmanForest,Natural,AbPasture,EnergyCrop,FertCrop,IrrigCrop"
);
BufferedWriter
outputFile
=
getFileWriter
(
timestep
,
ModelConfig
.
UK_LAND_COVER_OUTPUT_FILE
,
sbHeadings
.
toString
());
StringBuffer
sbData
=
new
StringBuffer
();
Collection
<
RasterKey
>
countryKeys
=
countryBoundaryRaster
.
getKeysFor
(
ca
.
getCountry
());
RasterSet
<
LandUseItem
>
ukLandUse
=
globalLandUseRaster
.
createSubsetForKeys
(
countryKeys
);
sbData
.
append
(
String
.
format
(
"%d,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f"
,
timestep
.
getYear
(),
LandUseItem
.
getTotalLandCover
(
ukLandUse
.
values
(),
LandCoverType
.
CROPLAND
),
LandUseItem
.
getTotalLandCover
(
ukLandUse
.
values
(),
LandCoverType
.
PASTURE
),
LandUseItem
.
getTotalLandCover
(
ukLandUse
.
values
(),
LandCoverType
.
MANAGED_FOREST
),
LandUseItem
.
getTotalLandCover
(
ukLandUse
.
values
(),
LandCoverType
.
UNMANAGED_FOREST
),
LandUseItem
.
getTotalLandCover
(
ukLandUse
.
values
(),
LandCoverType
.
OTHER_NATURAL
),
LandUseItem
.
getAbandonedPasture
(
ukLandUse
.
values
()))
);
sbData
.
append
(
String
.
format
(
",%.1f"
,
LandUseItem
.
getTotalCropArea
(
ukLandUse
.
values
(),
CropType
.
ENERGY_CROPS
)));
sbData
.
append
(
String
.
format
(
",%.1f"
,
LandUseItem
.
getFertiliserTotal
(
ukLandUse
.
values
(),
CropType
.
getCropsLessPasture
())
/
1000
));
sbData
.
append
(
String
.
format
(
",%.1f"
,
LandUseItem
.
getIrrigationTotal
(
ukLandUse
.
values
(),
CropType
.
getCropsLessPasture
())));
outputFile
.
write
(
sbData
.
toString
());
outputFile
.
newLine
();
outputFile
.
close
();
}
catch
(
IOException
e
)
{
LogWriter
.
print
(
e
);
}
}
private
void
writeCountryDemandFile
(
Timestep
timestep
){
try
{
...
...
@@ -395,6 +471,7 @@ private void writeDomesticProductionFile(Timestep timestep) {
writeGlobalMarketFile
(
timestep
);
writeDemandFile
(
timestep
);
writeDomesticProductionFile
(
timestep
);
writeCraftyPricesFile
(
timestep
);
writeCountryDemandFile
(
timestep
);
writeGlobalFoodBalanceSheet
(
timestep
,
landUseRaster
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment