Commit a9654eb6 authored by Poulet Camille's avatar Poulet Camille
Browse files

First attempt to use GR3D and solve error message

Mistake in enum. diaromousFish.Gender
The programm can not find the enumeration
parent d6cf6d18
<list>
<species.DiadromousFishGroup>
<useCemetery>true</useCemetery>
<name>species A</name>
<color>
<red>255</red>
......@@ -8,11 +9,217 @@
<alpha>255</alpha>
</color>
<linfVonBert>60.0</linfVonBert>
<dMaxDisp>0.0</dMaxDisp>
<dMaxDisp>300.0</dMaxDisp>
<lFirstMaturity>40.0</lFirstMaturity>
<fileNameInputForInitialObservation>data/input/reality/Obs1900.csv</fileNameInputForInitialObservation>
<fishNutrient>
<nutrientsOfInterest>
<string>N</string>
<string>P</string>
</nutrientsOfInterest>
<residenceTime>30.0</residenceTime>
<excretionRate class="hashtable">
<entry>
<string>P</string>
<double>2.17E-6</double>
</entry>
<entry>
<string>N</string>
<double>2.471E-5</double>
</entry>
</excretionRate>
<fishFeaturesPreSpawning class="hashtable">
<entry>
<species.DiadromousFish_-Gender>MALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>bLW</string>
<double>2.1774</double>
</entry>
<entry>
<string>aLW</string>
<double>0.27144384321211973</double>
</entry>
</hashtable>
</entry>
<entry>
<species.DiadromousFish_-Gender>FEMALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>bLW</string>
<double>3.147</double>
</entry>
<entry>
<string>aLW</string>
<double>0.007388725660209693</double>
</entry>
</hashtable>
</entry>
</fishFeaturesPreSpawning>
<fishFeaturesPostSpawning class="hashtable">
<entry>
<species.DiadromousFish_-Gender>MALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>bLW</string>
<double>2.9973</double>
</entry>
<entry>
<string>aLW</string>
<double>0.010383887012522573</double>
</entry>
</hashtable>
</entry>
<entry>
<species.DiadromousFish_-Gender>FEMALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>bLW</string>
<double>2.9418</double>
</entry>
<entry>
<string>aLW</string>
<double>0.013199187556948952</double>
</entry>
</hashtable>
</entry>
</fishFeaturesPostSpawning>
<juvenileFeatures class="hashtable">
<entry>
<string>bLW</string>
<double>3.0306</double>
</entry>
<entry>
<string>aLW</string>
<double>0.006986429759979109</double>
</entry>
</juvenileFeatures>
<spawnedGametesWeight class="hashtable">
<entry>
<species.DiadromousFish_-Gender>MALE
</species.DiadromousFish_-Gender>
<double>44.8</double>
</entry>
<entry>
<species.DiadromousFish_-Gender>FEMALE
</species.DiadromousFish_-Gender>
<double>131.0</double>
</entry>
</spawnedGametesWeight>
<compoCarcassPreSpawning class="hashtable">
<entry>
<species.DiadromousFish_-Gender>MALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>P</string>
<double>0.00666</double>
</entry>
<entry>
<string>N</string>
<double>0.02941</double>
</entry>
</hashtable>
</entry>
<entry>
<species.DiadromousFish_-Gender>FEMALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>P</string>
<double>0.006730000000000001</double>
</entry>
<entry>
<string>N</string>
<double>0.029580000000000002</double>
</entry>
</hashtable>
</entry>
</compoCarcassPreSpawning>
<compoCarcassPostSpawning class="hashtable">
<entry>
<species.DiadromousFish_-Gender>MALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>P</string>
<double>0.00961</double>
</entry>
<entry>
<string>N</string>
<double>0.0279</double>
</entry>
</hashtable>
</entry>
<entry>
<species.DiadromousFish_-Gender>FEMALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>P</string>
<double>0.00997</double>
</entry>
<entry>
<string>N</string>
<double>0.03216</double>
</entry>
</hashtable>
</entry>
</compoCarcassPostSpawning>
<compoGametes class="hashtable">
<entry>
<species.DiadromousFish_-Gender>MALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>P</string>
<double>0.00724</double>
</entry>
<entry>
<string>N</string>
<double>0.0325</double>
</entry>
</hashtable>
</entry>
<entry>
<species.DiadromousFish_-Gender>FEMALE
</species.DiadromousFish_-Gender>
<hashtable>
<entry>
<string>P</string>
<double>0.0032</double>
</entry>
<entry>
<string>N</string>
<double>0.03242</double>
</entry>
</hashtable>
</entry>
</compoGametes>
<compoJuvenile class="hashtable">
<entry>
<string>P</string>
<double>0.00887</double>
</entry>
<entry>
<string>N</string>
<double>0.02803</double>
</entry>
</compoJuvenile>
</fishNutrient>
<fileNameInputForInitialObservation>data/input/reality/Obs1900.csv
</fileNameInputForInitialObservation>
<centileForRange>0.95</centileForRange>
<parameterSetfileName>data/input/reality/parameterSet.csv
</parameterSetfileName>
<parameterSetLine>0</parameterSetLine>
<yearOfTheUpdate>0</yearOfTheUpdate>
<basinsToUpdateFile>data/input/reality/basinsToUpdate.csv
</basinsToUpdateFile>
<outputPath>data/output/</outputPath>
<processes>
<processesAtBegin>
<species.PopulateBasinNetworkWithANorthLimit>
......@@ -99,7 +306,8 @@
<initialLength>2.0</initialLength>
<sigmaRecruitment>0.2</sigmaRecruitment>
<survivalRateAfterReproduction>0.1</survivalRateAfterReproduction>
<maxNumberOfSuperIndividualPerReproduction>50.0</maxNumberOfSuperIndividualPerReproduction>
<maxNumberOfSuperIndividualPerReproduction>50.0
</maxNumberOfSuperIndividualPerReproduction>
<withDiagnose>false</withDiagnose>
</species.ReproduceAndSurviveAfterReproductionWithDiagnose>
......
......@@ -18,6 +18,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
......@@ -28,6 +29,7 @@ import java.util.regex.Pattern;
import miscellaneous.Duo;
import miscellaneous.TreeMapForCentile;
import species.DiadromousFish.Gender;
import org.openide.util.lookup.ServiceProvider;
......@@ -56,6 +58,12 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
*/
public double lFirstMaturity = 40.;
/**
* Routine to compute nutrient fluxes operated by a single individual (TODO by a single super individual).
*
*/
private FishNutrient fishNutrient;
public String fileNameInputForInitialObservation = "data/input/reality/Obs1900.csv";
/**
......@@ -121,9 +129,148 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
* @unit
*/
private transient List<Duo<Double, Double>> parameterSets;
public static void main(String[] args) {
System.out.println((new XStream(new DomDriver())).toXML(new DiadromousFishGroup(new Pilot(), null, null)));
DiadromousFishGroup diadromousFishGroup = new DiadromousFishGroup(new Pilot(), null, null);
double aResidenceTime =30;
Map <String, Double> anExcretionRate = new Hashtable <String, Double>();
anExcretionRate.put("N", 24.71E-6); //values from Barber et al, Alosa sapidissima in ug/g wet mass/hour : convertit en g
anExcretionRate.put("P", 2.17E-6); //values from Barber et al, Alosa sapidissima in ug/g wet mass/hour: convertit en g
/*
* A feature pre spawning
*/
Map<DiadromousFish.Gender, Map<String, Double>> aFeaturePreSpawning = new Hashtable<DiadromousFish.Gender, Map<String,Double>>();
/*
* For females
*/
Map<String,Double> aFeature = new Hashtable<String,Double>();
aFeature.put("aLW", Math.exp(-4.9078)); //weight size relationship computed from BDalosesBruch
aFeature.put("bLW", 3.147);
//aFeature.put("bLW",3.3429);// parametre "b" de la relation taille/poids - Coefficient d'allometrie
//aFeature.put("aLW",1.2102E-6 * Math.pow(10., aFeature.get("bLW"))); // parametre "a" de la relation taille/poids en kg/cm- Traduit la condition
//aFeature.put("GSI",0.15);
aFeaturePreSpawning.put(Gender.FEMALE, aFeature);
/*
* For males
*/
aFeature = new Hashtable<String,Double>();
aFeature.put("aLW", Math.exp(-1.304));
aFeature.put("bLW", 2.1774);
//aFeature.put("aLW",2.4386E-6 * Math.pow(10, aFeature.get("bLW"))); // Conversion des g/mm en g.cm (from Taverny, 1991)
//aFeature.put("GSI",.08);
aFeaturePreSpawning.put(Gender.MALE,aFeature);
/*
* a Feature post Spawning
*/
Map<DiadromousFish.Gender, Map<String, Double>> aFeaturePostSpawning = new Hashtable<DiadromousFish.Gender, Map<String,Double>>();
/*
* For females
*/
aFeature = new Hashtable<String,Double>();
aFeature.put("aLW", Math.exp(-4.3276)); //weight size relationship computed from BDalosesBruch
aFeature.put("bLW", 2.9418);
//aFeature.put("GSI",0.10); //From BDalosesBruch
//aFeature.put("aLW",aFeaturePreSpawning.get(Gender.FEMALE).get("aLW")/(1+aFeature.get("GSI"))); // parametre "a" de la relation taille/poids avec Lt en cm - Traduit la condition
//aFeature.put("bLW",aFeaturePreSpawning.get(Gender.FEMALE).get("bLW"));// parametre "b" de la relation taille/poids - Coefficient d'allometrie
aFeaturePostSpawning.put(Gender.FEMALE, aFeature);
/*
* For males
*/
aFeature = new Hashtable<String,Double>();
aFeature.put("aLW", Math.exp(-4.5675));// parametre "a" de la relation taille/poids - Coefficient d'allometrie
aFeature.put("bLW", 2.9973);
//aFeature.put("GSI",.05); From BDalosesBruch
//aFeature.put("aLW",aFeaturePreSpawning.get(Gender.MALE).get("aLW")/(1+aFeature.get("GSI")));
//aFeature.put("bLW",aFeaturePreSpawning.get(Gender.MALE).get("bLW"));
aFeaturePostSpawning.put(Gender.MALE,aFeature);
Map<DiadromousFish.Gender, Double> aGameteSpawned = new Hashtable <DiadromousFish.Gender,Double>();
aGameteSpawned.put(Gender.FEMALE, 131.); // Compute from the difference between spawned and unspawned ovaries ie correspond to a mean weight of eggs spawned
aGameteSpawned.put(Gender.MALE, 44.8); // Compute from the difference between spawned and unspawned testes ie correspond to a mean weight of sperm spawned
// carcass composition for fish before spawning
Map<DiadromousFish.Gender, Map<String, Double>> aCompoCarcassPreSpawning = new Hashtable<DiadromousFish.Gender,Map<String,Double>>();
Map<String,Double> aCompo = new Hashtable<String,Double>();
aCompo.put("N", 2.958 / 100.); //On remplit une collection avec un put.
aCompo.put("P", 0.673 / 100.);
aCompoCarcassPreSpawning.put(Gender.FEMALE,aCompo);
aCompo = new Hashtable<String,Double>();
aCompo.put("N", 2.941 / 100.);
aCompo.put("P", 0.666 / 100.);
aCompoCarcassPreSpawning.put(Gender.MALE,aCompo);
// carcass composition for fish after spawning
Map<DiadromousFish.Gender, Map<String, Double>> aCompoCarcassPostSpawning = new Hashtable<DiadromousFish.Gender,Map<String,Double>>();
aCompo = new Hashtable<String,Double>();
aCompo.put("N", 3.216 / 100.); //On remplit une collection avec un put.
aCompo.put("P", 0.997 / 100.);
aCompoCarcassPostSpawning.put(Gender.FEMALE,aCompo);
aCompo = new Hashtable<String,Double>();
aCompo.put("N", 2.790 / 100.); // From Haskel et al, 2017
aCompo.put("P", 0.961 / 100.);
aCompoCarcassPostSpawning.put(Gender.MALE,aCompo);
// Gametes composition approximated by the difference between gonads weight before and after spawning.
Map<DiadromousFish.Gender, Map<String, Double>> aCompoGametes = new Hashtable<DiadromousFish.Gender,Map<String,Double>>();
aCompo = new Hashtable<String,Double>();
aCompo.put("N", 3.242 / 100.); //On remplit une collection avec un put. From Haskel et al, 2018.
aCompo.put("P", 0.320 / 100.); // Haskel = %P, N, ici ratio donc divise par 100
aCompoGametes.put(Gender.FEMALE,aCompo);
aCompo = new Hashtable<String,Double>();
aCompo.put("N", 3.250 / 100.);
aCompo.put("P", 0.724 / 100.);
aCompoGametes.put(Gender.MALE,aCompo);
// features for juveniles
Map<String,Double> aJuvenileFeatures = new Hashtable<String, Double>();
aJuvenileFeatures.put("bLW",3.0306);
aJuvenileFeatures.put("aLW",Math.exp(-11.942) * Math.pow(10., aJuvenileFeatures.get("bLW")));
// carcass composition for juveniles fish
Map<String, Double> aCompoJuveniles = new Hashtable<String,Double>();
aCompoJuveniles.put("N", 2.803 / 100.); //On remplit une collection avec un put. %N in wet weight (Haskell et al, 2017) on Alosa sapidissima
aCompoJuveniles.put("P", 0.887 / 100.); //%P in wet weight (from Haskell et al, 2017) on Alosa sapidissima
ArrayList <String> nutrientsOfInterest= new ArrayList <String>();
nutrientsOfInterest.add("N");
nutrientsOfInterest.add("P");
diadromousFishGroup.fishNutrient = new FishNutrient(nutrientsOfInterest,aResidenceTime, anExcretionRate, aFeaturePreSpawning, aFeaturePostSpawning, aGameteSpawned,
aCompoCarcassPreSpawning, aCompoCarcassPostSpawning, aCompoGametes,
aJuvenileFeatures, aCompoJuveniles);
System.out.println((new XStream(new DomDriver())).toXML(diadromousFishGroup));
}
public DiadromousFishGroup(Pilot pilot, BasinNetwork environment, Processes processes) {
......@@ -360,10 +507,16 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
return lFirstMaturity;
}
public FishNutrient getFishNutrient() {
return fishNutrient;
}
public void setlFirstMaturity(double lFirstMaturity) {
this.lFirstMaturity = lFirstMaturity;
}
// ================================================================
// statictis for calibration
// ================================================================
......
......@@ -20,15 +20,11 @@
package species;
import environment.SeaBasin;
import environment.Time.Season;
import fr.cemagref.simaqualife.pilot.Pilot;
import species.DiadromousFish.Gender;
import species.DiadromousFish.Stage;
import species.ReproduceAndSurviveAfterReproduction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import com.thoughtworks.xstream.XStream;
......@@ -44,6 +40,7 @@ public class FishNutrient {
private static enum SpawningPosition {PRE,POST}; // on crer un static pour rserver une mme classe mmoire pour toutes les instances
//private static enum Gender {UNDIFFERENCIED, FEMALE, MALE};
private ArrayList<String> nutrientsOfInterest;
......@@ -59,11 +56,11 @@ public class FishNutrient {
* key feature
* value value
*/
private Map <Gender,Map<String, Double>> fishFeaturesPreSpawning;
private Map <DiadromousFish.Gender,Map<String, Double>> fishFeaturesPreSpawning;
private Map <Gender, Map<String, Double>> fishFeaturesPostSpawning;
private Map <DiadromousFish.Gender, Map<String, Double>> fishFeaturesPostSpawning;
private Map <String, Double> juvenileFeatures;
private Map<String, Double> juvenileFeatures;
/**
......@@ -72,7 +69,7 @@ public class FishNutrient {
* value g
* usually computed as the difference between unspawned gonad (inbound) and spawned gonad (outbound; "spent gonad")
*/
private Map <Gender, Double> spawnedGametesWeight;
private Map <DiadromousFish.Gender, Double> spawnedGametesWeight;
/**
......@@ -109,8 +106,6 @@ public class FishNutrient {
/**
* chemical composition of juveniles
* <key> stage
* <value>
* <key> chemical element
* <value> value
*/
......@@ -118,13 +113,6 @@ public class FishNutrient {
private Map<String,Double> compoJuvenile;
/**
*
*/
public FishNutrient() {
// TODO Auto-generated constructor stub
}
/**
* Constructor based on the 5 Map of fish composition
......@@ -138,12 +126,12 @@ public class FishNutrient {
double residenceTime,
Map <String, Double> excretionRate,
Map<Gender, Map<String, Double>> fishFeaturesPreSpawning,
Map<Gender, Map<String, Double>> fishFeaturesPostSpawning,
Map<Gender, Double> gameteSpawned,
Map<Gender, Map<String, Double>> compoCarcassPreSpawning,
Map<Gender, Map<String, Double>> compoCarcassPostSpawning,
Map<Gender, Map<String, Double>> compoGametes,
Map<DiadromousFish.Gender, Map<String, Double>> fishFeaturesPreSpawning,
Map<DiadromousFish.Gender, Map<String, Double>> fishFeaturesPostSpawning,
Map<DiadromousFish.Gender, Double> gameteSpawned,
Map<DiadromousFish.Gender, Map<String, Double>> compoCarcassPreSpawning,
Map<DiadromousFish.Gender, Map<String, Double>> compoCarcassPostSpawning,
Map<DiadromousFish.Gender, Map<String, Double>> compoGametes,
Map<String, Double> juvenileFeatures,
Map<String, Double> compoJuvenile)
{
......@@ -161,7 +149,7 @@ public class FishNutrient {
this.compoJuvenile = compoJuvenile;
}
/**
* compute the nutrient fluxes for a single fish (in the super individual)
* that dies before spawning
......@@ -499,6 +487,8 @@ public static void main(String[] args) {
System.out.println(juvenileFish.getStage() + ": " + juvenileFish.getLength() + " cm " + fn.getWeight(juvenileFish)+ " g ");
System.out.println("\tNutrients Fluxes for juveniles " + fn.computeNutrientsExportForJuveniles(juvenileFish).toString());
/* Create XML file
*
......
......@@ -337,9 +337,11 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
riverBasin.getNumberOfNonNulRecruitmentForFinalProbOfPres().push(0.);
}
// --------------------------------------------------------------------------------------------------
// Remove deadfish
// Remove deadfish and compute the related nutrient fluxes
// --------------------------------------------------------------------------------------------------
for (DiadromousFish fish : deadFish){
System.out.println(group.getFishNutrient().computeNutrientsInputForDeathAfterSpawning(fish)); //
group.removeAquaNism(fish);
}
deadFish.clear();
......
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