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
5cc78106
Commit
5cc78106
authored
Sep 04, 2019
by
Lambert Patrick
Browse files
export flux in effective
parent
f5467eb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
data/input/fishTryRealBV_CC.xml
View file @
5cc78106
...
...
@@ -300,6 +300,12 @@
<fileNameOutput>
lengthAgeDistribution
</fileNameOutput>
</species.ExportLenghtAgeDistribution>
<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/ExportFluxes.java
0 → 100644
View file @
5cc78106
/**
* patrick.lambert
* @author Patrick Lambert
* @copyright Copyright (c) 2018, Irstea
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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"
);
for
(
String
birthBasinName
:
group
.
getEnvironment
().
getRiverBasinNames
()){
bW
.
write
(
sep
+
birthBasinName
);
}
}
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 per 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 effetive 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 fisrt 2 fields of the line
bW
.
write
(
Time
.
getYear
(
pilot
)+
sep
+
migrationBasin
.
getName
());
// the cumulative effective from birth basin
for
(
String
natalBasinName
:
group
.
getEnvironment
().
getRiverBasinNames
()){
bW
.
write
(
sep
+
spawnerOriginsBeforeReproduction
.
get
(
natalBasinName
));
}
// 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
();
}
}
}
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