Author: jcouteau Date: 2011-12-09 17:29:25 +0100 (Fri, 09 Dec 2011) New Revision: 270 Url: http://forge.codelutin.com/repositories/revision/isis-fish-data/270 Log: #411 : Garder l'info strategy dans les exports de captures - Nouveaux exports avec strat?\195?\169gie Added: trunk/exports/CapturesNombreStrategies.java trunk/exports/CapturesPoidsStrategies.java Modified: trunk/exports/CapturesNombre.java trunk/exports/CapturesPoids.java Modified: trunk/exports/CapturesNombre.java =================================================================== --- trunk/exports/CapturesNombre.java 2011-12-02 19:19:55 UTC (rev 269) +++ trunk/exports/CapturesNombre.java 2011-12-09 16:29:25 UTC (rev 270) @@ -21,16 +21,6 @@ */ package exports; -import static org.nuiton.i18n.I18n._; - -import java.io.Writer; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.math.matrix.MatrixIterator; -import org.nuiton.math.matrix.MatrixND; - -import scripts.ResultName; import fr.ifremer.isisfish.datastore.SimulationStorage; import fr.ifremer.isisfish.entities.Metier; import fr.ifremer.isisfish.entities.Population; @@ -38,12 +28,22 @@ import fr.ifremer.isisfish.entities.Zone; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.types.TimeStep; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixIterator; +import org.nuiton.math.matrix.MatrixND; +import scripts.ResultName; +import java.io.Writer; + +import static org.nuiton.i18n.I18n._; + /** * CapturesNombre.java * - * Created: 23 novembre 2006 - * + * Export des captures en nombre de la forme : + * Population ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur + * * @author anonymous <anonymous@labs.libre-entreprise.org> * @version $Revision: 1.4 $ * Added: trunk/exports/CapturesNombreStrategies.java =================================================================== --- trunk/exports/CapturesNombreStrategies.java (rev 0) +++ trunk/exports/CapturesNombreStrategies.java 2011-12-09 16:29:25 UTC (rev 270) @@ -0,0 +1,110 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2006 - 2011 Ifremer, CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ +package exports; + +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.Strategy; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.export.Export; +import fr.ifremer.isisfish.types.TimeStep; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixIterator; +import org.nuiton.math.matrix.MatrixND; +import scripts.ResultName; + +import java.io.Writer; + +import static org.nuiton.i18n.I18n._; + +/** + * CapturesNombreStrategies.java + * + * Export des captures en nombre de la forme : + * Population ; Stratégie ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur + * + * @author anonymous <anonymous@labs.libre-entreprise.org> + * @version $Revision: 1.4 $ + * + * Last update: $Date: 2007-05-24 09:30:07 $ by : $Author: bpoussin $ + */ +public class CapturesNombreStrategies implements Export { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory.getLog(CapturesNombre.class); + + protected String[] necessaryResult = { ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP }; + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + + @Override + public String getExportFilename() { + return "CapturesNombreStrategies"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String getDescription() { + return _("Export les captures en nombre de la simulation. tableau pop;strategie;metier;id;zone;nombre"); + } + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + TimeStep lastStep = simulation.getResultStorage().getLastStep(); + + for (Population pop : simulation.getParameter().getPopulations()) { + for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step + .next()) { + MatrixND mat = simulation.getResultStorage().getMatrix(step, + pop, ResultName.MATRIX_CATCH_PER_STRATEGY_MET_PER_ZONE_POP); + if (mat != null) { // can be null if simulation is stopped before last year simulation + //mat = mat.sumOverDim(0); //sum on strategy + for (MatrixIterator i = mat.iterator(); i.hasNext();) { + i.next(); + Object[] sems = i.getSemanticsCoordinates(); + Metier metier = (Metier) sems[1]; + PopulationGroup group = (PopulationGroup) sems[2]; + Zone zone = (Zone) sems[3]; + Strategy strategy = (Strategy) sems[0]; + + double val = i.getValue(); + out.write(pop.getName() + ";" + strategy.getName() + ";" + + metier.getName() + ";" + group.getId() + ";" + + zone.getName() + ";" + step.getStep() + ";" + + val + "\n"); + } + } + } + } + } +} Modified: trunk/exports/CapturesPoids.java =================================================================== --- trunk/exports/CapturesPoids.java 2011-12-02 19:19:55 UTC (rev 269) +++ trunk/exports/CapturesPoids.java 2011-12-09 16:29:25 UTC (rev 270) @@ -21,16 +21,6 @@ */ package exports; -import static org.nuiton.i18n.I18n._; - -import java.io.Writer; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.math.matrix.MatrixIterator; -import org.nuiton.math.matrix.MatrixND; - -import scripts.ResultName; import fr.ifremer.isisfish.datastore.SimulationStorage; import fr.ifremer.isisfish.entities.Metier; import fr.ifremer.isisfish.entities.Population; @@ -38,11 +28,21 @@ import fr.ifremer.isisfish.entities.Zone; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.types.TimeStep; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixIterator; +import org.nuiton.math.matrix.MatrixND; +import scripts.ResultName; +import java.io.Writer; + +import static org.nuiton.i18n.I18n._; + /** * CapturesPoids.java * - * Created: 23 novembre 2006 + * Export des captures en poids de la forme : + * Population ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur * * @author anonymous <anonymous@labs.libre-entreprise.org> * @version $Revision: 1.4 $ Added: trunk/exports/CapturesPoidsStrategies.java =================================================================== --- trunk/exports/CapturesPoidsStrategies.java (rev 0) +++ trunk/exports/CapturesPoidsStrategies.java 2011-12-09 16:29:25 UTC (rev 270) @@ -0,0 +1,110 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2006 - 2011 Ifremer, CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ +package exports; + +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.Strategy; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.export.Export; +import fr.ifremer.isisfish.types.TimeStep; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixIterator; +import org.nuiton.math.matrix.MatrixND; +import scripts.ResultName; + +import java.io.Writer; + +import static org.nuiton.i18n.I18n._; + +/** + * CapturesPoidsStrategies.java + * + * Export des captures en poids de la forme : + * Population ; Stratégie ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur + * + * @author anonymous <anonymous@labs.libre-entreprise.org> + * @version $Revision: 1.4 $ + * + * Last update: $Date: 2007-05-24 09:30:07 $ by : $Author: bpoussin $ + */ +public class CapturesPoidsStrategies implements Export { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory.getLog(CapturesPoids.class); + + protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP }; + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + + @Override + public String getExportFilename() { + return "CapturesPoidsStrategies"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String getDescription() { + return _("Export les captures en poids de la simulation. tableau pop;strategie;metier;id;zone;nombre"); + } + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + TimeStep lastStep = simulation.getResultStorage().getLastStep(); + + for (Population pop : simulation.getParameter().getPopulations()) { + for (TimeStep step = new TimeStep(0); !step.after(lastStep); step = step + .next()) { + MatrixND mat = simulation.getResultStorage().getMatrix(step, + pop, ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + if (mat != null) { // can be null if simulation is stopped before last year simulation + //mat = mat.sumOverDim(0); //sum on strategy + for (MatrixIterator i = mat.iterator(); i.hasNext();) { + i.next(); + Object[] sems = i.getSemanticsCoordinates(); + Metier metier = (Metier) sems[1]; + PopulationGroup group = (PopulationGroup) sems[2]; + Zone zone = (Zone) sems[3]; + Strategy strategy = (Strategy) sems[0]; + + double val = i.getValue(); + out.write(pop.getName() + ";" + strategy.getName() + ";" + + metier.getName() + ";" + group.getId() + ";" + + zone.getName() + ";" + step.getStep() + ";" + + val + "\n"); + } + } + } + } + } +}
participants (1)
-
jcouteau@users.forge.codelutin.com