Author: chatellier Date: 2011-07-08 14:23:25 +0000 (Fri, 08 Jul 2011) New Revision: 3442 Log: Fix isis test database Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java Removed: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightReferenceY7.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeReferenceY10.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeY4.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightY1.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassReferenceY8.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeReferenceY11.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeY5.java isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassY2.java Deleted: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightReferenceY7.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightReferenceY7.java 2011-07-08 14:22:36 UTC (rev 3441) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightReferenceY7.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -1,122 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Ifremer, Code Lutin - * %% - * 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 sensitivityexports; - -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.MatrixND; -import org.nuiton.topia.TopiaContext; - -import scripts.ResultName; -import fr.ifremer.isisfish.datastore.ResultStorage; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.util.Doc; - -public class SensitivityCapturesWeightReferenceY7 implements SensitivityExport { - - /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory - .getLog(SensitivityCapturesWeightReferenceY7.class); - - protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP }; - - @Doc("Population") - public Population param_pop; - - @Doc("Name of the reference simulation") - public String param_referenceSimulation = ""; - - @Override - public void export(SimulationStorage simulation, Writer out) - throws Exception { - SimulationStorage referenceSimulation = SimulationStorage - .getSimulation(param_referenceSimulation); - ResultStorage referenceResultStorage = referenceSimulation - .getResultStorage(); - ResultStorage resultStorage = simulation.getResultStorage(); - Date lastDate = resultStorage.getLastDate(); - Double capturesWeight = 0.0; - Double capturesWeightReference = 0.0; - - for (Population pop : simulation.getParameter().getPopulations()) { - if (pop.getName().equals(param_pop.getName())) { - for (int i = 0; i < 12; i++) { - - //Get the captures Weight of each month of the last year - MatrixND matlastdate = resultStorage - .getMatrix( - new Date(lastDate.getDate() - i), - pop, - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); - capturesWeight += matlastdate.sumAll(); - - //Get the reference captures Weight of each month of the last year - TopiaContext tx = referenceSimulation.getStorage() - .beginTransaction(); - MatrixND matlastdatereference = referenceResultStorage - .getMatrix( - new Date(lastDate.getDate() - i), - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP - + " " + pop, tx); - capturesWeightReference += matlastdatereference.sumAll(); - tx.commitTransaction(); - tx.closeContext(); - - } - - } - } - - out.write(Double.toString(capturesWeight / capturesWeightReference)); - } - - @Override - public String getDescription() { - return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies"); - } - - @Override - public String getExportFilename() { - return "SensitivityCapturesWeightReferenceY7"; - } - - @Override - public String getExtensionFilename() { - return ".csv"; - } - - @Override - public String[] getNecessaryResult() { - return this.necessaryResult; - } - -} \ No newline at end of file Deleted: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeReferenceY10.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeReferenceY10.java 2011-07-08 14:22:36 UTC (rev 3441) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeReferenceY10.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -1,142 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Ifremer, Code Lutin - * %% - * 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 sensitivityexports; - -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.MatrixND; -import org.nuiton.topia.TopiaContext; - -import scripts.ResultName; -import fr.ifremer.isisfish.datastore.ResultStorage; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.util.Doc; - -public class SensitivityCapturesWeightRelativeReferenceY10 implements - SensitivityExport { - - /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory - .getLog(SensitivityCapturesWeightRelativeReferenceY10.class); - - protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP }; - - @Doc("Population") - public Population param_pop; - - @Doc("Name of the reference simulation") - public String param_referenceSimulation = ""; - - @Override - public void export(SimulationStorage simulation, Writer out) - throws Exception { - SimulationStorage referenceSimulation = SimulationStorage - .getSimulation(param_referenceSimulation); - ResultStorage referenceResultStorage = referenceSimulation - .getResultStorage(); - ResultStorage resultStorage = simulation.getResultStorage(); - Date lastDate = resultStorage.getLastDate(); - Double capturesWeight = 0.0; - Double capturesWeightfirst = 0.0; - Double capturesWeightreference = 0.0; - Double capturesWeightfirstreference = 0.0; - - for (Population pop : simulation.getParameter().getPopulations()) { - if (pop.getName().equals(param_pop.getName())) { - for (int i = 0; i < 12; i++) { - - //Get the captures Weight of each month of the last year - MatrixND matlastdate = resultStorage - .getMatrix( - new Date(lastDate.getDate() - i), - pop, - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); - capturesWeight += matlastdate.sumAll(); - - //Get the captures Weight of each month of the first year - MatrixND matfirstdate = resultStorage - .getMatrix( - new Date(i), - pop, - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); - capturesWeightfirst += matfirstdate.sumAll(); - - //Get the reference captures Weight of each month of the last year - - TopiaContext tx = referenceSimulation.getStorage() - .beginTransaction(); - - MatrixND matlastdatereference = referenceResultStorage - .getMatrix( - new Date(lastDate.getDate() - i), - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP - + " " + pop, tx); - capturesWeightreference += matlastdatereference.sumAll(); - - //Get the reference captures Weight of each month of the first year - MatrixND matfirstdatereference = referenceResultStorage - .getMatrix( - new Date(i), - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP - + " " + pop, tx); - capturesWeightfirstreference += matfirstdatereference - .sumAll(); - tx.commitTransaction(); - tx.closeContext(); - } - } - } - out.write(Double.toString((capturesWeight / capturesWeightfirst) - / (capturesWeightreference / capturesWeightfirstreference))); - } - - @Override - public String getDescription() { - return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies"); - } - - @Override - public String getExportFilename() { - return "SensitivityCapturesWeightRelativeReferenceY10"; - } - - @Override - public String getExtensionFilename() { - return ".csv"; - } - - @Override - public String[] getNecessaryResult() { - return this.necessaryResult; - } - -} Deleted: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeY4.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeY4.java 2011-07-08 14:22:36 UTC (rev 3441) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightRelativeY4.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -1,109 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Ifremer, Code Lutin - * %% - * 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 sensitivityexports; - -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.MatrixND; - -import scripts.ResultName; -import fr.ifremer.isisfish.datastore.ResultStorage; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.util.Doc; - -public class SensitivityCapturesWeightRelativeY4 implements SensitivityExport { - - /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory - .getLog(SensitivityCapturesWeightRelativeY4.class); - - protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP }; - - @Doc("Population") - public Population param_pop; - - @Override - public void export(SimulationStorage simulation, Writer out) - throws Exception { - ResultStorage resultStorage = simulation.getResultStorage(); - Date lastDate = resultStorage.getLastDate(); - Double capturesWeight = 0.0; - Double capturesWeightfirst = 0.0; - - for (Population pop : simulation.getParameter().getPopulations()) { - if (pop.getName().equals(param_pop.getName())) { - for (int i = 0; i < 12; i++) { - - //Get the captures Weight of each month of the last year - MatrixND matlastdate = resultStorage - .getMatrix( - new Date(lastDate.getDate() - i), - pop, - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); - capturesWeight += matlastdate.sumAll(); - - //Get the captures Weight of each month of the first year - MatrixND matfirstdate = resultStorage - .getMatrix( - new Date(i), - pop, - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); - capturesWeightfirst += matfirstdate.sumAll(); - } - - } - } - - out.write(Double.toString(capturesWeight / capturesWeightfirst)); - } - - @Override - public String getDescription() { - return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies"); - } - - @Override - public String getExportFilename() { - return "SensitivityCapturesWeightRelativeY4"; - } - - @Override - public String getExtensionFilename() { - return ".csv"; - } - - @Override - public String[] getNecessaryResult() { - return this.necessaryResult; - } - -} Deleted: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightY1.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightY1.java 2011-07-08 14:22:36 UTC (rev 3441) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCapturesWeightY1.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -1,100 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Ifremer, Code Lutin - * %% - * 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 sensitivityexports; - -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.MatrixND; - -import scripts.ResultName; -import fr.ifremer.isisfish.datastore.ResultStorage; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.util.Doc; - -public class SensitivityCapturesWeightY1 implements SensitivityExport { - - /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory - .getLog(SensitivityCapturesWeightY1.class); - - protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP }; - - @Doc("Population") - public Population param_pop; - - @Override - public void export(SimulationStorage simulation, Writer out) - throws Exception { - ResultStorage resultStorage = simulation.getResultStorage(); - Date lastDate = resultStorage.getLastDate(); - Double capturesWeight = 0.0; - - for (Population pop : simulation.getParameter().getPopulations()) { - if (pop.getName().equals(param_pop.getName())) { - for (int i = 0; i < 12; i++) { - - //Get the captures Weight of each month of the last year - MatrixND matlastdate = resultStorage - .getMatrix( - new Date(lastDate.getDate() - i), - pop, - ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); - capturesWeight += matlastdate.sumAll(); - } - - } - } - - out.write(Double.toString(capturesWeight)); - } - - @Override - public String getDescription() { - return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies"); - } - - @Override - public String getExportFilename() { - return "SensitivityCapturesWeightY1"; - } - - @Override - public String getExtensionFilename() { - return ".csv"; - } - - @Override - public String[] getNecessaryResult() { - return this.necessaryResult; - } - -} Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java (rev 0) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -0,0 +1,137 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * %% + * 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 sensitivityexports; + +import static org.nuiton.i18n.I18n._; + +import java.io.File; +import java.io.Writer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixND; + +import org.nuiton.util.ReverseFileReader; +import scripts.ResultName; +import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.export.SensitivityExport; +import fr.ifremer.isisfish.types.TimeStep; +import fr.ifremer.isisfish.util.Doc; + +public class SensitivityCatchWeightReferenceY7 implements SensitivityExport { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory + .getLog(SensitivityCatchWeightReferenceY7.class); + + protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP }; + + @Doc("Population") + public Population param_pop; + + @Doc("Path of the CapturesPoids.csv file") + public String param_referenceCatchWeightCSV =""; + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + ResultStorage resultStorage = simulation.getResultStorage(); + TimeStep lastStep = resultStorage.getLastStep(); + Double capturesWeight = 0.0; + Double capturesWeightReference = 0.0; + + File referenceFile = new File(param_referenceCatchWeightCSV); + + //instantiate a reader that starts reading from the file end. + ReverseFileReader reader = new ReverseFileReader(referenceFile); + + //read the last line of the file (should be empty) + String line = reader.readLine(); + + //read the next line (the last written line) + line = reader.readLine(); + + Integer lastMonth = 0; + + while (line != null ) { + + String[] items = line.split(";"); + + //If we did not initiate the last date (we are on the last line of + // the file), we do it now with the value of the date. + if (lastMonth == 0) { + lastMonth = Integer.parseInt(items[4]); + } + + Integer month = Integer.parseInt(items[4]); + + if ((items[0].equals(param_pop.getName())) && (month>lastMonth-12)){ + capturesWeightReference += Double.parseDouble(items[5]); + } + line = reader.readLine(); + } + + for (Population pop : simulation.getParameter().getPopulations()) { + if (pop.getName().equals(param_pop.getName())) { + for (int i = 0; i < 12; i++) { + + //Get the captures Weight of each month of the last year + MatrixND matlastdate = resultStorage.getMatrix( + new TimeStep(lastStep.getStep() - i), + pop, + ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + capturesWeight += matlastdate.sumAll(); + } + } + } + + log.info("capturesWeight value : " + capturesWeight); + log.info("capturesWeightReference value : " + capturesWeightReference); + + out.write(Double.toString(capturesWeight / capturesWeightReference)); + } + + @Override + public String getDescription() { + return _("Captures in weight for the last year for the popage " + + "population. Captures is the sum of zones, groups, metiers " + + "and strategies"); + } + + @Override + public String getExportFilename() { + return "SensitivityCapturesWeightReferenceY7"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + +} Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightReferenceY7.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java (rev 0) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -0,0 +1,150 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * %% + * 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 sensitivityexports; + +import static org.nuiton.i18n.I18n._; + +import java.io.File; +import java.io.Writer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixND; + +import org.nuiton.util.ReverseFileReader; +import scripts.ResultName; +import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.export.SensitivityExport; +import fr.ifremer.isisfish.types.TimeStep; +import fr.ifremer.isisfish.util.Doc; + +public class SensitivityCatchWeightRelativeReferenceY10 implements + SensitivityExport { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory + .getLog(SensitivityCatchWeightRelativeReferenceY10.class); + + protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP }; + + @Doc("Population") + public Population param_pop; + + @Doc("Path of the CapturesPoids.csv file") + public String param_referenceCatchWeightCSV = ""; + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + ResultStorage resultStorage = simulation.getResultStorage(); + TimeStep lastStep = resultStorage.getLastStep(); + Double capturesWeight = 0.0; + Double capturesWeightFirst = 0.0; + Double capturesWeightReference = 0.0; + Double capturesWeightFirstReference = 0.0; + + File referenceFile = new File(param_referenceCatchWeightCSV); + + //instantiate a reader that starts reading from the file end. + ReverseFileReader reader = new ReverseFileReader(referenceFile); + + //read the last line of the file (should be empty) + String line = reader.readLine(); + + //read the next line (the last written line) + line = reader.readLine(); + + + Integer lastMonth = 0; + + while (line!=null ){ + + String[] items = line.split(";"); + + //If we did not initiate the last date (we are on the last line of + // the file), we do it now with the value of the date. + if (lastMonth == 0) { + lastMonth = Integer.parseInt(items[4]); + } + + Integer month = Integer.parseInt(items[4]); + + if ((items[0].equals(param_pop.getName())) && (month>lastMonth-12)){ + capturesWeightReference += Double.parseDouble(items[5]); + } + + if ((items[0].equals(param_pop.getName())) && (month<12)){ + capturesWeightFirstReference += Double.parseDouble(items[5]); + } + line = reader.readLine(); + } + + for (Population pop : simulation.getParameter().getPopulations()) { + if (pop.getName().equals(param_pop.getName())) { + for (int i = 0; i < 12; i++) { + + //Get the captures Weight of each month of the last year + MatrixND matlastdate = resultStorage + .getMatrix( + new TimeStep(lastStep.getStep() - i), + pop, + ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + capturesWeight += matlastdate.sumAll(); + + //Get the captures Weight of each month of the first year + MatrixND matfirstdate = resultStorage + .getMatrix( + new TimeStep(i), + pop, + ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + capturesWeightFirst += matfirstdate.sumAll(); + + } + } + } + out.write(Double.toString((capturesWeight / capturesWeightFirst) + / (capturesWeightReference / capturesWeightFirstReference))); + } + + @Override + public String getDescription() { + return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies"); + } + + @Override + public String getExportFilename() { + return "SensitivityCapturesWeightRelativeReferenceY10"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + +} Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeReferenceY10.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java (rev 0) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -0,0 +1,106 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * %% + * 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 sensitivityexports; + +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.MatrixND; + +import scripts.ResultName; +import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.export.SensitivityExport; +import fr.ifremer.isisfish.types.TimeStep; +import fr.ifremer.isisfish.util.Doc; + +public class SensitivityCatchWeightRelativeY4 implements SensitivityExport { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory + .getLog(SensitivityCatchWeightRelativeY4.class); + + protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP }; + + @Doc("Population") + public Population param_pop; + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + ResultStorage resultStorage = simulation.getResultStorage(); + TimeStep lastStep = resultStorage.getLastStep(); + Double capturesWeight = 0.0; + Double capturesWeightfirst = 0.0; + + for (Population pop : simulation.getParameter().getPopulations()) { + if (pop.getName().equals(param_pop.getName())) { + for (int i = 0; i < 12; i++) { + + //Get the captures Weight of each month of the last year + MatrixND matlastdate = resultStorage + .getMatrix( + new TimeStep(lastStep.getStep() - i), + pop, + ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + capturesWeight += matlastdate.sumAll(); + + //Get the captures Weight of each month of the first year + MatrixND matfirstdate = resultStorage + .getMatrix( + new TimeStep(i), + pop, + ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + capturesWeightfirst += matfirstdate.sumAll(); + } + + } + } + + out.write(Double.toString(capturesWeight / capturesWeightfirst)); + } + + @Override + public String getDescription() { + return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies"); + } + + @Override + public String getExportFilename() { + return "SensitivityCapturesWeightRelativeY4"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + +} Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightRelativeY4.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java (rev 0) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -0,0 +1,97 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * %% + * 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 sensitivityexports; + +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.MatrixND; + +import scripts.ResultName; +import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.export.SensitivityExport; +import fr.ifremer.isisfish.types.TimeStep; +import fr.ifremer.isisfish.util.Doc; + +public class SensitivityCatchWeightY1 implements SensitivityExport { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory + .getLog(SensitivityCatchWeightY1.class); + + protected String[] necessaryResult = { ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP }; + + @Doc("Population") + public Population param_pop; + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + ResultStorage resultStorage = simulation.getResultStorage(); + TimeStep lastStep = resultStorage.getLastStep(); + Double capturesWeight = 0.0; + + for (Population pop : simulation.getParameter().getPopulations()) { + if (pop.getName().equals(param_pop.getName())) { + for (int i = 0; i < 12; i++) { + + //Get the captures Weight of each month of the last year + MatrixND matlastdate = resultStorage + .getMatrix( + new TimeStep(lastStep.getStep() - i), + pop, + ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + capturesWeight += matlastdate.sumAll(); + } + + } + } + + out.write(Double.toString(capturesWeight)); + } + + @Override + public String getDescription() { + return _("Captures in weight for the last year for the popage population. Captures is the sum of zones, groups, metiers and strategies"); + } + + @Override + public String getExportFilename() { + return "SensitivityCapturesWeightY1"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + +} Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityCatchWeightY1.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Deleted: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassReferenceY8.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassReferenceY8.java 2011-07-08 14:22:36 UTC (rev 3441) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassReferenceY8.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -1,131 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Ifremer, Code Lutin - * %% - * 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 sensitivityexports; - -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 org.nuiton.topia.TopiaContext; - -import scripts.ResultName; -import fr.ifremer.isisfish.datastore.ResultStorage; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.entities.PopulationGroup; -import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.util.Doc; - -public class SensitivityGenitorBiomassReferenceY8 implements SensitivityExport { - - /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory - .getLog(SensitivityGenitorBiomassReferenceY8.class); - - protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS }; - - @Doc("Population") - public Population param_pop; - - @Doc("Name of the reference simulation") - public String param_referenceSimulation = ""; - - @Override - public void export(SimulationStorage simulation, Writer out) - throws Exception { - SimulationStorage referenceSimulation = SimulationStorage - .getSimulation(param_referenceSimulation); - ResultStorage referenceResultStorage = referenceSimulation - .getResultStorage(); - ResultStorage resultStorage = simulation.getResultStorage(); - Date lastDate = resultStorage.getLastDate(); - Double biomass = 0.0; - Double referenceBiomass = 0.0; - - for (Population pop : simulation.getParameter().getPopulations()) { - if (pop.getName().equals(param_pop.getName())) { - - //Get the biomass of the last time step - MatrixND matlastdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); - for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - PopulationGroup group = (PopulationGroup) sems[1]; - Date date = (Date) sems[0]; - if (date.equals(lastDate)) { - biomass += i.getValue() * group.getReproductionRate(); - } - } - - //Get the reference biomass of the last time step - TopiaContext tx = referenceSimulation.getStorage() - .beginTransaction(); - MatrixND matlastdatereference = referenceResultStorage - .getMatrix(ResultName.MATRIX_BIOMASS + " " + pop, tx); - for (MatrixIterator i = matlastdatereference.iterator(); i - .hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - PopulationGroup group = (PopulationGroup) sems[1]; - Date date = (Date) sems[0]; - if (date.equals(lastDate)) { - referenceBiomass += i.getValue() - * group.getReproductionRate(); - } - } - tx.commitTransaction(); - tx.closeContext(); - } - } - out.write(Double.toString(biomass / referenceBiomass)); - } - - @Override - public String getDescription() { - return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones"); - } - - @Override - public String getExportFilename() { - return "SensitivityGenitorBiomassReferenceY8"; - } - - @Override - public String getExtensionFilename() { - return ".csv"; - } - - @Override - public String[] getNecessaryResult() { - return this.necessaryResult; - } - -} Deleted: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeReferenceY11.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeReferenceY11.java 2011-07-08 14:22:36 UTC (rev 3441) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeReferenceY11.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -1,166 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Ifremer, Code Lutin - * %% - * 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 sensitivityexports; - -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 org.nuiton.topia.TopiaContext; - -import scripts.ResultName; -import fr.ifremer.isisfish.datastore.ResultStorage; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.entities.PopulationGroup; -import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.util.Doc; - -public class SensitivityGenitorBiomassRelativeReferenceY11 implements - SensitivityExport { - - /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory - .getLog(SensitivityGenitorBiomassRelativeReferenceY11.class); - - protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS }; - - @Doc("Population") - public Population param_pop; - - @Doc("Name of the reference simulation") - public String param_referenceSimulation = ""; - - @Override - public void export(SimulationStorage simulation, Writer out) - throws Exception { - SimulationStorage referenceSimulation = SimulationStorage - .getSimulation(param_referenceSimulation); - ResultStorage resultStorage = simulation.getResultStorage(); - ResultStorage referenceResultStorage = referenceSimulation - .getResultStorage(); - Date lastDate = resultStorage.getLastDate(); - Date firstDate = new Date(11); - double biomass = 0.0; - double firstbiomass = 0.0; - double biomassReference = 0.0; - double firstbiomassReference = 0.0; - - for (Population pop : simulation.getParameter().getPopulations()) { - if (pop.getName().equals(param_pop.getName())) { - - //Get the biomass of the first time step - MatrixND matfirstdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); - for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - PopulationGroup group = (PopulationGroup) sems[1]; - Date date = (Date) sems[0]; - if (date.equals(firstDate)) { - firstbiomass += i.getValue() - * group.getReproductionRate(); - } - } - - //Get the biomass of the last time step - MatrixND matlastdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); - for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - PopulationGroup group = (PopulationGroup) sems[1]; - Date date = (Date) sems[0]; - if (date.equals(lastDate)) { - biomass = biomass + i.getValue() - * group.getReproductionRate(); - } - } - - //Get the reference biomass of the first time step - TopiaContext tx = referenceSimulation.getStorage() - .beginTransaction(); - MatrixND matfirstdatereference = referenceResultStorage - .getMatrix(ResultName.MATRIX_BIOMASS + " " + pop, tx); - for (MatrixIterator i = matfirstdatereference.iterator(); i - .hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - PopulationGroup group = (PopulationGroup) sems[1]; - Date date = (Date) sems[0]; - if (date.equals(firstDate)) { - firstbiomassReference += i.getValue() - * group.getReproductionRate(); - } - } - - //Get the reference biomass of the last time step - MatrixND matlastdatereference = referenceResultStorage - .getMatrix(ResultName.MATRIX_BIOMASS + " " + pop, tx); - for (MatrixIterator i = matlastdatereference.iterator(); i - .hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - PopulationGroup group = (PopulationGroup) sems[1]; - Date date = (Date) sems[0]; - if (date.equals(lastDate)) { - biomassReference += i.getValue() - * group.getReproductionRate(); - } - } - tx.commitTransaction(); - tx.closeContext(); - } - } - out.write(Double.toString((biomass / firstbiomass) - / (biomassReference / firstbiomassReference))); - } - - @Override - public String getDescription() { - return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones"); - } - - @Override - public String getExportFilename() { - return "SensitivityGenitorBiomassRelativeReferenceY11"; - } - - @Override - public String getExtensionFilename() { - return ".csv"; - } - - @Override - public String[] getNecessaryResult() { - return this.necessaryResult; - } - -} \ No newline at end of file Deleted: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeY5.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeY5.java 2011-07-08 14:22:36 UTC (rev 3441) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassRelativeY5.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -1,118 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Ifremer, Code Lutin - * %% - * 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 sensitivityexports; - -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.ResultStorage; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.entities.PopulationGroup; -import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.util.Doc; - -public class SensitivityGenitorBiomassRelativeY5 implements SensitivityExport { - - /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory - .getLog(SensitivityGenitorBiomassRelativeY5.class); - - protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS }; - - @Doc("Population") - public Population param_pop; - - @Override - public void export(SimulationStorage simulation, Writer out) - throws Exception { - Date lastDate = simulation.getResultStorage().getLastDate(); - Date firstDate = new Date(11); - double biomass = 0.0; - double firstbiomass = 0.0; - - for (Population pop : simulation.getParameter().getPopulations()) { - if (pop.getName().equals(param_pop.getName())) { - ResultStorage resultStorage = simulation.getResultStorage(); - - //Get the biomass of the first time step - MatrixND matfirstdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); - for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - PopulationGroup group = (PopulationGroup) sems[1]; - Date date = (Date) sems[0]; - if (date.equals(firstDate)) { - firstbiomass += i.getValue() - * group.getReproductionRate(); - } - } - - //Get the biomass of the last time step - MatrixND matlastdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); - for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - PopulationGroup group = (PopulationGroup) sems[1]; - Date date = (Date) sems[0]; - if (date.equals(lastDate)) - biomass += i.getValue() * group.getReproductionRate(); - } - } - } - out.write(Double.toString(biomass / firstbiomass)); - } - - @Override - public String getDescription() { - return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones"); - } - - @Override - public String getExportFilename() { - return "SensitivityGenitorBiomassRelativeY5"; - } - - @Override - public String getExtensionFilename() { - return ".csv"; - } - - @Override - public String[] getNecessaryResult() { - return this.necessaryResult; - } - -} \ No newline at end of file Deleted: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassY2.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassY2.java 2011-07-08 14:22:36 UTC (rev 3441) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivityGenitorBiomassY2.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -1,103 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Ifremer, Code Lutin - * %% - * 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 sensitivityexports; - -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.ResultStorage; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.entities.Population; -import fr.ifremer.isisfish.entities.PopulationGroup; -import fr.ifremer.isisfish.export.SensitivityExport; -import fr.ifremer.isisfish.types.Date; -import fr.ifremer.isisfish.util.Doc; - -public class SensitivityGenitorBiomassY2 implements SensitivityExport { - - /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory - .getLog(SensitivityGenitorBiomassY2.class); - - protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS }; - - @Doc("Population") - public Population param_pop; - - @Override - public void export(SimulationStorage simulation, Writer out) - throws Exception { - Date lastDate = simulation.getResultStorage().getLastDate(); - double biomass = 0.0; - - for (Population pop : simulation.getParameter().getPopulations()) { - if (pop.getName().equals(param_pop.getName())) { - ResultStorage resultStorage = simulation.getResultStorage(); - - //Get the biomass of the last time step - MatrixND matlastdate = resultStorage.getMatrix(pop, - ResultName.MATRIX_BIOMASS); - for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - Date date = (Date) sems[0]; - PopulationGroup group = (PopulationGroup) sems[1]; - if (date.equals(lastDate)) { - biomass += i.getValue() * group.getReproductionRate(); - } - } - } - } - out.write(Double.toString(biomass)); - } - - @Override - public String getDescription() { - return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones"); - } - - @Override - public String getExportFilename() { - return "SensitivityGenitorBiomassY2"; - } - - @Override - public String getExtensionFilename() { - return ".csv"; - } - - @Override - public String[] getNecessaryResult() { - return this.necessaryResult; - } - -} Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java (rev 0) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -0,0 +1,154 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * %% + * 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 sensitivityexports; + +import static org.nuiton.i18n.I18n._; + +import java.io.File; +import java.io.Writer; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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 org.nuiton.topia.TopiaContext; +import org.nuiton.util.ReverseFileReader; +import scripts.ResultName; +import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.export.SensitivityExport; +import fr.ifremer.isisfish.types.TimeStep; +import fr.ifremer.isisfish.util.Doc; + +public class SensitivitySpawningBiomassReferenceY8 implements SensitivityExport { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory + .getLog(SensitivitySpawningBiomassReferenceY8.class); + + protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS }; + + @Doc("Population") + public Population param_pop; + + @Doc("URL of the Biomasses.csv reference export file") + public String param_referenceBiomassCSV =""; + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + ResultStorage resultStorage = simulation.getResultStorage(); + TimeStep lastStep = resultStorage.getLastStep(); + Double biomass = 0.0; + Double referenceBiomass = 0.0; + + File referenceFile = new File(param_referenceBiomassCSV); + + TopiaContext tx = simulation.getStorage().beginTransaction(); + + Population tempPop = (Population)tx.findByTopiaId(param_pop.getTopiaId()); + + List<PopulationGroup> groups = tempPop.getPopulationGroup(); + + Map<Integer, Double> map =new HashMap<Integer,Double>(); + + for (PopulationGroup group:groups) { + map.put(group.getId(),group.getReproductionRate()); + } + + tx.closeContext(); + + //instantiate a reader that starts reading from the file end. + ReverseFileReader reader = new ReverseFileReader(referenceFile); + + //read the last line of the file (should be empty) + String line = reader.readLine(); + + //read the next line (the last written line) + line = reader.readLine(); + + + String lastMonth=""; + + while (line!=null ){ + + String[] items = line.split(";"); + + //If we did not initiate the last date (we are on the last line of + // the file), we do it now with the value of the date. + if ("".equals(lastMonth)) { + lastMonth = items[3]; + } + + if ((items[0].equals(param_pop.getName())) && (items[3].equals(lastMonth))){ + referenceBiomass += Double.parseDouble(items[4]) * map.get(Integer.parseInt(items[1])); + } + line = reader.readLine(); + } + + for (Population pop : simulation.getParameter().getPopulations()) { + if (pop.getName().equals(param_pop.getName())) { + + //Get the biomass of the last time step + MatrixND matlastdate = resultStorage.getMatrix(pop, + ResultName.MATRIX_BIOMASS); + for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { + i.next(); + Object[] sems = i.getSemanticsCoordinates(); + PopulationGroup group = (PopulationGroup) sems[1]; + TimeStep step = (TimeStep) sems[0]; + if (step.equals(lastStep)) { + biomass += i.getValue() * group.getReproductionRate(); + } + } + } + } + out.write(Double.toString(biomass / referenceBiomass)); + } + + @Override + public String getDescription() { + return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones"); + } + + @Override + public String getExportFilename() { + return "SensitivitySpawningBiomassReferenceY8"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + +} Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassReferenceY8.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java (rev 0) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -0,0 +1,180 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * %% + * 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 sensitivityexports; + +import static org.nuiton.i18n.I18n._; + +import java.io.File; +import java.io.Writer; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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 org.nuiton.topia.TopiaContext; + +import org.nuiton.util.ReverseFileReader; +import scripts.ResultName; +import fr.ifremer.isisfish.datastore.ResultStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.export.SensitivityExport; +import fr.ifremer.isisfish.types.TimeStep; +import fr.ifremer.isisfish.util.Doc; + +public class SensitivitySpawningBiomassRelativeReferenceY11 implements + SensitivityExport { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory + .getLog(SensitivitySpawningBiomassRelativeReferenceY11.class); + + protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS }; + + @Doc("Population") + public Population param_pop; + + @Doc("URL of the Biomasses.csv reference export file") + public String param_referenceBiomassCSV =""; + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + + ResultStorage resultStorage = simulation.getResultStorage(); + TimeStep lastStep = resultStorage.getLastStep(); + TimeStep firstStep = new TimeStep(11); + double biomass = 0.0; + double firstbiomass = 0.0; + double biomassReference = 0.0; + double firstBiomassReference = 0.0; + + File referenceFile = new File(param_referenceBiomassCSV); + + TopiaContext tx = simulation.getStorage().beginTransaction(); + + Population tempPop = (Population)tx.findByTopiaId(param_pop.getTopiaId()); + + List<PopulationGroup> groups = tempPop.getPopulationGroup(); + + Map<Integer, Double> map =new HashMap<Integer,Double>(); + + for (PopulationGroup group:groups) { + map.put(group.getId(),group.getReproductionRate()); + } + + tx.closeContext(); + + //instantiate a reader that starts reading from the file end. + ReverseFileReader reader = new ReverseFileReader(referenceFile); + + //read the last line of the file (should be empty) + String line = reader.readLine(); + + //read the next line (the last written line) + line = reader.readLine(); + + + String lastMonth=""; + + while (line != null ) { + + String[] items = line.split(";"); + + //If we did not initiate the last date (we are on the last line of + // the file), we do it now with the value of the date. + if ("".equals(lastMonth)) { + lastMonth = items[3]; + } + + if ((items[0].equals(param_pop.getName())) && (items[3].equals(lastMonth))){ + biomassReference += Double.parseDouble(items[4]) * map.get(Integer.parseInt(items[1])); + } + + if ((items[0].equals(param_pop.getName())) && (items[3].equals("11"))){ + firstBiomassReference += Double.parseDouble(items[4]) * map.get(Integer.parseInt(items[1])); + } + + line = reader.readLine(); + } + + for (Population pop : simulation.getParameter().getPopulations()) { + if (pop.getName().equals(param_pop.getName())) { + + //Get the biomass of the first time step + MatrixND matfirstdate = resultStorage.getMatrix(pop, + ResultName.MATRIX_BIOMASS); + for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) { + i.next(); + Object[] sems = i.getSemanticsCoordinates(); + PopulationGroup group = (PopulationGroup) sems[1]; + TimeStep step = (TimeStep) sems[0]; + if (step.equals(firstStep)) { + firstbiomass += i.getValue() + * group.getReproductionRate(); + } + } + + //Get the biomass of the last time step + MatrixND matlastdate = resultStorage.getMatrix(pop, + ResultName.MATRIX_BIOMASS); + for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { + i.next(); + Object[] sems = i.getSemanticsCoordinates(); + PopulationGroup group = (PopulationGroup) sems[1]; + TimeStep step = (TimeStep) sems[0]; + if (step.equals(lastStep)) { + biomass = biomass + i.getValue() + * group.getReproductionRate(); + } + } + } + } + out.write(Double.toString((biomass / firstbiomass) + / (biomassReference / firstBiomassReference))); + } + + @Override + public String getDescription() { + return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones"); + } + + @Override + public String getExportFilename() { + return "SensitivitySpawningBiomassRelativeReferenceY11"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + +} Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeReferenceY11.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java (rev 0) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -0,0 +1,115 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * %% + * 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 sensitivityexports; + +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.ResultStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.export.SensitivityExport; +import fr.ifremer.isisfish.types.TimeStep; +import fr.ifremer.isisfish.util.Doc; + +public class SensitivitySpawningBiomassRelativeY5 implements SensitivityExport { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory + .getLog(SensitivitySpawningBiomassRelativeY5.class); + + protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS }; + + @Doc("Population") + public Population param_pop; + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + TimeStep lastStep = simulation.getResultStorage().getLastStep(); + TimeStep firstStep = new TimeStep(11); + double biomass = 0.0; + double firstbiomass = 0.0; + + for (Population pop : simulation.getParameter().getPopulations()) { + if (pop.getName().equals(param_pop.getName())) { + ResultStorage resultStorage = simulation.getResultStorage(); + + //Get the biomass of the first time step + MatrixND matfirstdate = resultStorage.getMatrix(pop, + ResultName.MATRIX_BIOMASS); + for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) { + i.next(); + Object[] sems = i.getSemanticsCoordinates(); + PopulationGroup group = (PopulationGroup) sems[1]; + TimeStep step = (TimeStep) sems[0]; + if (step.equals(firstStep)) { + firstbiomass += i.getValue() + * group.getReproductionRate(); + } + } + + //Get the biomass of the last time step + MatrixND matlastdate = resultStorage.getMatrix(pop, + ResultName.MATRIX_BIOMASS); + for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { + i.next(); + Object[] sems = i.getSemanticsCoordinates(); + PopulationGroup group = (PopulationGroup) sems[1]; + TimeStep step = (TimeStep) sems[0]; + if (step.equals(lastStep)) + biomass += i.getValue() * group.getReproductionRate(); + } + } + } + out.write(Double.toString(biomass / firstbiomass)); + } + + @Override + public String getDescription() { + return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones"); + } + + @Override + public String getExportFilename() { + return "SensitivityGenitorBiomassRelativeY5"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + +} Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassRelativeY5.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java =================================================================== --- isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java (rev 0) +++ isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java 2011-07-08 14:23:25 UTC (rev 3442) @@ -0,0 +1,100 @@ +/* + * #%L + * IsisFish data + * %% + * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Jean Couteau + * %% + * 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 sensitivityexports; + +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.ResultStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.export.SensitivityExport; +import fr.ifremer.isisfish.types.TimeStep; +import fr.ifremer.isisfish.util.Doc; + +public class SensitivitySpawningBiomassY2 implements SensitivityExport { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory + .getLog(SensitivitySpawningBiomassY2.class); + + protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS }; + + @Doc("Population") + public Population param_pop; + + @Override + public void export(SimulationStorage simulation, Writer out) + throws Exception { + TimeStep lastStep = simulation.getResultStorage().getLastStep(); + double biomass = 0.0; + + for (Population pop : simulation.getParameter().getPopulations()) { + if (pop.getName().equals(param_pop.getName())) { + ResultStorage resultStorage = simulation.getResultStorage(); + + //Get the biomass of the last time step + MatrixND matlastdate = resultStorage.getMatrix(pop, + ResultName.MATRIX_BIOMASS); + for (MatrixIterator i = matlastdate.iterator(); i.hasNext();) { + i.next(); + Object[] sems = i.getSemanticsCoordinates(); + TimeStep step = (TimeStep) sems[0]; + PopulationGroup group = (PopulationGroup) sems[1]; + if (step.equals(lastStep)) { + biomass += i.getValue() * group.getReproductionRate(); + } + } + } + } + out.write(Double.toString(biomass)); + } + + @Override + public String getDescription() { + return _("Biomass of the genitors for the last time step. Biomass is the sum on the groups and zones"); + } + + @Override + public String getExportFilename() { + return "SensitivityGenitorBiomassY2"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + +} Property changes on: isis-fish/trunk/src/test/resources/test-database/sensitivityexports/SensitivitySpawningBiomassY2.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL