/* * #%L * IsisFish data * %% * Copyright (C) 2006 - 2014 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 3 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 * . * #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.Zone; import fr.ifremer.isisfish.entities.Strategy; 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 resultinfos.MatrixFishingMortality; import java.io.Writer; /** * CapturesPoidsStrategies.java * * Export des F de la forme : pop,zonepop,step,val * * @author anonymous * @version $Revision: 1.4 $ * * Last update: $Date: 2007-05-24 09:30:07 $ by : $Author: bpoussin $ */ public class FishingMortalityPopZoneMois implements Export { /** to use log facility, just put in your code: log.info("..."); */ static private Log log = LogFactory.getLog(FishingMortalityPopZoneMois.class); protected String[] necessaryResult = { MatrixFishingMortality.NAME }; @Override public String[] getNecessaryResult() { return this.necessaryResult; } @Override public String getExportFilename() { return "FishingMortalityPopZoneMois"; } @Override public String getExtensionFilename() { return ".csv"; } @Override public String getDescription() { return "Export les valeurs F de la simulation. tableau pop;zonepop;step;nombre"; } @Override public void export(SimulationStorage simulation, Writer out) throws Exception { out.write("population;zonepop;step;value\n"); for (Population pop : simulation.getParameter().getPopulations()) { MatrixND mat = simulation.getResultStorage().getMatrix(pop,MatrixFishingMortality.NAME); // step, str, met, group, zonepop if (mat != null) { // can be null if simulation is stopped before last year simulation mat = mat //.sumOverDim(0,12); //sum per year .sumOverDim(1) //sum on str .sumOverDim(2) //sum on metier .sumOverDim(3) //sum on group //.sumOverDim(4) //sum on zones // .reduceDims(4) // si pop avec une seule zone .reduceDims(3);//si pop avec un seul group for (MatrixIterator i = mat.iterator(); i.hasNext();) { i.next(); Object[] sems = i.getSemanticsCoordinates(); //Strategy strategy = (Strategy) sems[1]; //Metier metier = (Metier) sems[2]; Zone zone = (Zone) sems[4]; TimeStep step = (TimeStep) sems[0]; //int mois = step.getMonth().getMonthNumber(); double val = i.getValue(); System.out.println("export F : " + zone); out.write(pop.getName() + ";" // + strategy.getName() + ";" + zone.getName() + ";" + step.getStep() + ";" + val + "\n"); // + metier.getName() + ";" } } } } }