Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SimAquaLife
GR3D
Commits
fb60514b
Commit
fb60514b
authored
Jul 01, 2020
by
Lambert Patrick
Browse files
with right output path
parent
957c9e54
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/species/WriteCurrentNutrientExportFluxes.java
View file @
fb60514b
...
...
@@ -13,41 +13,40 @@ import environment.Time;
import
environment.Time.Season
;
import
fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess
;
public
class
WriteCurrentNutrientExportFluxes
extends
AquaNismsGroupProcess
<
DiadromousFish
,
DiadromousFishGroup
>
{
private
String
fileName
=
"currentNutrientExportFluxes"
;
private
String
fileName
=
"currentNutrientExportFluxes"
;
private
Season
writeSeason
=
Season
.
SPRING
;
private
transient
BufferedWriter
bW
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
((
new
XStream
(
new
DomDriver
()))
.
toXML
(
new
WriteCurrentNutrientExportFluxes
()));
System
.
out
.
println
((
new
XStream
(
new
DomDriver
())).
toXML
(
new
WriteCurrentNutrientExportFluxes
()));
}
@Override
public
void
doProcess
(
DiadromousFishGroup
group
)
{
String
sep
=
";"
;
String
sep
=
";"
;
Time
time
=
group
.
getEnvironment
().
getTime
();
// initialise the bW the first time
try
{
if
(
bW
==
null
)
{
String
outputPath
=
"data/output/"
;
if
(
bW
==
null
)
{
String
outputPath
=
group
.
getOutputPath
()
;
new
File
(
outputPath
+
fileName
).
getParentFile
().
mkdirs
();
bW
=
new
BufferedWriter
(
new
FileWriter
(
new
File
(
outputPath
+
fileName
+
group
.
getSimulationId
()
+
".csv"
)));
bW
=
new
BufferedWriter
(
new
FileWriter
(
new
File
(
outputPath
+
fileName
+
group
.
getSimulationId
()
+
".csv"
)));
bW
.
write
(
"year"
+
sep
+
"nutrient"
+
sep
+
"originBasin"
+
sep
+
"value"
+
"\n"
);
bW
.
write
(
"year"
+
sep
+
"nutrient"
+
sep
+
"originBasin"
+
sep
+
"value"
+
"\n"
);
}
// write information for the current year
Map
<
Long
,
Map
<
String
,
Map
<
String
,
Double
>>>
fluxesCollection
=
group
.
getNutrientRoutine
().
getNutrientExportFluxesCollection
().
getExportFluxesCollection
();
Map
<
Long
,
Map
<
String
,
Map
<
String
,
Double
>>>
fluxesCollection
=
group
.
getNutrientRoutine
()
.
getNutrientExportFluxesCollection
().
getExportFluxesCollection
();
long
year
=
time
.
getYear
(
group
.
getPilot
());
...
...
@@ -55,15 +54,16 @@ public class WriteCurrentNutrientExportFluxes extends AquaNismsGroupProcess<Diad
for
(
String
nutrient
:
group
.
getNutrientRoutine
().
getNutrientsOfInterest
())
{
for
(
String
originBasinName
:
group
.
getEnvironment
().
getRiverBasinNames
())
{
bW
.
write
(
year
+
sep
+
nutrient
+
sep
+
originBasinName
);
bW
.
write
(
sep
+
fluxesCollection
.
get
(
year
).
get
(
nutrient
).
get
(
originBasinName
)
);
bW
.
write
(
year
+
sep
+
nutrient
+
sep
+
originBasinName
);
bW
.
write
(
sep
+
fluxesCollection
.
get
(
year
).
get
(
nutrient
).
get
(
originBasinName
));
}
bW
.
write
(
"\n"
);
}
}
// close the bW
if
(
group
.
getPilot
().
getCurrentTime
()==
group
.
getPilot
().
getSimBegin
()+
group
.
getPilot
().
getSimDuration
()-
1
){
if
(
group
.
getPilot
().
getCurrentTime
()
==
group
.
getPilot
().
getSimBegin
()
+
group
.
getPilot
().
getSimDuration
()
-
1
)
{
bW
.
flush
();
bW
.
close
();
}
...
...
src/main/java/species/WriteCurrentNutrientImportFluxes.java
View file @
fb60514b
...
...
@@ -4,11 +4,7 @@ import java.io.BufferedWriter;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
com.thoughtworks.xstream.XStream
;
import
com.thoughtworks.xstream.io.xml.DomDriver
;
...
...
@@ -19,60 +15,60 @@ import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
public
class
WriteCurrentNutrientImportFluxes
extends
AquaNismsGroupProcess
<
DiadromousFish
,
DiadromousFishGroup
>
{
private
String
fileName
=
"currentNutrientImporttFluxes"
;
private
String
fileName
=
"currentNutrientImporttFluxes"
;
private
Season
writeSeason
=
Season
.
SPRING
;
private
transient
BufferedWriter
bW
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
((
new
XStream
(
new
DomDriver
()))
.
toXML
(
new
WriteCurrentNutrientImportFluxes
()));
System
.
out
.
println
((
new
XStream
(
new
DomDriver
())).
toXML
(
new
WriteCurrentNutrientImportFluxes
()));
}
@Override
public
void
doProcess
(
DiadromousFishGroup
group
)
{
String
sep
=
";"
;
String
sep
=
";"
;
Time
time
=
group
.
getEnvironment
().
getTime
();
try
{
// initialise the bW the first time
if
(
bW
==
null
)
{
if
(
bW
==
null
)
{
String
outputPath
=
"data/output/"
;
String
outputPath
=
group
.
getOutputPath
()
;
new
File
(
outputPath
+
fileName
).
getParentFile
().
mkdirs
();
bW
=
new
BufferedWriter
(
new
FileWriter
(
new
File
(
outputPath
+
fileName
+
group
.
getSimulationId
()
+
".csv"
)));
bW
=
new
BufferedWriter
(
new
FileWriter
(
new
File
(
outputPath
+
fileName
+
group
.
getSimulationId
()
+
".csv"
)));
bW
.
write
(
"year"
+
sep
+
"nutrient"
+
sep
+
"originBasin"
);
bW
.
write
(
"year"
+
sep
+
"nutrient"
+
sep
+
"originBasin"
);
for
(
String
birthBasinName
:
group
.
getEnvironment
().
getRiverBasinNames
())
{
bW
.
write
(
sep
+
birthBasinName
);
// write each basin name in the file
bW
.
write
(
sep
+
birthBasinName
);
// write each basin name in the file
}
bW
.
write
(
"\n"
);
}
Map
<
Long
,
Map
<
String
,
Map
<
String
,
Map
<
String
,
Double
>>>>
fluxesCollection
=
group
.
getNutrientRoutine
().
getNutrientImportFluxesCollection
().
getImportFluxesCollection
();
Map
<
Long
,
Map
<
String
,
Map
<
String
,
Map
<
String
,
Double
>>>>
fluxesCollection
=
group
.
getNutrientRoutine
()
.
getNutrientImportFluxesCollection
().
getImportFluxesCollection
();
long
year
=
time
.
getYear
(
group
.
getPilot
());
if
(
year
>=
group
.
getMinYearToWrite
()
&
time
.
getSeason
(
group
.
getPilot
())
==
writeSeason
)
{
Map
<
String
,
Map
<
String
,
Map
<
String
,
Double
>>>
yearsMap
=
fluxesCollection
.
get
(
year
);
Map
<
String
,
Map
<
String
,
Map
<
String
,
Double
>>>
yearsMap
=
fluxesCollection
.
get
(
year
);
for
(
String
nutrient
:
group
.
getNutrientRoutine
().
getNutrientsOfInterest
())
{
Map
<
String
,
Map
<
String
,
Double
>>
originsMap
=
yearsMap
.
get
(
nutrient
);
Map
<
String
,
Map
<
String
,
Double
>>
originsMap
=
yearsMap
.
get
(
nutrient
);
for
(
String
originBasinName
:
group
.
getEnvironment
().
getRiverBasinNames
())
{
bW
.
write
(
year
+
sep
+
nutrient
+
sep
+
originBasinName
);
Map
<
String
,
Double
>
destinationsMap
=
originsMap
.
get
(
originBasinName
);
bW
.
write
(
year
+
sep
+
nutrient
+
sep
+
originBasinName
);
Map
<
String
,
Double
>
destinationsMap
=
originsMap
.
get
(
originBasinName
);
for
(
String
destinationBasinName
:
group
.
getEnvironment
().
getRiverBasinNames
())
{
Double
aFlux
=
destinationsMap
.
get
(
destinationBasinName
);
bW
.
write
(
sep
+
aFlux
);
Double
aFlux
=
destinationsMap
.
get
(
destinationBasinName
);
bW
.
write
(
sep
+
aFlux
);
}
bW
.
write
(
"\n"
);
}
...
...
@@ -80,7 +76,8 @@ public class WriteCurrentNutrientImportFluxes extends AquaNismsGroupProcess<Diad
}
// close the bW
if
(
group
.
getPilot
().
getCurrentTime
()==
group
.
getPilot
().
getSimBegin
()+
group
.
getPilot
().
getSimDuration
()-
1
){
if
(
group
.
getPilot
().
getCurrentTime
()
==
group
.
getPilot
().
getSimBegin
()
+
group
.
getPilot
().
getSimDuration
()
-
1
)
{
bW
.
flush
();
bW
.
close
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment