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

wihr observer of age range

parent 01ef8903
......@@ -72,13 +72,19 @@
<observers>
<observer.RecordDuoChart>
<graphType>POINT</graphType>
<variableName>getPrimiparousrousRateVsLatitude</variableName>
<variableName>getPrimiparousRateVsLatitude</variableName>
<xName>latitude</xName>
<yName>meanPrimarousRate</yName>
<yName>meanPrimiparousRate</yName>
</observer.RecordDuoChart>
<observer.TemporalRangeSerieChart>
<title>Range of female ages</title>
<xAxisLabel>Time (season)</xAxisLabel>
<yAxisLabel>Age (year)</yAxisLabel>
<variableName>getRangeOfFemaleAge</variableName>
</observer.TemporalRangeSerieChart>
</observers>
</fr.cemagref.observation.kernel.ObservablesHandler>
</entry>
......
......@@ -37,9 +37,11 @@ import fr.cemagref.observation.kernel.ObservablesHandler;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import fr.cemagref.simaqualife.pilot.Pilot;
import miscellaneous.QueueMemory;
import miscellaneous.TreeMapForCentile;
import observer.ObservableRecord;
import species.DiadromousFish;
import species.DiadromousFish.Gender;
import species.DiadromousFish.Stage;
import species.DiadromousFishGroup;
/**
......@@ -183,6 +185,52 @@ public class AnalyseSpawnerFeatures extends AquaNismsGroupProcess<DiadromousFish
}
@Observable(description = "range of female ages")
public Double[] getRangeOfFemaleAge() {
return getRangeOfAge(Gender.FEMALE, defaultGroup);
}
@Observable(description = "range of male ages")
public Double[] getRangeOfMaleAge() {
return getRangeOfAge(Gender.MALE, defaultGroup);
}
public Double[] getRangeOfAge(Gender gender, DiadromousFishGroup group) {
TreeMapForCentile ageEffective = new TreeMapForCentile();
Double[] range = new Double[3];
double sum = 0;
double nb = 0;
double ageMin = 100.;
double ageMax = 0.;
for (RiverBasin riverBasin : riverBasins) {
for (DiadromousFish fish : riverBasin.getFishs(group)) {
if (fish.getStage() == Stage.MATURE & fish.getGender() == gender)
if (fish.getAge() < ageMin)
ageMin = fish.getAge();
if (fish.getAge() > ageMax)
ageMax = fish.getAge();
ageEffective.putWithAdding(fish.getAge(), fish.getAmount());
nb += fish.getAmount();
sum += fish.getAge() * fish.getAmount();
}
}
// (y, y-low, y-high) data item
// range[0] = sum / nb;
range[0] = ageEffective.calculateMedian();
range[1] = ageMin;
range[2] = ageMax;
// System.out.println(Arrays.toString(range));
return range;
}
@Observable(description = "mean age at first reproduction for female")
public double getMeanAgeOfPrimiparousFemale() {
double sum = 0;
......@@ -212,7 +260,7 @@ public class AnalyseSpawnerFeatures extends AquaNismsGroupProcess<DiadromousFish
@Observable(description = "PrimiparousRate versus latitude")
public List<Record> getPrimiparousrousRateVsLatitude() {
public List<Record> getPrimiparousRateVsLatitude() {
List<Record> records = new ArrayList<Record>();
......@@ -301,11 +349,11 @@ public class AnalyseSpawnerFeatures extends AquaNismsGroupProcess<DiadromousFish
@Information(unit = "°")
private double latitude;
@Information(unit = "#/#")
private double meanPrimarousRate;
private double meanPrimiparousRate;
public Record(double latitude, double meanPrimarousRate) {
this.latitude = latitude;
this.meanPrimarousRate = meanPrimarousRate;
this.meanPrimiparousRate = meanPrimarousRate;
}
}
......
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