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
dd081b0a
Commit
dd081b0a
authored
Sep 06, 2019
by
Poulet Camille
Browse files
Add Export Fluxes Class
Export the effective fluxes between watersheds
parent
e403278f
Changes
4
Hide whitespace changes
Inline
Side-by-side
data/input/fishTryRealBV_CC.xml
View file @
dd081b0a
...
...
@@ -279,6 +279,7 @@
<standardDeviationOfSpawnersLengthAtRepro>
2.0
</standardDeviationOfSpawnersLengthAtRepro>
<weightOfDeathBasin>
0.4
</weightOfDeathBasin>
</species.DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin>
<species.Survive>
<synchronisationMode>
ASYNCHRONOUS
</synchronisationMode>
<tempMinMortGenInRiv>
10.0
</tempMinMortGenInRiv>
...
...
@@ -289,6 +290,13 @@
<mortalityRateInSea>
0.4
</mortalityRateInSea>
<mortalityRateInOffshore>
0.4
</mortalityRateInOffshore>
</species.Survive>
<species.ExportFluxes>
<synchronisationMode>
ASYNCHRONOUS
</synchronisationMode>
<exportSeason>
SPRING
</exportSeason>
<fileNameOutput>
EffectiveFluxes
</fileNameOutput>
</species.ExportFluxes>
<species.ReproduceAndSurviveAfterReproductionWithDiagnose>
<synchronisationMode>
ASYNCHRONOUS
</synchronisationMode>
<reproductionSeason>
SPRING
</reproductionSeason>
...
...
src/main/java/species/DiadromousFishGroup.java
View file @
dd081b0a
...
...
@@ -412,7 +412,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
fileNameFluxes
+
this
.
getSimulationId
()
+
".csv"
)));
bWForFluxes
.
write
(
"timestep"
+
sep
+
"year"
+
sep
+
"season"
+
sep
+
"basin"
+
sep
+
"abundance"
+
sep
+
"fluxType"
+
sep
+
"origin
e
"
+
sep
+
"biomass"
);
+
sep
+
"abundance"
+
sep
+
"fluxType"
+
sep
+
"origin"
+
sep
+
"biomass"
);
for
(
String
nutrient
:
nutrientRoutine
.
getNutrientsOfInterest
())
{
bWForFluxes
.
write
(
sep
+
nutrient
);
}
...
...
src/main/java/species/ExportFluxes.java
0 → 100644
View file @
dd081b0a
package
species
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.thoughtworks.xstream.XStream
;
import
com.thoughtworks.xstream.io.xml.DomDriver
;
import
environment.RiverBasin
;
import
environment.Time
;
import
environment.Time.Season
;
import
fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess
;
import
fr.cemagref.simaqualife.pilot.Pilot
;
import
species.DiadromousFish.Stage
;
/**
*
*/
public
class
ExportFluxes
extends
AquaNismsGroupProcess
<
DiadromousFish
,
DiadromousFishGroup
>
{
private
Season
exportSeason
=
Season
.
SPRING
;
private
String
fileNameOutput
=
"EffectiveFluxes"
;
private
transient
BufferedWriter
bW
;
private
transient
String
sep
=
";"
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
((
new
XStream
(
new
DomDriver
()))
.
toXML
(
new
ExportFluxes
()));
}
/* (non-Javadoc)
* @see fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess#initTransientParameters(fr.cemagref.simaqualife.pilot.Pilot)
*/
@Override
public
void
initTransientParameters
(
Pilot
pilot
)
{
super
.
initTransientParameters
(
pilot
);
sep
=
";"
;
}
@Override
public
void
doProcess
(
DiadromousFishGroup
group
)
{
if
(
bW
==
null
){
if
(
fileNameOutput
!=
null
){
new
File
(
group
.
getOutputPath
()+
fileNameOutput
).
getParentFile
().
mkdirs
();
try
{
bW
=
new
BufferedWriter
(
new
FileWriter
(
new
File
(
group
.
getOutputPath
()+
fileNameOutput
+
group
.
getSimulationId
()+
".csv"
)));
bW
.
write
(
"year"
+
sep
+
"migrationBasin"
);
//create the field of the column
for
(
String
birthBasinName
:
group
.
getEnvironment
().
getRiverBasinNames
())
{
bW
.
write
(
sep
+
birthBasinName
);
// write each basin name in the file
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
try
{
if
(
Time
.
getSeason
(
pilot
)
==
exportSeason
&
Time
.
getYear
(
pilot
)>
1900
)
{
for
(
RiverBasin
migrationBasin
:
group
.
getEnvironment
().
getRiverBasins
())
{
//Create the map to get the abundance in each birth basin
Map
<
String
,
Long
>
spawnerOriginsBeforeReproduction
=
new
HashMap
<
String
,
Long
>(
group
.
getEnvironment
().
getRiverBasinNames
().
length
);
for
(
String
basinName
:
group
.
getEnvironment
().
getRiverBasinNames
()){
spawnerOriginsBeforeReproduction
.
put
(
basinName
,
0L
);
}
//compute the cumulative effective per birth basin
if
(
migrationBasin
.
getFishs
(
group
)
!=
null
)
{
for
(
DiadromousFish
fish
:
migrationBasin
.
getFishs
(
group
))
{
if
(
fish
.
getStage
()
==
Stage
.
MATURE
)
{
String
birthBasinName
=
fish
.
getBirthBasin
().
getName
();
spawnerOriginsBeforeReproduction
.
put
(
birthBasinName
,
spawnerOriginsBeforeReproduction
.
get
(
birthBasinName
)
+
fish
.
getAmount
());
}
}
}
//write the first two fields of the line
bW
.
write
(
Time
.
getYear
(
pilot
)+
sep
+
migrationBasin
.
getName
());
//write the cumulative effective from birth basin
for
(
String
birthBasinName
:
group
.
getEnvironment
().
getRiverBasinNames
())
{
bW
.
write
(
sep
+
spawnerOriginsBeforeReproduction
.
get
(
birthBasinName
));
}
//write an end-of(line
bW
.
write
(
"\n"
);
}
}
if
(
group
.
getPilot
().
getCurrentTime
()==
group
.
getPilot
().
getSimBegin
()+
group
.
getPilot
().
getSimDuration
()-
1
)
bW
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
src/main/java/species/ReproduceAndSurviveAfterReproductionWithDiagnose.java
View file @
dd081b0a
...
...
@@ -3,6 +3,7 @@ package species;
import
java.io.BufferedWriter
;
import
java.io.IOException
;
import
java.io.ObjectInputStream.GetField
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Hashtable
;
...
...
@@ -169,7 +170,7 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
// age of autochnonous spawnser
Map
<
Integer
,
Long
>
ageOfNativeSpawners
=
new
TreeMap
<
Integer
,
Long
>();
// compute the number of spawners and keep the origines of the spawners
for
(
DiadromousFish
fish
:
fishInBasin
){
...
...
@@ -410,9 +411,9 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
try
{
for
(
fluxOrigin
origin
:
totalInputFluxes
.
keySet
())
{
bW
.
write
(
group
.
getPilot
().
getCurrentTime
()
+
"; "
+
Time
.
getYear
(
group
.
getPilot
())
+
";"
+
Time
.
getSeason
(
group
.
getPilot
())
+
";"
+
riverBasin
.
getName
()
+
";"
+
riverBasin
.
getSpawnerNumber
()
+
";"
+
"
;
IMPORT
;
"
+
origin
);
+
";"
+
riverBasin
.
getName
()
+
";"
+
riverBasin
.
getSpawnerNumber
()
+
";"
+
"IMPORT"
+
";"
+
origin
);
bW
.
write
(
";"
+
totalInputFluxes
.
get
(
origin
).
get
(
"biomass"
));
for
(
String
nutrient
:
group
.
getNutrientRoutine
().
getNutrientsOfInterest
())
{
bW
.
write
(
";"
+
totalInputFluxes
.
get
(
origin
).
get
(
nutrient
));
}
...
...
@@ -434,8 +435,8 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
riverBasin
.
getSpawnerOrigins
().
push
(
spawnerOriginsDuringReproduction
);
//System.out.println(" AFTER " +riverBasin.getSpawnerOrigins().keySet());
}
// --------------------------------------------------------------------------------------------------
// update the observers
// --------------------------------------------------------------------------------------------------
...
...
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