Commit a7f77b00 authored by patrick.lambert's avatar patrick.lambert
Browse files

mobe getSimultationId from group to BainNetwork

parent 435d2e8f
......@@ -159,8 +159,8 @@ public class ExportExchangeSBetweenCatchments extends AquaNismsGroupProcess<Diad
sep = ",";
try {
new File(group.getOutputPath() + fileNameOutput).getParentFile().mkdirs();
bW = new BufferedWriter(
new FileWriter(new File(group.getOutputPath() + fileNameOutput + group.getSimulationId() + ".csv")));
bW = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameOutput + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("year" + sep + "migrationBasin" + sep + "natalBasin" + sep + "effective");
bW.write("\n");
......
......@@ -33,8 +33,8 @@ import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import fr.cemagref.simaqualife.pilot.Pilot;
import species.DiadromousFish;
import species.DiadromousFishGroup;
import species.DiadromousFish.Stage;
import species.DiadromousFishGroup;
/**
*
......@@ -46,35 +46,40 @@ public class ExportLenghtAgeDistribution extends AquaNismsGroupProcess<Diadromou
private String fileNameOutput = "lengthAgeDistribution";
private transient BufferedWriter bW;
private transient String sep=";";
private transient String sep = ";";
public static void main(String[] args) {
System.out.println((new XStream(new DomDriver()))
.toXML(new ExportLenghtAgeDistribution()));
System.out.println((new XStream(new DomDriver())).toXML(new ExportLenghtAgeDistribution()));
}
/* (non-Javadoc)
* @see fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess#initTransientParameters(fr.cemagref.simaqualife.pilot.Pilot)
/*
* (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=";";
sep = ";";
}
@Override
public void doProcess(DiadromousFishGroup group) {
if (bW==null){
if (fileNameOutput != null){
new File(group.getOutputPath()+fileNameOutput).getParentFile().mkdirs();
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 = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameOutput + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("timestep"+sep+"year"+sep+"season"+sep+"basin"+ sep+"gender"
+sep+ "effective" +sep+"length"+sep+"age"+sep+"nbSpawn"+"\n");
bW.write("timestep" + sep + "year" + sep + "season" + sep + "basin" + sep + "gender" + sep + "effective" + sep
+ "length" + sep + "age" + sep + "nbSpawn" + "\n");
} catch (IOException e) {
e.printStackTrace();
......@@ -84,14 +89,15 @@ public class ExportLenghtAgeDistribution extends AquaNismsGroupProcess<Diadromou
try {
Time time = group.getEnvironment().getTime();
if (time.getSeason(pilot) == exportSeason & time.getYear(pilot)>1900) {
if (time.getSeason(pilot) == exportSeason & time.getYear(pilot) > 1900) {
for (RiverBasin basin : group.getEnvironment().getRiverBasins()) {
if (basin.getFishs(group) != null) {
for (DiadromousFish fish : basin.getFishs(group)) {
if (fish.getStage() == Stage.MATURE) {
//System.out.println(fish.getAge() + " -> "+ fish.getLength() +" - "+fish.getNumberOfReproduction());
// System.out.println(fish.getAge() + " -> "+ fish.getLength() +" -
// "+fish.getNumberOfReproduction());
bW.write(pilot.getCurrentTime() + sep);
bW.write(time.getYear(pilot) + sep);
bW.write(time.getSeason(pilot) + sep);
......@@ -99,18 +105,17 @@ public class ExportLenghtAgeDistribution extends AquaNismsGroupProcess<Diadromou
bW.write(fish.getGender() + sep);
bW.write(fish.getAmount() + sep);
bW.write(fish.getLength() + sep);
bW.write(fish.getAge()+ sep);
bW.write(fish.getNumberOfReproduction()+ "\n");
bW.write(fish.getAge() + sep);
bW.write(fish.getNumberOfReproduction() + "\n");
}
}
}
}
}
if (group.getPilot().getCurrentTime()== group.getPilot().getSimBegin()+group.getPilot().getSimDuration()-1)
if (group.getPilot().getCurrentTime() == group.getPilot().getSimBegin() + group.getPilot().getSimDuration() - 1)
bW.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -45,8 +45,8 @@ public class ExportMeanRecruitment extends AquaNismsGroupProcess<DiadromousFish,
if (fileNameOutput != null) {
try {
new File(group.getOutputPath() + fileNameOutput).getParentFile().mkdirs();
bW = new BufferedWriter(
new FileWriter(new File(group.getOutputPath() + fileNameOutput + group.getSimulationId() + ".csv")));
bW = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameOutput + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("timestep" + sep + "year" + sep + "season");
......
......@@ -50,8 +50,8 @@ public class ExportPopulationStatus extends AquaNismsGroupProcess<DiadromousFish
if (bWMortality == null) {
new File(group.getOutputPath() + fileNameMortality).getParentFile().mkdirs();
bWMortality = new BufferedWriter(new FileWriter(
new File(group.getOutputPath() + fileNameMortality + group.getSimulationId() + ".csv")));
bWMortality = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameMortality + group.getEnvironment().getSimulationId() + ".csv")));
bWMortality.write("timestep" + sep + "year" + sep + "season");
......@@ -66,8 +66,8 @@ public class ExportPopulationStatus extends AquaNismsGroupProcess<DiadromousFish
if (bWMortalityCrash == null) {
new File(group.getOutputPath() + fileNameMortalityCrash).getParentFile().mkdirs();
bWMortalityCrash = new BufferedWriter(new FileWriter(
new File(group.getOutputPath() + fileNameMortalityCrash + group.getSimulationId() + ".csv")));
bWMortalityCrash = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameMortalityCrash + group.getEnvironment().getSimulationId() + ".csv")));
bWMortalityCrash.write("timestep" + sep + "year" + sep + "season");
......@@ -82,8 +82,8 @@ public class ExportPopulationStatus extends AquaNismsGroupProcess<DiadromousFish
if (bWStockTrap == null) {
new File(group.getOutputPath() + fileNameStockTrap).getParentFile().mkdirs();
bWStockTrap = new BufferedWriter(new FileWriter(
new File(group.getOutputPath() + fileNameStockTrap + group.getSimulationId() + ".csv")));
bWStockTrap = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameStockTrap + group.getEnvironment().getSimulationId() + ".csv")));
bWStockTrap.write("timestep" + sep + "year" + sep + "season");
......@@ -98,8 +98,8 @@ public class ExportPopulationStatus extends AquaNismsGroupProcess<DiadromousFish
if (bwPopulationStatus == null) {
new File(group.getOutputPath() + fileNamePopulationStatus).getParentFile().mkdirs();
bwPopulationStatus = new BufferedWriter(new FileWriter(
new File(group.getOutputPath() + fileNamePopulationStatus + group.getSimulationId() + ".csv")));
bwPopulationStatus = new BufferedWriter(new FileWriter(new File(group.getOutputPath()
+ fileNamePopulationStatus + group.getEnvironment().getSimulationId() + ".csv")));
bwPopulationStatus.write("timestep" + sep + "year" + sep + "season");
......
......@@ -43,8 +43,8 @@ public class ExportRecruitment extends AquaNismsGroupProcess<DiadromousFish, Dia
if (fileNameOutput != null) {
try {
new File(group.getOutputPath() + fileNameOutput).getParentFile().mkdirs();
bW = new BufferedWriter(
new FileWriter(new File(group.getOutputPath() + fileNameOutput + group.getSimulationId() + ".csv")));
bW = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameOutput + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("timestep" + sep + "year" + sep + "season");
......
......@@ -84,8 +84,8 @@ public class ExportSpeciesRange extends AquaNismsGroupProcess<DiadromousFish, Di
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 = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameOutput + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("timestep" + sep + "year" + sep + "season" + sep + "medianRange" + sep + "southRange" + sep
+ "northRange" + sep + "centileRange" + "\n");
......
......@@ -235,8 +235,8 @@ public class TypeTrajectoryCV extends AquaNismsGroupProcess<DiadromousFish, Diad
new File(group.getOutputPath() + fileNameOutput).getParentFile().mkdirs();
try {
bW = new BufferedWriter(
new FileWriter(new File(group.getOutputPath() + fileNameOutput + group.getSimulationId() + ".csv")));
bW = new BufferedWriter(new FileWriter(
new File(group.getOutputPath() + fileNameOutput + group.getEnvironment().getSimulationId() + ".csv")));
int nbBV = finalStatesNames.length;
bW.write("nom des bv");
......
......@@ -16,8 +16,8 @@ import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import fr.cemagref.simaqualife.pilot.Pilot;
import species.DiadromousFish;
import species.DiadromousFishGroup;
import species.DiadromousFish.Stage;
import species.DiadromousFishGroup;
/**
*
......@@ -31,7 +31,6 @@ public class WriteBiomassFluxes extends AquaNismsGroupProcess<DiadromousFish, Di
private transient BufferedWriter bW;
private transient String sep = ";";
public static void main(String[] args) {
System.out.println((new XStream(new DomDriver())).toXML(new WriteBiomassFluxes()));
}
......@@ -58,8 +57,8 @@ public class WriteBiomassFluxes extends AquaNismsGroupProcess<DiadromousFish, Di
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 = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameOutput + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("year" + sep + "migrationBasin"); // create the field of the column
for (String birthBasinName : group.getEnvironment().getRiverBasinNames()) {
......
......@@ -22,7 +22,6 @@ public class WriteCurrentNutrientExportFluxes extends AquaNismsGroupProcess<Diad
private transient BufferedWriter bW;
public static void main(String[] args) {
System.out.println((new XStream(new DomDriver())).toXML(new WriteCurrentNutrientExportFluxes()));
}
......@@ -41,7 +40,7 @@ public class WriteCurrentNutrientExportFluxes extends AquaNismsGroupProcess<Diad
new File(outputPath + fileName).getParentFile().mkdirs();
bW = new BufferedWriter(
new FileWriter(new File(outputPath + fileName + group.getSimulationId() + ".csv")));
new FileWriter(new File(outputPath + fileName + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("year" + sep + "nutrient" + sep + "originBasin" + sep + "value" + "\n");
}
......@@ -64,8 +63,7 @@ public class WriteCurrentNutrientExportFluxes 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();
}
......
......@@ -22,7 +22,6 @@ public class WriteCurrentNutrientImportFluxes extends AquaNismsGroupProcess<Diad
private transient BufferedWriter bW;
public static void main(String[] args) {
System.out.println((new XStream(new DomDriver())).toXML(new WriteCurrentNutrientImportFluxes()));
......@@ -43,7 +42,7 @@ public class WriteCurrentNutrientImportFluxes extends AquaNismsGroupProcess<Diad
new File(outputPath + fileName).getParentFile().mkdirs();
bW = new BufferedWriter(
new FileWriter(new File(outputPath + fileName + group.getSimulationId() + ".csv")));
new FileWriter(new File(outputPath + fileName + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("year" + sep + "nutrient" + sep + "originBasin");
for (String birthBasinName : group.getEnvironment().getRiverBasinNames()) {
......@@ -78,8 +77,7 @@ 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();
}
......
......@@ -4,7 +4,6 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.ListIterator;
......@@ -18,8 +17,8 @@ import environment.Time;
import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import species.DiadromousFish;
import species.DiadromousFishGroup;
import species.DiadromousFish.Stage;
import species.DiadromousFishGroup;
public class WriteEffectiveAndBiomassExportFluxes extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> {
......@@ -46,40 +45,40 @@ public class WriteEffectiveAndBiomassExportFluxes extends AquaNismsGroupProcess<
new File(outputPath + fileName).getParentFile().mkdirs();
bW = new BufferedWriter(
new FileWriter(new File(outputPath + fileName + group.getSimulationId() + ".csv")));
new FileWriter(new File(outputPath + fileName + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("year" + sep + "originBasin" + sep + "abundance" + sep + "biomass" + "\n");
}
// write information for the current year
Map<String, Double> totalOutputFluxes = new Hashtable<String, Double>();
Map<String, Double> totalOutputFluxes = new Hashtable<String, Double>();
long year = time.getYear(group.getPilot());
if (year >= group.getMinYearToWrite() & time.getSeason(group.getPilot()) == writeSeason) {
for (RiverBasin basin : group.getEnvironment().getRiverBasins()){
if (year >= group.getMinYearToWrite() & time.getSeason(group.getPilot()) == writeSeason) {
for (RiverBasin basin : group.getEnvironment().getRiverBasins()) {
totalOutputFluxes.put("biomass", 0.); //cr�ation de la biomasse
totalOutputFluxes.put("biomass", 0.); // cr�ation de la biomasse
totalOutputFluxes.put("abundance", 0.);
List<DiadromousFish> fishes = basin.getFishs(group);
if (fishes!=null) {
if (fishes != null) {
ListIterator<DiadromousFish> fishIterator = fishes.listIterator();
// for (DiadromousFish fish : fishes) {
while (fishIterator.hasNext()) {
DiadromousFish fish = fishIterator.next();
if (fish.getStage()==Stage.IMMATURE) {
if (fish.getStage() == Stage.IMMATURE) {
double abundanceExp = fish.getAmount();
double biomass = group.getNutrientRoutine().getWeight(fish) * fish.getAmount();
totalOutputFluxes.put("biomass", totalOutputFluxes.get("biomass") + biomass);
totalOutputFluxes.put("abundance", totalOutputFluxes.get("abundance") + abundanceExp);
}
double biomass = group.getNutrientRoutine().getWeight(fish) * fish.getAmount();
totalOutputFluxes.put("biomass", totalOutputFluxes.get("biomass") + biomass);
totalOutputFluxes.put("abundance", totalOutputFluxes.get("abundance") + abundanceExp);
}
}
}
try {
bW.write(time.getYear(group.getPilot()) + ";"+ basin.getName() + ";");
bW.write(+ totalOutputFluxes.get("abundance") + ";" + totalOutputFluxes.get("biomass"));
bW.write(time.getYear(group.getPilot()) + ";" + basin.getName() + ";");
bW.write(+totalOutputFluxes.get("abundance") + ";" + totalOutputFluxes.get("biomass"));
bW.write("\n");
} catch (IOException e) {
......@@ -89,8 +88,7 @@ public class WriteEffectiveAndBiomassExportFluxes extends AquaNismsGroupProcess<
}
// 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();
}
......
......@@ -35,8 +35,8 @@ import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import fr.cemagref.simaqualife.pilot.Pilot;
import species.DiadromousFish;
import species.DiadromousFishGroup;
import species.DiadromousFish.Stage;
import species.DiadromousFishGroup;
/**
*
......@@ -50,7 +50,6 @@ public class WriteEffectiveAndBiomassImportFluxes extends AquaNismsGroupProcess<
private transient BufferedWriter bW;
private transient String sep = ";";
public static void main(String[] args) {
System.out.println((new XStream(new DomDriver())).toXML(new WriteEffectiveAndBiomassImportFluxes()));
}
......@@ -78,8 +77,8 @@ public class WriteEffectiveAndBiomassImportFluxes extends AquaNismsGroupProcess<
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 = new BufferedWriter(new FileWriter(new File(
group.getOutputPath() + fileNameOutput + group.getEnvironment().getSimulationId() + ".csv")));
bW.write("year" + sep + "type" + sep + "originBasin"); // create the field of the column
for (String birthBasinName : group.getEnvironment().getRiverBasinNames()) {
......
......@@ -83,4 +83,19 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
}
/**
*
* concat at RngSatusIndex, temperatureCatchmentFile
*
* @return simulation name
*/
public String getSimulationId() {
String id = "_";
id = id.concat(Integer.toString(getPilot().getParameters().getRngStatusIndex()));
String temperatureFile = getTemperatureCatchmentFile();
id = id.concat("-").concat(temperatureFile);
return id;
}
}
......@@ -435,8 +435,8 @@ public class DiadromousFishGroup extends AquaNismsGroup<DiadromousFish, RIOBasin
sep = ";";
new File(this.outputPath + fileNameFluxes).getParentFile().mkdirs();
try {
bWForFluxes = new BufferedWriter(
new FileWriter(new File(this.outputPath + fileNameFluxes + this.getSimulationId() + ".csv")));
bWForFluxes = new BufferedWriter(new FileWriter(
new File(this.outputPath + fileNameFluxes + this.getEnvironment().getSimulationId() + ".csv")));
bWForFluxes.write("timestep" + sep + "year" + sep + "season" + sep + "basin" + sep + "abundance" + sep
+ "fluxType" + sep + "origin" + sep + "abundanceExp" + sep + "biomass");
......@@ -627,24 +627,6 @@ public class DiadromousFishGroup extends AquaNismsGroup<DiadromousFish, RIOBasin
}
/**
*
* concat at RngSatusIndex, temperatureCatchmentFile
*
* @return simulation name
*/
public String getSimulationId() {
String id = "_";
id = id.concat(Integer.toString(getPilot().getParameters().getRngStatusIndex()));
String temperatureFile = ((RIOBasinNetwork) getPilot().getAquaticWorld().getEnvironment()).getTemperatureCatchmentFile();
id = id.concat("-").concat(temperatureFile);
if (parameterSetLine > 0) {
id = id.concat("-").concat(Integer.toString(parameterSetLine));
}
return id;
}
public boolean isThereBasinToUpdate() {
return basinsToUpdate != null;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment