/* * #%L * IsisFish data * %% * Copyright (C) 2006 - 2018 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 * . * #L% */ package exports; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.io.Writer; import org.nuiton.math.matrix.*; import resultinfos.MatrixBiomass; import fr.ifremer.isisfish.entities.*; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.types.TimeStep; import resultinfos.MatrixBiomassBeginMonth; import fr.ifremer.isisfish.datastore.SimulationStorage; /** * BiomasseBeginMonthFeconde_Janvier.java * * Created: 21 fev 2024 * * @author smahevas * @version $Revision: $ * * */ public class BiomasseBeginMonthFeconde_Janvier implements Export { /** to use log facility, just put in your code: log.info("..."); */ static private Log log = LogFactory.getLog(BiomasseBeginMonthFeconde_Janvier.class); protected String [] necessaryResult = { MatrixBiomassBeginMonth.NAME }; @Override public String[] getNecessaryResult() { return this.necessaryResult; } @Override public String getExportFilename() { return "BiomasseBeginMonthFeconde_Janvier"; } @Override public String getExtensionFilename() { return ".csv"; } @Override public String getDescription() { return "Exporte les biomasses fecondes, tableau avec des lignes pop;date_janvier;val"; } @Override public void export(SimulationStorage simulation, Writer out) throws Exception { for (Population pop : simulation.getParameter().getPopulations()) { MatrixND mat = simulation.getResultStorage().getMatrix(pop, MatrixBiomassBeginMonth.NAME); mat = mat.sumOverDim(2); //sum on zones mat = mat.reduce(); // calcul Biomasse geniteurs for (MatrixIterator i=mat.iterator(); i.hasNext();) { i.next(); Object [] sems = i.getSemanticsCoordinates(); PopulationGroup group = (PopulationGroup) sems[1]; double val = i.getValue() * group.getMaturityOgive(); i.setValue(val); } mat = mat.sumOverDim(1); //sum on group mat = mat.reduce(); for (MatrixIterator i=mat.iterator(); i.hasNext();) { i.next(); Object [] sems = i.getSemanticsCoordinates(); TimeStep step = (TimeStep)sems[0]; int mois = 0; //en janvier if(step.getMonth().getMonthNumber()==mois) { out.write(pop.getName() + ";" + step.getStep() + ";" + i.getValue() + "\n"); } } } } }