diff --git a/src/main/java/environment/BasinNetworkObserverWith2Basins.java b/src/main/java/environment/BasinNetworkObserverWith2Basins.java index d2ab357863adac93099f916917a50c27145d3be8..0de33be6b2b9bd5d364c8ea7fb82121107259142 100644 --- a/src/main/java/environment/BasinNetworkObserverWith2Basins.java +++ b/src/main/java/environment/BasinNetworkObserverWith2Basins.java @@ -18,44 +18,42 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; -import species.DiadromousFish; -import species.DiadromousFishGroup; - import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; import environment.Basin.BasinType; import fr.cemagref.observation.gui.Configurable; import fr.cemagref.observation.gui.Drawable; +import species.DiadromousFish; +import species.DiadromousFishGroup; @SuppressWarnings("serial") -public class BasinNetworkObserverWith2Basins extends BasinNetworkObserver implements Configurable, -Drawable, MouseMotionListener { +@Deprecated +public class BasinNetworkObserverWith2Basins extends BasinNetworkObserver implements Configurable, Drawable, MouseMotionListener { - private double maxDistance =1000.; + private double maxDistance = 1000.; private double minDistance = 50.; - private double maxSurface=100000.; - + private double maxSurface = 100000.; // list of reachRect private transient Map<Shape, Basin> shapeBasinMap; private transient Map<Basin, Shape> basinShapeMap; // list of color - //private transient Color[] colorList; + // private transient Color[] colorList; @Override public void init() { - // create a uniform generator to calculate 100 xAlea and yAlea + // create a uniform generator to calculate 100 xAlea and yAlea // to randomly locate the fish in a basin nbAlea = 1000; - aleaX=new double[nbAlea]; - aleaY=new double[nbAlea]; - for (int i=0; i < nbAlea; i++){ - aleaX[i]= Math.random(); - aleaY[i]= Math.random(); + aleaX = new double[nbAlea]; + aleaY = new double[nbAlea]; + for (int i = 0; i < nbAlea; i++) { + aleaX[i] = Math.random(); + aleaY[i] = Math.random(); } display = new JPanel(new BorderLayout()); @@ -67,114 +65,96 @@ Drawable, MouseMotionListener { display.add(displayComponent, BorderLayout.CENTER); display.add(label, BorderLayout.PAGE_START); - /* // color list - colorList = new Color[6]; - colorList[0]= Color.GREEN; - colorList[1]= Color.CYAN; - colorList[2]= Color.MAGENTA; - colorList[3]= Color.PINK; - colorList[4]= Color.ORANGE; - colorList[5]= Color.YELLOW;*/ - -/* // list of color - colors= new ArrayList<Color>(25); - colors.add(new Color(0, 157, 0)); - colors.add(new Color(0, 163, 0)); - colors.add(new Color(0, 168, 0)); - colors.add(new Color(0, 172, 0)); - colors.add(new Color(17, 175, 0)); - colors.add(new Color(57, 178, 0)); - colors.add(new Color(82, 179, 0)); - colors.add(new Color(103, 180, 0)); - colors.add(new Color(122, 179, 0)); - colors.add(new Color(138, 178, 39)); - colors.add(new Color(153, 175, 117)); - colors.add(new Color(165, 173, 153)); - colors.add(new Color(171, 171, 171)); - colors.add(new Color(183, 167, 157)); - colors.add(new Color(201, 159, 127)); - colors.add(new Color(219, 149, 78)); - colors.add(new Color(235, 139, 0)); - colors.add(new Color(248, 127, 0)); - colors.add(new Color(255, 114, 0)); - colors.add(new Color(255, 101, 0)); - colors.add(new Color(255, 87, 0)); - colors.add(new Color(255, 72, 0)); - colors.add(new Color(255, 57, 0)); - colors.add(new Color(255, 39, 0)); - colors.add(new Color(255, 14, 0));*/ + /* + * // color list colorList = new Color[6]; colorList[0]= Color.GREEN; colorList[1]= Color.CYAN; colorList[2]= + * Color.MAGENTA; colorList[3]= Color.PINK; colorList[4]= Color.ORANGE; colorList[5]= Color.YELLOW; + */ + + /* + * // list of color colors= new ArrayList<Color>(25); colors.add(new Color(0, 157, 0)); colors.add(new Color(0, + * 163, 0)); colors.add(new Color(0, 168, 0)); colors.add(new Color(0, 172, 0)); colors.add(new Color(17, 175, + * 0)); colors.add(new Color(57, 178, 0)); colors.add(new Color(82, 179, 0)); colors.add(new Color(103, 180, + * 0)); colors.add(new Color(122, 179, 0)); colors.add(new Color(138, 178, 39)); colors.add(new Color(153, 175, + * 117)); colors.add(new Color(165, 173, 153)); colors.add(new Color(171, 171, 171)); colors.add(new Color(183, + * 167, 157)); colors.add(new Color(201, 159, 127)); colors.add(new Color(219, 149, 78)); colors.add(new + * Color(235, 139, 0)); colors.add(new Color(248, 127, 0)); colors.add(new Color(255, 114, 0)); colors.add(new + * Color(255, 101, 0)); colors.add(new Color(255, 87, 0)); colors.add(new Color(255, 72, 0)); colors.add(new + * Color(255, 57, 0)); colors.add(new Color(255, 39, 0)); colors.add(new Color(255, 14, 0)); + */ // list of color - colors= new ArrayList<Color>(2); + colors = new ArrayList<Color>(2); colors.add(Color.BLACK); colors.add(Color.GRAY); - // Initialize the map linking shape with basin shapeBasinMap = new HashMap<Shape, Basin>(); } + @Override public JComponent getDisplay() { // compute the range with a small margin double marginRatio = .02; - double surf= maxSurface/2, interRect=maxSurface*.05; - minX = -2*(surf + interRect); - rangeX = maxSurface - minX; - minX -= rangeX *marginRatio; - rangeX += 2*rangeX *marginRatio; - + double surf = maxSurface / 2, interRect = maxSurface * .05; + minX = -2 * (surf + interRect); + rangeX = maxSurface - minX; + minX -= rangeX * marginRatio; + rangeX += 2 * rangeX * marginRatio; + bn = (GridBasinNetwork) pilot.getAquaticWorld().getEnvironment(); minY = Double.POSITIVE_INFINITY; for (RiverBasin basin : bn.getRiverBasins()) { - minY = Math.min(minY ,basin.getLatitude()); + minY = Math.min(minY, basin.getLatitude()); } - minY = (minY -minDistance/2.) ; + minY = (minY - minDistance / 2.); rangeY = maxDistance - minY; minY -= rangeY * marginRatio; - rangeY += 2*rangeY*marginRatio; + rangeY += 2 * rangeY * marginRatio; // define the shape for each basin basinShapeMap = new HashMap<Basin, Shape>(); for (Basin basin : bn.getBasins()) { Path2D.Double shape = new Path2D.Double(); - if (basin.getType() == BasinType.RIVER){ - shape.moveTo( 0., ((RiverBasin) basin).getLatitude()- minDistance/2); - shape.lineTo(((RiverBasin) basin).getSurface(), ((RiverBasin) basin).getLatitude()- minDistance/2); - shape.lineTo(((RiverBasin) basin).getSurface(), ((RiverBasin) basin).getLatitude()+ minDistance/2); - shape.lineTo( 0., ((RiverBasin) basin).getLatitude()+ minDistance/2); + if (basin.getType() == BasinType.RIVER) { + shape.moveTo(0., ((RiverBasin) basin).getLatitude() - minDistance / 2); + shape.lineTo(((RiverBasin) basin).getSurface(), ((RiverBasin) basin).getLatitude() - minDistance / 2); + shape.lineTo(((RiverBasin) basin).getSurface(), ((RiverBasin) basin).getLatitude() + minDistance / 2); + shape.lineTo(0., ((RiverBasin) basin).getLatitude() + minDistance / 2); shape.closePath(); } else { RiverBasin rivBas = (RiverBasin) bn.getAssociatedRiverBasin(basin); - double lag= surf +interRect; + double lag = surf + interRect; if (basin.getType() == BasinType.OFFSHORE) - lag *=2 ; - - shape.moveTo(-lag, rivBas.getLatitude()- minDistance/2); - shape.lineTo(-lag+surf, rivBas.getLatitude()- minDistance/2); - shape.lineTo( -lag+surf, rivBas.getLatitude()+ minDistance/2); - shape.lineTo( -lag ,rivBas.getLatitude()+ minDistance/2); + lag *= 2; + + shape.moveTo(-lag, rivBas.getLatitude() - minDistance / 2); + shape.lineTo(-lag + surf, rivBas.getLatitude() - minDistance / 2); + shape.lineTo(-lag + surf, rivBas.getLatitude() + minDistance / 2); + shape.lineTo(-lag, rivBas.getLatitude() + minDistance / 2); shape.closePath(); } basinShapeMap.put(basin, shape); } - return display; } - public static void main(String[] args) { System.out.println((new - XStream(new DomDriver())) .toXML(new BasinNetworkObserverWith2Basins())); } + + + public static void main(String[] args) { + System.out.println((new XStream(new DomDriver())).toXML(new BasinNetworkObserverWith2Basins())); + } private class DisplayComponent extends JComponent { @Override protected synchronized void paintComponent(Graphics g) { - double W =this.getWidth(); - double H =this.getHeight(); - AffineTransform af = new AffineTransform(W/rangeX, 0., 0., - -H/rangeY, -W*minX/rangeX, H*(1. + minY/rangeY)); - //System.out.println(af.toString()); + double W = this.getWidth(); + double H = this.getHeight(); + AffineTransform af = new AffineTransform(W / rangeX, 0., 0., -H / rangeY, -W * minX / rangeX, + H * (1. + minY / rangeY)); + // System.out.println(af.toString()); // prepare the graphics this.paintComponents(g); @@ -187,23 +167,23 @@ Drawable, MouseMotionListener { // prepare the diameter for the fish circle double fishX, fishY; - int fishDiameter = (int) Math.round(Math.min(W,H) / 100.); + int fishDiameter = (int) Math.round(Math.min(W, H) / 100.); shapeBasinMap.clear(); int idxColor; - //System.out.println("minX="+minX+ " rangeX=" + rangeX+ " minY="+minY+ "rangeY="+rangeY); + // System.out.println("minX="+minX+ " rangeX=" + rangeX+ " minY="+minY+ "rangeY="+rangeY); for (Basin basin : basinShapeMap.keySet()) { // draw each basin - //System.out.println( basin.getName() +" "+ basinShapeMap.get(basin).getBounds2D().toString()); - Path2D.Double displayShape = (Path2D.Double) - ((Path2D.Double) basinShapeMap.get(basin)).createTransformedShape(af); - //System.out.println( basin.getName() +" "+ displayShape.getBounds2D().toString()); + // System.out.println( basin.getName() +" "+ basinShapeMap.get(basin).getBounds2D().toString()); + Path2D.Double displayShape = (Path2D.Double) ((Path2D.Double) basinShapeMap.get(basin)) + .createTransformedShape(af); + // System.out.println( basin.getName() +" "+ displayShape.getBounds2D().toString()); shapeBasinMap.put(displayShape, basin); // to be used by the mouseMoved() - // fill the - if (basin instanceof RiverBasin) + // fill the + if (basin instanceof RiverBasin) g.setColor(new Color(0, 204, 255)); else if (basin instanceof InshoreBasin) g.setColor(new Color(0, 102, 255)); @@ -213,40 +193,35 @@ Drawable, MouseMotionListener { g2d.fill(displayShape); // draw the contour of the basin - if (basin instanceof RiverBasin) { + if (basin instanceof RiverBasin) { idxColor = bn.getRow(basin.getId()) % colors.size(); g.setColor(colors.get(idxColor)); g2d.draw(displayShape); } // draw fish - int cpt=0; - Map<DiadromousFishGroup, List<DiadromousFish>> fishPerGroup= basin.getFishPerGroup(); - for (DiadromousFishGroup group : fishPerGroup.keySet()){ - //g.setColor(group.getColor()); + int cpt = 0; + Map<DiadromousFishGroup, List<DiadromousFish>> fishPerGroup = basin.getFishPerGroup(); + for (DiadromousFishGroup group : fishPerGroup.keySet()) { + // g.setColor(group.getColor()); - for (DiadromousFish fish : fishPerGroup.get(group)){ + for (DiadromousFish fish : fishPerGroup.get(group)) { do { - fishX = displayShape.getBounds2D().getMinX() + displayShape.getBounds2D().getWidth() - * (0.2 + .6 * aleaX[cpt % nbAlea]); //- fishDiameter/2; - fishY = displayShape.getBounds2D().getMinY()+ displayShape.getBounds2D().getHeight() - * (0.2 + .6 * aleaY[cpt % nbAlea]);// - fishDiameter/2; - //System.out.println(! displayShape.contains(fishX, fishY)); + fishX = displayShape.getBounds2D().getMinX() + + displayShape.getBounds2D().getWidth() * (0.2 + .6 * aleaX[cpt % nbAlea]); // - + // fishDiameter/2; + fishY = displayShape.getBounds2D().getMinY() + + displayShape.getBounds2D().getHeight() * (0.2 + .6 * aleaY[cpt % nbAlea]);// - + // fishDiameter/2; + // System.out.println(! displayShape.contains(fishX, fishY)); cpt++; - } while (! displayShape.contains(fishX, fishY)); + } while (!displayShape.contains(fishX, fishY)); idxColor = bn.getRow(fish.getBirthBasin().getId()) % colors.size(); g.setColor(colors.get(idxColor)); - g2d.fillOval((int) fishX, (int) fishY, fishDiameter, - fishDiameter); + g2d.fillOval((int) fishX, (int) fishY, fishDiameter, fishDiameter); } } } } } } - - - - - - diff --git a/src/main/java/environment/BasinNetworkObserverWithRealBasin.java b/src/main/java/environment/BasinNetworkObserverWithRealBasin.java index e338805b0282e9e0160f03138770b234646cffce..f0563a91883a57a1d342151d2350a21415f01c9b 100644 --- a/src/main/java/environment/BasinNetworkObserverWithRealBasin.java +++ b/src/main/java/environment/BasinNetworkObserverWithRealBasin.java @@ -33,9 +33,9 @@ import fr.cemagref.simaqualife.kernel.util.TransientParameters; import fr.cemagref.simaqualife.pilot.Pilot; import species.DiadromousFishGroup; +@Deprecated @SuppressWarnings("serial") -public class BasinNetworkObserverWithRealBasin extends ObserverListener - implements Configurable, Drawable, MouseMotionListener { +public class BasinNetworkObserverWithRealBasin extends ObserverListener implements Configurable, Drawable, MouseMotionListener { private String title; private double threshold = 13000000.; @@ -131,8 +131,7 @@ public class BasinNetworkObserverWithRealBasin extends ObserverListener txt += (basin.getName() + " "); for (DiadromousFishGroup group : basin.getGroups()) { - txt += group.getName() + "=" + basin.getEffective(group) + " in " + basin.getSuperFishNumber(group) - + " SI "; + txt += group.getName() + "=" + basin.getEffective(group) + " in " + basin.getSuperFishNumber(group) + " SI "; } break; } diff --git a/src/main/java/environment/BasinNetworkReal.java b/src/main/java/environment/BasinNetworkReal.java index 5c6654334e25544e72dde916714f046e9b7119e0..de76bd90f085b1e6ed8c2593834bea732241df3f 100644 --- a/src/main/java/environment/BasinNetworkReal.java +++ b/src/main/java/environment/BasinNetworkReal.java @@ -26,6 +26,7 @@ import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientPara import fr.cemagref.simaqualife.pilot.Pilot; import miscellaneous.QueueMemoryMap; +@Deprecated public class BasinNetworkReal extends GridBasinNetwork { private String basinFile = "data/input/reality/basins.csv"; diff --git a/src/main/java/environment/BasinNetworkSWithContinent.java b/src/main/java/environment/BasinNetworkSWithContinent.java index cd289c0077b4036b33a0e1afd17aeebc0d740d24..0427ac7e174e3b6a8f632698bcb4c5cacd1971f3 100644 --- a/src/main/java/environment/BasinNetworkSWithContinent.java +++ b/src/main/java/environment/BasinNetworkSWithContinent.java @@ -461,5 +461,4 @@ public class BasinNetworkSWithContinent extends GridBasinNetwork { public Map<String, Path2D.Double> getMapContinent() { return mapContinent; } - } diff --git a/src/main/java/environment/BasinNetworkWith2Basins.java b/src/main/java/environment/BasinNetworkWith2Basins.java index 9646ca5ac24150aeac5b7b0d3b6d5d332b1b5299..5c7e360a95342ea406ee23e7a555398cdcea80f6 100644 --- a/src/main/java/environment/BasinNetworkWith2Basins.java +++ b/src/main/java/environment/BasinNetworkWith2Basins.java @@ -9,6 +9,7 @@ import environment.OffshoreBasin.OffshoreBasinFunction; import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters; import fr.cemagref.simaqualife.pilot.Pilot; +@Deprecated public class BasinNetworkWith2Basins extends GridBasinNetwork { private String nameOfBv[] = { "BV1", "BV2" }; diff --git a/src/main/java/species/NutrientRoutineEssay.java b/src/main/java/species/NutrientRoutineEssay.java index fe13c766c78b92d9d563327dffa346a98236617c..30e1ace17fa47e3ac1b1006e9267045a8796c460 100644 --- a/src/main/java/species/NutrientRoutineEssay.java +++ b/src/main/java/species/NutrientRoutineEssay.java @@ -1,10 +1,6 @@ package species; -import environment.InshoreBasin; -import fr.cemagref.simaqualife.pilot.Pilot; -import species.DiadromousFish.Gender; -import species.DiadromousFish.Stage; import java.util.ArrayList; import java.util.Hashtable; import java.util.Map; @@ -12,188 +8,177 @@ import java.util.Map; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; +import environment.InshoreBasin; +import fr.cemagref.simaqualife.pilot.Pilot; +import species.DiadromousFish.Gender; +import species.DiadromousFish.Stage; /** * @author camille.poulet * */ +@Deprecated public class NutrientRoutineEssay { + private static enum SpawningPosition { + PRE, POST + }; // on cr�er un static pour r�server une m�me classe m�moire pour toutes les instances - private static enum SpawningPosition {PRE,POST}; // on cr�er un static pour r�server une m�me classe m�moire pour toutes les instances - - //private static enum Gender {UNDIFFERENCIED, FEMALE, MALE}; + // private static enum Gender {UNDIFFERENCIED, FEMALE, MALE}; private ArrayList<String> nutrientsOfInterest; private double residenceTime; - private Map<String, Double> excretionRate; + private Map<String, Double> excretionRate; /** - * Main feature for weight (g) computation before spawning i.e. gametes expelling according to gender, for a given length (cm) - * //Voir pour un retour � la ligne lors du commentaire - * key gender - * value - * key feature - * value value + * Main feature for weight (g) computation before spawning i.e. gametes expelling according to gender, for a given + * length (cm) //Voir pour un retour � la ligne lors du commentaire key gender value key feature value value */ - private Map <DiadromousFish.Gender,Map<String, Double>> fishFeaturesPreSpawning; + private Map<DiadromousFish.Gender, Map<String, Double>> fishFeaturesPreSpawning; - private Map <DiadromousFish.Gender, Map<String, Double>> fishFeaturesPostSpawning; + private Map<DiadromousFish.Gender, Map<String, Double>> fishFeaturesPostSpawning; private Map<String, Double> juvenileFeatures; - /** - * Weight of gametes spawned for both males and females - * key gender - * value g - * usually computed as the difference between unspawned gonad (inbound) and spawned gonad (outbound; "spent gonad") + * Weight of gametes spawned for both males and females key gender value g usually computed as the difference + * between unspawned gonad (inbound) and spawned gonad (outbound; "spent gonad") */ - //private Map <DiadromousFish.Gender, Double> spawnedGametesWeight; - + // private Map <DiadromousFish.Gender, Double> spawnedGametesWeight; /** - * chemical composition of carcass before gametes expelling (before spawning) i.e. soma + gonads + gametes - * <key> gender - * <value> - * <key> chemical element - * <value> value ratio element / (total wet weight) g/g + * chemical composition of carcass before gametes expelling (before spawning) i.e. soma + gonads + gametes <key> + * gender <value> <key> chemical element <value> value ratio element / (total wet weight) g/g */ - private Map<DiadromousFish.Gender,Map<String,Double>> compoCarcassPreSpawning; - - //package permettant la cr�ation d'une table de hachage ie fonctionnant en cl� -valeur. Cl� unique, mais valeur peut �tre associ�e � plusieurs cl�s; - //La class d'objet Map a pour point faible la taille des donn�es � stocker. Plus on a de valeur dans la table, plus c'est lourd et lent! Donc, trouver un compromis entre temps de calcul et espace. - //N'accepte pas la valeur nulle et thread safe i.e. utilisable simultan�ment par plusieurs �l�ments du programme. + private Map<DiadromousFish.Gender, Map<String, Double>> compoCarcassPreSpawning; + // package permettant la cr�ation d'une table de hachage ie fonctionnant en cl� -valeur. Cl� unique, mais valeur + // peut �tre associ�e � plusieurs cl�s; + // La class d'objet Map a pour point faible la taille des donn�es � stocker. Plus on a de valeur dans la table, plus + // c'est lourd et lent! Donc, trouver un compromis entre temps de calcul et espace. + // N'accepte pas la valeur nulle et thread safe i.e. utilisable simultan�ment par plusieurs �l�ments du programme. /** - * chemical composition of gametes estimated from the MIGADO dataset (BDalosesBruch) - * <key> gender - * <value> - * <key> chemical element - * <value> value + * chemical composition of gametes estimated from the MIGADO dataset (BDalosesBruch) <key> gender <value> <key> + * chemical element <value> value */ - private Map<DiadromousFish.Gender, Map<String,Double>> compoGametes; + private Map<DiadromousFish.Gender, Map<String, Double>> compoGametes; // For juveniles - Based on Taverny (1991) /** - * chemical composition of juveniles - * <key> chemical element - * <value> value + * chemical composition of juveniles <key> chemical element <value> value */ - private Map<String,Double> compoJuvenile; - + private Map<String, Double> compoJuvenile; /** - * Constructor based on the 5 Map of fish composition + * Constructor based on the 5 Map of fish composition + * * @param fishFeaturesPreSpawning * @param compoCarcassPreSpawning * @param compoCarcassPostSpawning * @param compoGametes * @param compoJuvenile */ - public NutrientRoutineEssay(ArrayList<String> nutrientsOfInterest, + public NutrientRoutineEssay(ArrayList<String> nutrientsOfInterest, - double residenceTime, - Map <String, Double> excretionRate, + double residenceTime, Map<String, Double> excretionRate, Map<DiadromousFish.Gender, Map<String, Double>> fishFeaturesPreSpawning, Map<DiadromousFish.Gender, Map<String, Double>> fishFeaturesPostSpawning, Map<DiadromousFish.Gender, Map<String, Double>> compoCarcassPreSpawning, - Map<DiadromousFish.Gender, Map<String, Double>> compoGametes, - Map<String, Double> juvenileFeatures, - Map<String, Double> compoJuvenile) - { + Map<DiadromousFish.Gender, Map<String, Double>> compoGametes, Map<String, Double> juvenileFeatures, + Map<String, Double> compoJuvenile) { super(); this.nutrientsOfInterest = nutrientsOfInterest; - this.excretionRate = excretionRate; - this.residenceTime = residenceTime; + this.excretionRate = excretionRate; + this.residenceTime = residenceTime; this.fishFeaturesPreSpawning = fishFeaturesPreSpawning; this.fishFeaturesPostSpawning = fishFeaturesPostSpawning; this.compoCarcassPreSpawning = compoCarcassPreSpawning; this.compoGametes = compoGametes; this.juvenileFeatures = juvenileFeatures; - this.compoJuvenile = compoJuvenile; + this.compoJuvenile = compoJuvenile; } + /** - * compute the nutrient fluxes for a single fish (in the super individual) - * that dies before spawning + * compute the nutrient fluxes for a single fish (in the super individual) that dies before spawning + * * @param fish */ - public Map<String,Double> computeNutrientsInputForDeadFish(DiadromousFish fish, ArrayList<String> nutrientsOfInterest) { + public Map<String, Double> computeNutrientsInputForDeadFish(DiadromousFish fish, ArrayList<String> nutrientsOfInterest) { - Map<String,Double> nutrientsInput = new Hashtable<String, Double>(); // On cr�er ici une Map, classe m�re des hashtable (Homme = classe mere ie Map//Jules = hashtable) + Map<String, Double> nutrientsInput = new Hashtable<String, Double>(); // On cr�er ici une Map, classe m�re des + // hashtable (Homme = classe mere ie + // Map//Jules = hashtable) for (String nutrient : nutrientsOfInterest) { - if (fish.getStage()== Stage.MATURE) { - double totalWeightPre = this.getWeight(fish,SpawningPosition.PRE); - double carcass = totalWeightPre - * compoCarcassPreSpawning.get(fish.getGender()).get(nutrient); - double excretion = totalWeightPre - * residenceTime - * excretionRate.get(nutrient) ; + if (fish.getStage() == Stage.MATURE) { + double totalWeightPre = this.getWeight(fish, SpawningPosition.PRE); + double carcass = totalWeightPre * compoCarcassPreSpawning.get(fish.getGender()).get(nutrient); + double excretion = totalWeightPre * residenceTime * excretionRate.get(nutrient); double nutrientImport = carcass + excretion; - nutrientsInput.put(nutrient, nutrientImport); - } - else { + nutrientsInput.put(nutrient, nutrientImport); + } else { nutrientsInput.put(nutrient, 0.); } } - //TODO Multiply by fish amount + // TODO Multiply by fish amount return nutrientsInput; } - public Map<String,Double> computeNutrientsInputForDeadFish(DiadromousFish fish) { - return computeNutrientsInputForDeadFish(fish,this.nutrientsOfInterest); + public Map<String, Double> computeNutrientsInputForDeadFish(DiadromousFish fish) { + + return computeNutrientsInputForDeadFish(fish, this.nutrientsOfInterest); } + /** - * compute the nutrient fluxes for a single fish (in the super individual) - * that survives after spawning - * Map: model output = element of interest ie string + double ie the quantification of this fluxes. + * compute the nutrient fluxes for a single fish (in the super individual) that survives after spawning Map: model + * output = element of interest ie string + double ie the quantification of this fluxes. + * * @return nutrientsInput */ - public Map<String,Double>computeNutrientsInputForSurvivalAfterSpawning(DiadromousFish fish, ArrayList<String> nutrientsOfInterest) { - - Map<String,Double> nutrientsInput = new Hashtable<String,Double>(); - for (String nutrient: nutrientsOfInterest) { - if (fish.getStage()==Stage.MATURE) { - double totalWeightPre = this.getWeight(fish,SpawningPosition.PRE); - double gametes = (this.getGonadWeight(fish, SpawningPosition.PRE) - this.getGonadWeight(fish, SpawningPosition.POST)) - * compoGametes.get(fish.getGender()).get(nutrient); - double excretion = totalWeightPre - * residenceTime - * excretionRate.get(nutrient); + public Map<String, Double> computeNutrientsInputForSurvivalAfterSpawning(DiadromousFish fish, + ArrayList<String> nutrientsOfInterest) { + + Map<String, Double> nutrientsInput = new Hashtable<String, Double>(); + for (String nutrient : nutrientsOfInterest) { + if (fish.getStage() == Stage.MATURE) { + double totalWeightPre = this.getWeight(fish, SpawningPosition.PRE); + double gametes = (this.getGonadWeight(fish, SpawningPosition.PRE) + - this.getGonadWeight(fish, SpawningPosition.POST)) * compoGametes.get(fish.getGender()).get(nutrient); + double excretion = totalWeightPre * residenceTime * excretionRate.get(nutrient); double nutrientImport = gametes + excretion; - nutrientsInput.put(nutrient, nutrientImport); - } - else { - nutrientsInput.put(nutrient,0.); + nutrientsInput.put(nutrient, nutrientImport); + } else { + nutrientsInput.put(nutrient, 0.); } } return nutrientsInput; - } + } - public Map<String,Double>computeNutrientsInputForSurvivalAfterSpawning(DiadromousFish fish) { + + public Map<String, Double> computeNutrientsInputForSurvivalAfterSpawning(DiadromousFish fish) { return computeNutrientsInputForSurvivalAfterSpawning(fish, this.nutrientsOfInterest); } - public Map<String,Double> computeNutrientsExportForJuveniles(DiadromousFish juvenileFish, ArrayList<String>nutrientsOfInterest) { - Map<String,Double> nutrientsExport = new Hashtable<String,Double>(); - for(String nutrient: nutrientsOfInterest) { - if(juvenileFish.getStage()==Stage.IMMATURE) { + public Map<String, Double> computeNutrientsExportForJuveniles(DiadromousFish juvenileFish, + ArrayList<String> nutrientsOfInterest) { + Map<String, Double> nutrientsExport = new Hashtable<String, Double>(); + for (String nutrient : nutrientsOfInterest) { + if (juvenileFish.getStage() == Stage.IMMATURE) { double JuvenileMass = this.getWeight(juvenileFish); nutrientsExport.put(nutrient, JuvenileMass * compoJuvenile.get(nutrient)); @@ -203,74 +188,83 @@ public class NutrientRoutineEssay { return nutrientsExport; } - public Map<String,Double> computeNutrientsExportForJuveniles(DiadromousFish juvenileFish){ + + public Map<String, Double> computeNutrientsExportForJuveniles(DiadromousFish juvenileFish) { return computeNutrientsExportForJuveniles(juvenileFish, this.nutrientsOfInterest); } + /** - * Compute the weight for a fish with length (cm) + * Compute the weight for a fish with length (cm) + * * @param fish * @return weight (g) */ - public double getWeight (DiadromousFish fish, SpawningPosition spawningPosition) { - - double weight = 0.; - if (fish.getStage()==Stage.IMMATURE) - weight = juvenileFeatures.get("aLW") * Math.pow(fish.getLength(),juvenileFeatures.get("bLW")); - else //Stage.MATURE - weight = fishFeaturesPreSpawning.get(fish.getGender()).get("aLW") * Math.pow(fish.getLength(), fishFeaturesPreSpawning.get(fish.getGender()).get("bLW") ); - + public double getWeight(DiadromousFish fish, SpawningPosition spawningPosition) { + + double weight = 0.; + if (fish.getStage() == Stage.IMMATURE) + weight = juvenileFeatures.get("aLW") * Math.pow(fish.getLength(), juvenileFeatures.get("bLW")); + else // Stage.MATURE + weight = fishFeaturesPreSpawning.get(fish.getGender()).get("aLW") + * Math.pow(fish.getLength(), fishFeaturesPreSpawning.get(fish.getGender()).get("bLW")); + return weight; } + /** - * Compute the weight for a fish with length (cm) + * Compute the weight for a fish with length (cm) + * * @param fish * @return weight (g) */ - public double getWeight (DiadromousFish fish) { + public double getWeight(DiadromousFish fish) { - return getWeight (fish, SpawningPosition.PRE); + return getWeight(fish, SpawningPosition.PRE); } /** - * Compute the gonad weight for a fish with length (cm) to compute the gamete emission (g). + * Compute the gonad weight for a fish with length (cm) to compute the gamete emission (g). + * * @param fish * @return weight (g) */ - public double getGonadWeight (DiadromousFish fish, SpawningPosition spawningPosition) { + public double getGonadWeight(DiadromousFish fish, SpawningPosition spawningPosition) { - double gonadWeight = 0.; - if (fish.getStage()==Stage.MATURE); - if (spawningPosition == SpawningPosition.PRE) + double gonadWeight = 0.; + if (fish.getStage() == Stage.MATURE) + ; + if (spawningPosition == SpawningPosition.PRE) gonadWeight = Math.exp(fishFeaturesPreSpawning.get(fish.getGender()).get("aLW_Gonad") - + fishFeaturesPreSpawning.get(fish.getGender()).get("bLW_Gonad") * Math.log(fish.getLength())); - else + + fishFeaturesPreSpawning.get(fish.getGender()).get("bLW_Gonad") * Math.log(fish.getLength())); + else gonadWeight = Math.exp(fishFeaturesPostSpawning.get(fish.getGender()).get("aLW_Gonad") - + fishFeaturesPostSpawning.get(fish.getGender()).get("bLW_Gonad") * Math.log(fish.getLength())); + + fishFeaturesPostSpawning.get(fish.getGender()).get("bLW_Gonad") * Math.log(fish.getLength())); return gonadWeight; } - + + /** - * Compute the gonad weight for a fish with length (cm) to compute the gamete emission (g). + * Compute the gonad weight for a fish with length (cm) to compute the gamete emission (g). + * * @param fish * @return weight (g) */ - public double getGonadWeight (DiadromousFish fish) { - - return getGonadWeight (fish, SpawningPosition.PRE); - } - + public double getGonadWeight(DiadromousFish fish) { + return getGonadWeight(fish, SpawningPosition.PRE); + } public ArrayList<String> getNutrientsOfInterest() { return nutrientsOfInterest; } + /** * @param args */ @@ -280,158 +274,177 @@ public class NutrientRoutineEssay { /** * @param args */ - public static void main(String[] args) { + public static void main(String[] args) { - - double aResidenceTime =30; + double aResidenceTime = 30; System.out.println("aResidenceTime: " + aResidenceTime); // - - Map <String, Double> anExcretionRate = new Hashtable <String, Double>(); - anExcretionRate.put("N", 24.71E-6); //values from Barber et al, Alewifes in ug/g wet mass/hour : convertit en g - anExcretionRate.put("P", 2.17E-6); //values from Barber et al, Alewifes in ug/g wet mass/hour: convertit en g + Map<String, Double> anExcretionRate = new Hashtable<String, Double>(); + anExcretionRate.put("N", 24.71E-6); // values from Barber et al, Alewifes in ug/g wet mass/hour : convertit en g + anExcretionRate.put("P", 2.17E-6); // values from Barber et al, Alewifes in ug/g wet mass/hour: convertit en g System.out.println("anExcretionRate: " + anExcretionRate.toString()); // /* - * A feature pre spawning + * A feature pre spawning */ - Map<Gender, Map<String, Double>> aFeaturePreSpawning = new Hashtable<DiadromousFish.Gender, Map<String,Double>>(); + Map<Gender, Map<String, Double>> aFeaturePreSpawning = new Hashtable<DiadromousFish.Gender, Map<String, Double>>(); /* * For females */ - Map<String,Double> aFeature = new Hashtable<String,Double>(); + Map<String, Double> aFeature = new Hashtable<String, Double>(); - aFeature.put("bLW", 3.3429); //From Taverny - aFeature.put("aLW", 1.2102E-6 * Math.pow(10., aFeature.get("bLW"))); //weight size relationship -- Conversion des g/mm en g.cm (from Taverny, 1991) + aFeature.put("bLW", 3.3429); // From Taverny + aFeature.put("aLW", 1.2102E-6 * Math.pow(10., aFeature.get("bLW"))); // weight size relationship -- Conversion + // des g/mm en g.cm (from Taverny, 1991) aFeature.put("bLW_Gonad", 2.6729); // issu de la relation taille - poids des gonades Bruch aFeature.put("aLW_Gonad", -5.2425); // issu de la relation taille - poids des gonades Bruch - + aFeaturePreSpawning.put(Gender.FEMALE, aFeature); /* - * For males + * For males */ - aFeature = new Hashtable<String,Double>(); + aFeature = new Hashtable<String, Double>(); aFeature.put("bLW", 3.2252); - aFeature.put("aLW", 2.4386E-6 * Math.pow(10., aFeature.get("bLW"))); //weight size relationship from Taverny -- Conversion des g/mm en g.cm (from Taverny, 1991) - aFeature.put("bLW_Gonad", 3.3838); - aFeature.put("aLW_Gonad", -8.8744); - aFeaturePreSpawning.put(Gender.MALE,aFeature); + aFeature.put("aLW", 2.4386E-6 * Math.pow(10., aFeature.get("bLW"))); // weight size relationship from Taverny -- + // Conversion des g/mm en g.cm (from + // Taverny, 1991) + aFeature.put("bLW_Gonad", 3.3838); + aFeature.put("aLW_Gonad", -8.8744); + aFeaturePreSpawning.put(Gender.MALE, aFeature); System.out.println("aFeaturePreSpawning: " + aFeaturePreSpawning.toString()); // /* - * a Feature post Spawning + * a Feature post Spawning */ - Map<Gender, Map<String, Double>> aFeaturePostSpawning = new Hashtable<DiadromousFish.Gender, Map<String,Double>>(); + Map<Gender, Map<String, Double>> aFeaturePostSpawning = new Hashtable<DiadromousFish.Gender, Map<String, Double>>(); /* - * For females + * For females */ - aFeature = new Hashtable<String,Double>(); - + aFeature = new Hashtable<String, Double>(); + aFeature.put("aLW_Gonad", -6.6234); // issu de la relation taille - poids des gonades Bruch aFeature.put("bLW_Gonad", 2.8545); // issu de la relation taille - poids des gonades Bruch - + aFeaturePostSpawning.put(Gender.FEMALE, aFeature); /* - * For males + * For males */ - aFeature = new Hashtable<String,Double>(); + aFeature = new Hashtable<String, Double>(); aFeature.put("aLW_Gonad", -11.285); // issu de la relation taille - poids des gonades Bruch aFeature.put("bLW_Gonad", 3.8331); // issu de la relation taille - poids des gonades Bruch - - aFeaturePostSpawning.put(Gender.MALE,aFeature); + + aFeaturePostSpawning.put(Gender.MALE, aFeature); System.out.println("aFeaturePostSpawning: " + aFeaturePostSpawning.toString()); // carcass composition for fish before spawning - Map<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. Values from Haskell (2018) Alosa sapidissima (%) - aCompo.put("P", 0.673 / 100.); //Values from Haskell (2018) Alosa sapidissima (%) - aCompoCarcassPreSpawning.put(Gender.FEMALE,aCompo); - - aCompo = new Hashtable<String,Double>(); - aCompo.put("N", 2.941 / 100.); //Values from Haskell (2018) Alosa sapidissima (%) + Map<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. Values from Haskell (2018) Alosa + // sapidissima (%) + aCompo.put("P", 0.673 / 100.); // Values from Haskell (2018) Alosa sapidissima (%) + aCompoCarcassPreSpawning.put(Gender.FEMALE, aCompo); + + aCompo = new Hashtable<String, Double>(); + aCompo.put("N", 2.941 / 100.); // Values from Haskell (2018) Alosa sapidissima (%) aCompo.put("P", 0.666 / 100.);// Values from Haskell (2018) Alosa sapidissima (%) - aCompoCarcassPreSpawning.put(Gender.MALE,aCompo); + aCompoCarcassPreSpawning.put(Gender.MALE, aCompo); System.out.println("aCompoCarcassPreSpawning: " + aCompoCarcassPreSpawning.toString()); // + // Gametes composition approximated by the difference between gonads weight before and after spawning. + Map<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); - // Gametes composition approximated by the difference between gonads weight before and after spawning. - Map<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.); // Approxim�e par la compo des gonades + aCompo = new Hashtable<String, Double>(); + aCompo.put("N", 3.250 / 100.); // Approxim�e par la compo des gonades aCompo.put("P", 0.724 / 100.); - aCompoGametes.put(Gender.MALE,aCompo); + aCompoGametes.put(Gender.MALE, aCompo); System.out.println("aCompoGametes:" + aCompoGametes.toString()); // - // features for juveniles + // 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"))); + 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"))); - System.out.println("aJuvenileFeatures: " + aJuvenileFeatures.toString()); + System.out.println("aJuvenileFeatures: " + aJuvenileFeatures.toString()); - // 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 + // 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 - System.out.println("aCompoJuveniles: " + aCompoJuveniles.toString()); + System.out.println("aCompoJuveniles: " + aCompoJuveniles.toString()); - ArrayList <String> nutrientsOfInterest= new ArrayList <String>(); + ArrayList<String> nutrientsOfInterest = new ArrayList<String>(); nutrientsOfInterest.add("N"); nutrientsOfInterest.add("P"); System.out.println("nutrientsOfInterest: " + nutrientsOfInterest); - - NutrientRoutineEssay fn = new NutrientRoutineEssay(nutrientsOfInterest,aResidenceTime, anExcretionRate, aFeaturePreSpawning, aFeaturePostSpawning, - aCompoCarcassPreSpawning, aCompoGametes, aJuvenileFeatures, aCompoJuveniles); - - InshoreBasin basin = new InshoreBasin(0,"Bidon",10.,12., 14.,12.); //il faut aller dans "SeaBasin" dans "environement et regarder comment est construit le constructeur. Il lui faut ici un rang, un nom de bassin versant, et des temp�rature pour chaque saison - Pilot pilot = new Pilot (); - DiadromousFish fishFemale = new DiadromousFish (pilot, basin, 52., 1L, Gender.FEMALE); //Idem ici, on regarde comment est construit DiadromousFih et on lui donne les valeur de ce qu'il nous demande. + NutrientRoutineEssay fn = new NutrientRoutineEssay(nutrientsOfInterest, aResidenceTime, anExcretionRate, + aFeaturePreSpawning, aFeaturePostSpawning, aCompoCarcassPreSpawning, aCompoGametes, aJuvenileFeatures, + aCompoJuveniles); + + InshoreBasin basin = new InshoreBasin(0, "Bidon", 10., 12., 14., 12.); // il faut aller dans "SeaBasin" dans + // "environement et regarder comment est + // construit le constructeur. Il lui + // faut ici un rang, un nom de bassin + // versant, et des temp�rature pour + // chaque saison + Pilot pilot = new Pilot(); + DiadromousFish fishFemale = new DiadromousFish(pilot, basin, 52., 1L, Gender.FEMALE); // Idem ici, on regarde + // comment est construit + // DiadromousFih et on + // lui donne les valeur + // de ce qu'il nous + // demande. fishFemale.setStage(Stage.MATURE); - DiadromousFish fishMale = new DiadromousFish (pilot, basin, 47., 1L, Gender.MALE); //Idem ici, on regarde comment est construit DiadromousFih et on lui donne les valeur de ce qu'il nous demande. + DiadromousFish fishMale = new DiadromousFish(pilot, basin, 47., 1L, Gender.MALE); // Idem ici, on regarde + // comment est construit + // DiadromousFih et on lui + // donne les valeur de ce + // qu'il nous demande. fishMale.setStage(Stage.MATURE); - DiadromousFish juvenileFish = new DiadromousFish(pilot,basin,7.0,1L,Gender.UNDIFFERENCIED); + DiadromousFish juvenileFish = new DiadromousFish(pilot, basin, 7.0, 1L, Gender.UNDIFFERENCIED); juvenileFish.setStage(Stage.IMMATURE); - System.out.println(); // affiche une ligne blanche - System.out.println(fishFemale.getGender() + ": " + fishFemale.getLength() + " cm " + fn.getWeight(fishFemale, SpawningPosition.PRE)+ " g " + fn.getWeight(fishFemale, SpawningPosition.POST)); + System.out.println(); // affiche une ligne blanche + System.out.println(fishFemale.getGender() + ": " + fishFemale.getLength() + " cm " + + fn.getWeight(fishFemale, SpawningPosition.PRE) + " g " + fn.getWeight(fishFemale, SpawningPosition.POST)); System.out.println("\tNutrients Fluxes for dead fish " + fn.computeNutrientsInputForDeadFish(fishFemale).toString()); - System.out.println("\tNutrients Fluxes for survival " + fn.computeNutrientsInputForSurvivalAfterSpawning(fishFemale).toString()); + System.out.println( + "\tNutrients Fluxes for survival " + fn.computeNutrientsInputForSurvivalAfterSpawning(fishFemale).toString()); - System.out.println(fishMale.getGender() + ": " + fishMale.getLength() + " cm " + fn.getWeight(fishMale, SpawningPosition.PRE)+ " g " + fn.getWeight(fishMale, SpawningPosition.POST)); + System.out.println(fishMale.getGender() + ": " + fishMale.getLength() + " cm " + + fn.getWeight(fishMale, SpawningPosition.PRE) + " g " + fn.getWeight(fishMale, SpawningPosition.POST)); System.out.println("\tNutrients Fluxes for dead fish " + fn.computeNutrientsInputForDeadFish(fishMale).toString()); - System.out.println("\tNutrients Fluxes for survival " + fn.computeNutrientsInputForSurvivalAfterSpawning(fishMale).toString()); + System.out.println( + "\tNutrients Fluxes for survival " + fn.computeNutrientsInputForSurvivalAfterSpawning(fishMale).toString()); - System.out.println(juvenileFish.getStage() + ": " + juvenileFish.getLength() + " cm " + fn.getWeight(juvenileFish)+ " g "); + 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 + /* + * Create XML file * */ - System.out.println((new XStream(new DomDriver())).toXML(fn)); + System.out.println((new XStream(new DomDriver())).toXML(fn)); - } + } } - - diff --git a/src/main/java/species/WriteEffectiveAndBiomassImportFluxes.java b/src/main/java/species/WriteEffectiveAndBiomassImportFluxes.java index be6b38b390765bec8d02dba297743b4f423ae5da..2146f10ef91ba70df240be83f9f09bd3a12e5303 100644 --- a/src/main/java/species/WriteEffectiveAndBiomassImportFluxes.java +++ b/src/main/java/species/WriteEffectiveAndBiomassImportFluxes.java @@ -39,7 +39,7 @@ import species.DiadromousFish.Stage; /** * */ -public class WriteEffectiveAndBiomassFluxes extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> { +public class WriteEffectiveAndBiomassImportFluxes extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> { private Season exportSeason = Season.SPRING; @@ -50,7 +50,7 @@ public class WriteEffectiveAndBiomassFluxes extends AquaNismsGroupProcess<Diadro public static void main(String[] args) { - System.out.println((new XStream(new DomDriver())).toXML(new WriteEffectiveAndBiomassFluxes())); + System.out.println((new XStream(new DomDriver())).toXML(new WriteEffectiveAndBiomassImportFluxes())); } diff --git a/src/main/java/species/WriteEffectivesFluxes.java b/src/main/java/species/WriteEffectivesFluxes.java index c386fb2bd07e210c1d7a586f5d830b1d2902ef8f..51610858c9d94bd4861eae11fc9378bd066c4b32 100644 --- a/src/main/java/species/WriteEffectivesFluxes.java +++ b/src/main/java/species/WriteEffectivesFluxes.java @@ -39,6 +39,7 @@ import species.DiadromousFish.Stage; /** * */ +@Deprecated public class WriteEffectivesFluxes extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> { private Season exportSeason = Season.SPRING; @@ -46,36 +47,42 @@ public class WriteEffectivesFluxes extends AquaNismsGroupProcess<DiadromousFish, private String fileNameOutput = "effectiveFluxes"; 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 WriteEffectivesFluxes())); + System.out.println((new XStream(new DomDriver())).toXML(new WriteEffectivesFluxes())); } - /* (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.getSimulationId() + ".csv"))); - bW.write("year"+sep+"migrationBasin" ); //create the field of the column + bW.write("year" + sep + "migrationBasin"); // create the field of the column for (String birthBasinName : group.getEnvironment().getRiverBasinNames()) { - bW.write(sep + birthBasinName); // write each basin name in the file + bW.write(sep + birthBasinName); // write each basin name in the file } bW.write("\n"); @@ -85,40 +92,41 @@ public class WriteEffectivesFluxes extends AquaNismsGroupProcess<DiadromousFish, } } - try { Time time = group.getEnvironment().getTime(); if (time.getSeason(pilot) == exportSeason & time.getYear(pilot) >= group.getMinYearToWrite()) { for (RiverBasin migrationBasin : group.getEnvironment().getRiverBasins()) { - //Create the map to get the abundance in each birth basin - Map<String, Long> spawnerOriginsBeforeReproduction = new HashMap<String, Long>(group.getEnvironment().getRiverBasinNames().length); - for (String basinName : group.getEnvironment().getRiverBasinNames()){ - spawnerOriginsBeforeReproduction.put(basinName, 0L); + // Create the map to get the abundance in each 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 effective per birth basin + // compute the cumulative effective 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() ); + spawnerOriginsBeforeReproduction.put(birthBasinName, + spawnerOriginsBeforeReproduction.get(birthBasinName) + fish.getAmount()); } } } - //write the first two fields of the line - bW.write(time.getYear(pilot)+sep+migrationBasin.getName()); + // write the first two fields of the line + bW.write(time.getYear(pilot) + sep + migrationBasin.getName()); - //write the cumulative effective from birth basin + // write the cumulative effective from birth basin for (String birthBasinName : group.getEnvironment().getRiverBasinNames()) { - bW.write(sep+spawnerOriginsBeforeReproduction.get(birthBasinName)); + bW.write(sep + spawnerOriginsBeforeReproduction.get(birthBasinName)); } // write an end-of-line bW.write("\n"); } } - 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(); }