/* * #%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.Strategy; import fr.ifremer.isisfish.entities.Population; import fr.ifremer.isisfish.entities.PopulationGroup; 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 resultinfos.MatrixCatchPerStrategyMetPerZoneMet; import java.io.Writer; /** * Captures_AgeStructure.java * * Export des captures en poids de la forme : * Population ; Métier ; Groupe ; Zone ; Pas de temps ; Valeur * * @author anonymous * @version $Revision: 1.4 $ * * Last update: $Date: 2007-05-24 09:30:07 $ by : $Author: bpoussin $ */ public class Captures_AgeStructure implements Export { /** to use log facility, just put in your code: log.info("..."); */ static private Log log = LogFactory.getLog(Captures_AgeStructure.class); protected String[] necessaryResult = { MatrixCatchPerStrategyMetPerZoneMet.NAME }; @Override public String[] getNecessaryResult() { return this.necessaryResult; } @Override public String getExportFilename() { return "Captures_AgeStructure"; } @Override public String getExtensionFilename() { return ".csv"; } @Override public String getDescription() { return "Export les captures annuelles par groupe. tableau year;pop;groupe;nombre"; } @Override public void export(SimulationStorage simulation, Writer out) throws Exception { out.write("year;population;group;value\n"); for (Population pop : simulation.getParameter().getPopulations()) { MatrixND mat = simulation.getResultStorage().getMatrix(pop, MatrixCatchPerStrategyMetPerZoneMet.NAME); mat = mat.sumOverDim(0,12); mat = mat.sumOverDim(1); // str mat = mat.sumOverDim(2); // met mat = mat.sumOverDim(4); // zon mat = mat.reduceDims(4); mat = mat.reduceDims(2); mat = mat.reduceDims(1); for (MatrixIterator i = mat.iterator(); i.hasNext();) { i.next(); Object[] sems = i.getSemanticsCoordinates(); int year = (int) sems[0]; //Metier metier = (Metier) sems[1]; PopulationGroup group = (PopulationGroup) sems[1]; //Zone zone = (Zone) sems[2]; double val = i.getValue(); out.write(year + ";" + pop.getName() + ";" //+metier.getName() + ";" //+ ";" + zone.getName() + group.getId() + ";" + val + "\n"); } } } }