Commit 88af03bc authored by Lambert Patrick's avatar Lambert Patrick
Browse files

with different kopt for female and male

parent f846ba58
......@@ -7,9 +7,10 @@
<blue>0</blue>
<alpha>255</alpha>
</color>
<linfVonBert>60.0</linfVonBert>
<linfVonBert>70.0</linfVonBert>
<dMaxDisp>300.0</dMaxDisp>
<lFirstMaturity>40.0</lFirstMaturity>
<lFirstMaturityForFemale>55.0</lFirstMaturityForFemale>
<lFirstMaturityForMale>40.0</lFirstMaturityForMale>
<fishNutrient>
<nutrientsOfInterest>
<string>N</string>
......@@ -219,6 +220,7 @@
<environment.InformTime>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode>
</environment.InformTime>
<species.PlopProcess>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode>
<temporisation>0</temporisation>
......@@ -233,7 +235,8 @@
<tempMinGrow>3.0</tempMinGrow>
<tempMaxGrow>26.0</tempMaxGrow>
<tempOptGrow>17.0</tempOptGrow>
<kOpt>0.3900707</kOpt>
<kOptForFemale>0.5363472</kOptForFemale>
<kOptForMale>0.3900707</kOptForMale>
<sigmaDeltaLVonBert>0.2</sigmaDeltaLVonBert>
</species.Grow>
......@@ -269,6 +272,11 @@
<mortalityRateInOffshore>0.4</mortalityRateInOffshore>
</species.Survive>
<species.ExportLenghtAgeDistribution>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode>
<exportSeason>SPRING</exportSeason>
<fileNameOutput>lengthAgeDistribution</fileNameOutput>
</species.ExportLenghtAgeDistribution>
<species.ReproduceAndSurviveAfterReproductionWithDiagnose>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode>
......@@ -320,6 +328,6 @@
</processesAtEnd>
</processes>
<useCemetery>true</useCemetery>
<useCemetery>false</useCemetery>
</species.DiadromousFishGroup>
</list>
\ No newline at end of file
......@@ -9,6 +9,7 @@ import fr.cemagref.simaqualife.pilot.Pilot;
public class DiadromousFish extends AquaNism<Basin, BasinNetwork> {
public static enum Stage {IMMATURE, MATURE};
//TODO replace UNDIFFERENCIED by UNDETERMINED
public static enum Gender {UNDIFFERENCIED, FEMALE, MALE};
private long amount;
......@@ -101,6 +102,7 @@ public class DiadromousFish extends AquaNism<Basin, BasinNetwork> {
return gender;
}
@Override
public <ANG extends AquaNismsGroup<?, BasinNetwork>> void moveTo(
Pilot pilot, Basin destination, ANG group) {
......
......@@ -51,19 +51,27 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
* @unit
*/
public double dMaxDisp = 300.;
/**
* length at first maturity. At that length the female become Stage.MATURE
* @unit cm
*/
public double lFirstMaturityForFemale = 55.;
/**
* length at first maturity. At that length the fish become Stage.MATURE
* length at first maturity. At that length the female become Stage.MATURE
* @unit cm
*/
public double lFirstMaturity = 40.;
public double lFirstMaturityForMale = 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";
/**
......@@ -112,11 +120,19 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
private transient Map<String, Duo<Double, Double>> basinsToUpdate;
/**
* Brody growth coefficient of the von Bertalanffy growth curve (from the parameterset file)
* Brody growth coefficient of the von Bertalanffy growth curve for female (calculated from the parameterset file)
* * L = Linf *(1-exp(-K*(t-t0))
* @unit year-1
*/
private transient double kOpt;
private transient double kOptForFemale;
/**
* Brody growth coefficient of the von Bertalanffy growth curve for male (calculated from the parameterset file)
* * L = Linf *(1-exp(-K*(t-t0))
* @unit year-1
*/
private transient double kOptForMale;
/**
* minimum temperature for the reproduction (from the parameterset file)
* @unit °C
......@@ -129,25 +145,25 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
* @unit
*/
private transient List<Duo<Double, Double>> parameterSets;
public static void main(String[] args) {
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
*/
......@@ -170,12 +186,12 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
//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
*/
......@@ -191,7 +207,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
* 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
......@@ -199,12 +215,12 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
//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>();
......@@ -217,7 +233,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
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>>();
......@@ -231,7 +247,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
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>>();
......@@ -251,7 +267,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
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>();
......@@ -263,13 +279,13 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
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));
}
......@@ -357,8 +373,9 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
}
// charge kopt et temMinRep depuis le fichier de parametre. Sinon (parameterSetLine<=0), ce sont les
// valeur dasn le procoessus de reroduction qui sont utilis�
kOpt=Double.NaN;
// valeurs dans le processus de reproduction qui sont utilis�
kOptForFemale=Double.NaN;
kOptForMale=Double.NaN;
tempMinRep =Double.NaN;
if (parameterSetLine>0){
parameterSets = new ArrayList<Duo<Double,Double>>(10);
......@@ -391,15 +408,33 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
e.printStackTrace();
}
kOpt = parameterSets.get(parameterSetLine-1).getFirst();
double kOpt = parameterSets.get(parameterSetLine-1).getFirst();
// 40 correspond to the lFirstMaturity used by Rougier to calibrate the model
kOptForMale = kOpt *lFirstMaturityForMale / 40.;
kOptForFemale= kOpt * lFirstMaturityForFemale / 40.;
tempMinRep = parameterSets.get(parameterSetLine-1).getSecond();
}
}
public double getKOpt(){
/**
* @param fish
* @param group
* @return the Brody coeff
*/
public double getKOpt(DiadromousFish fish) {
double kOpt = 0.;
if (fish.getGender() == Gender.FEMALE)
kOpt = kOptForFemale;
else if (fish.getGender() == Gender.MALE)
kOpt = kOptForMale;
else
kOpt= (kOptForFemale + kOptForMale) / 2.;
return kOpt;
}
public double getTempMinRep(){
return tempMinRep;
}
......@@ -503,20 +538,21 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
return dMaxDisp;
}
public double getlFirstMaturity() {
return lFirstMaturity;
public double getlFirstMaturityForFemale() {
return lFirstMaturityForFemale;
}
public double getlFirstMaturityForMale() {
return lFirstMaturityForMale;
}
public FishNutrient getFishNutrient() {
return fishNutrient;
}
public void setlFirstMaturity(double lFirstMaturity) {
this.lFirstMaturity = lFirstMaturity;
}
// ================================================================
// statictis for calibration
// ================================================================
......@@ -579,8 +615,8 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
return sumLogWhereAbs + sumLogWherePres;
}
// ========================================================
// obeserver to explore the distribution
// ========================================================
......@@ -597,8 +633,8 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
}
return latitude;
}
@Observable(description="Number of colonized basins")
public double getNbColonizedBasins() {
int nb = 0;
......@@ -611,7 +647,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
}
return nb;
}
@Observable(description="Northern colonized basins")
public double getNorthernBasins() {
......@@ -626,7 +662,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
return northernBasin;
}
@Observable(description="Southern colonized basins")
public double getSouthernBasins() {
int southernBasin = Integer.MIN_VALUE;
......@@ -671,7 +707,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
return rangeDistribution;
}
@Observable(description = "Range distribution")
public Double[] getRangeDistribution() {
double southernBasin = 0;
......@@ -720,7 +756,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
return eff;
}
@Override
public void addAquaNism(DiadromousFish fish) {
// avoid utilisation of global fishes list
......@@ -728,7 +764,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
fish.getPosition().addFish(fish, this);
}
@Override
public void removeAquaNism(DiadromousFish fish) {
// avoid utilisation of global fishes list
......@@ -736,13 +772,13 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
fish.getPosition().removeFish(fish, this);
}
@Override
public int compareTo(DiadromousFishGroup t) {
return name.compareTo(t.name);
}
/**
*
* concat at RngSatusIndex, temperatureCatchmentFile
......
......@@ -86,7 +86,9 @@ public class ExportLenghtAgeDistribution extends AquaNismsGroupProcess<Diadromou
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());
bW.write(pilot.getCurrentTime() + sep);
bW.write(Time.getYear(pilot) + sep);
bW.write(Time.getSeason(pilot) + sep);
......
......@@ -16,6 +16,7 @@ import miscellaneous.Miscellaneous;
import org.openide.util.lookup.ServiceProvider;
import species.DiadromousFish.Gender;
import species.DiadromousFish.Stage;
import umontreal.iro.lecuyer.probdist.NormalDist;
import umontreal.iro.lecuyer.randvar.NormalGen;
......@@ -46,8 +47,16 @@ public class Grow extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGr
* L = Linf *(1-exp(-K*(t-t0))
* @unit year -1
*/
private double kOpt = 0.3;
private double kOptForFemale= 0.3;
/**
* K, Brody growth rate at optimal temperature
* L = Linf *(1-exp(-K*(t-t0))
* @unit year -1
*/
private double kOptForMale= 0.3;
/**
* standart deviation for the lognormal random draw of growth increment
* @unit cm
......@@ -68,6 +77,7 @@ public class Grow extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGr
}
@Override
public void doProcess(DiadromousFishGroup group) {
for(Basin basin : group.getEnvironment().getBasins()){
......@@ -77,15 +87,10 @@ public class Grow extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGr
double kVonBert = 0.;
double growthIncrement = 0.;
// 1) calculate the kVonBert (from the grow process or forn Diadromousgroup
// when Brody coeff comes from calibration output
if (Double.isNaN(group.getKOpt())){
kVonBert = kOpt *
Miscellaneous.temperatureEffect(fish.getPosition().getCurrentTemperature(group.getPilot()), tempMinGrow, tempOptGrow, tempMaxGrow);
} else {
kVonBert = group.getKOpt() *
// 1) calculate the kVonBert
//System.out.println(this.getKOpt(fish, group) );
kVonBert = this.getKOpt(fish, group) *
Miscellaneous.temperatureEffect(fish.getPosition().getCurrentTemperature(group.getPilot()), tempMinGrow, tempOptGrow, tempMaxGrow);
}
// 2) Update the fish length with a lognormal normal draw of increment
// limit the fish length to Linf
......@@ -102,7 +107,7 @@ public class Grow extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGr
//System.out.println(fish.getAge() + " -> "+ fish.getLength() + " ("+fish.getStage()+"): "+ growthIncrement);
// test if fish become mature
if (fish.getStage() == Stage.IMMATURE){
if (fish.getLength() > group.getlFirstMaturity()){
if (fish.getLength() > group.getlFirstMaturityForFemale()){
fish.setStage(Stage.MATURE);
}
}
......@@ -110,4 +115,28 @@ public class Grow extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGr
}
}
}
/**
* @param fish
* @param group
* @return the Brody coeff from Diadromousgroup if exists or from this grow process
*/
public double getKOpt(DiadromousFish fish, DiadromousFishGroup group) {
double kOpt = 0.;
if (Double.isNaN(group.getKOpt(fish))){
if (fish.getGender() == Gender.FEMALE)
kOpt = kOptForFemale;
else if (fish.getGender() == Gender.MALE)
kOpt = kOptForMale;
else
kOpt= (kOptForFemale + kOptForMale) / 2.;
}
else
kOpt = group.getKOpt(fish);
return kOpt;
}
}
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