Author: jcouteau Date: 2009-04-16 13:25:07 +0000 (Thu, 16 Apr 2009) New Revision: 108 Added: trunk/exports/SensitivityBiomassRelativeReferenceY12.java trunk/exports/SensitivityCapturesWeightReferenceY7.java trunk/exports/SensitivityCapturesWeightRelativeReferenceY10.java trunk/exports/SensitivityGenitorBiomassReferenceY8.java trunk/exports/SensitivityGenitorBiomassRelativeReferenceY11.java Modified: trunk/exports/SensitivityBiomassReferenceY9.java trunk/exports/SensitivityBiomassRelativeY6.java trunk/exports/SensitivityGenitorBiomassRelativeY5.java Log: Implementation of reference exports. Modified: trunk/exports/SensitivityBiomassReferenceY9.java =================================================================== --- trunk/exports/SensitivityBiomassReferenceY9.java 2009-04-16 12:00:03 UTC (rev 107) +++ trunk/exports/SensitivityBiomassReferenceY9.java 2009-04-16 13:25:07 UTC (rev 108) @@ -2,12 +2,10 @@ import static org.codelutin.i18n.I18n._; -import java.io.File; import java.io.Writer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.codelutin.math.matrix.MatrixIterator; import org.codelutin.math.matrix.MatrixND; import scripts.ResultName; @@ -22,39 +20,47 @@ public class SensitivityBiomassReferenceY9 implements SensitivityExport { /** to use log facility, just put in your code: log.info("..."); */ - static private Log log = LogFactory.getLog(SensitivityBiomassReferenceY9.class); + static private Log log = LogFactory + .getLog(SensitivityBiomassReferenceY9.class); protected String[] necessaryResult = { ResultName.MATRIX_BIOMASS }; @Doc("Population") public Population param_pop; - - @Doc("Path to the reference simulation exports") - public String param_referenceExports; + @Doc("Name of the reference simulation") + public String param_referenceSimulation = ""; + @Override public void export(SimulationStorage simulation, Writer out) throws Exception { - File referenceExports=new File (param_referenceExports); - Date lastDate = simulation.getResultStorage().getLastDate(); - double biomass = 0.0; + 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())) { - MatrixND mat = simulation.getResultStorage().getMatrix(pop, + + //Get the biomass of the last time step + MatrixND matlastdate = resultStorage.getMatrix(lastDate, pop, ResultName.MATRIX_BIOMASS); - for (MatrixIterator i = mat.iterator(); i.hasNext();) { - i.next(); - Object[] sems = i.getSemanticsCoordinates(); - Date date = (Date) sems[0]; + biomass = matlastdate.sumAll(); - if (date.afterOrEquals(lastDate)) { - biomass = biomass + i.getValue(); - } - } + //Get the reference biomass of the last time step + MatrixND matreferencelastdate = referenceResultStorage + .getMatrix(lastDate, pop, ResultName.MATRIX_BIOMASS); + referenceBiomass = matreferencelastdate.sumAll(); + } } - out.write(Double.toString(biomass)); + out.write(Double.toString(biomass / referenceBiomass)); + } @Override @@ -64,7 +70,7 @@ @Override public String getExportFilename() { - return "SensitivityBiomass"; + return "SensitivityBiomassReferenceY9"; } @Override Added: trunk/exports/SensitivityBiomassRelativeReferenceY12.java =================================================================== --- trunk/exports/SensitivityBiomassRelativeReferenceY12.java (rev 0) +++ trunk/exports/SensitivityBiomassRelativeReferenceY12.java 2009-04-16 13:25:07 UTC (rev 108) @@ -0,0 +1,101 @@ +package exports; + +import static org.codelutin.i18n.I18n._; + +import java.io.Writer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.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; + +@Doc("Doc for SensitivityBiomass") +public class SensitivityBiomassRelativeReferenceY12 implements + SensitivityExport { + + /** to use log facility, just put in your code: log.info("..."); */ + static private Log log = LogFactory + .getLog(SensitivityBiomassRelativeReferenceY12.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 on december of the first year + MatrixND matfirstdate = resultStorage.getMatrix(firstDate, pop, + ResultName.MATRIX_BIOMASS); + firstbiomass = matfirstdate.sumAll(); + + //Get the biomass of the last time step + MatrixND matlastdate = resultStorage.getMatrix(lastDate, pop, + ResultName.MATRIX_BIOMASS); + biomass = matlastdate.sumAll(); + + //Get the biomass on december of the first year + MatrixND matfirstdatereference = referenceResultStorage + .getMatrix(firstDate, pop, ResultName.MATRIX_BIOMASS); + firstbiomassReference = matfirstdatereference.sumAll(); + + //Get the biomass of the last time step + MatrixND matlastdatereference = referenceResultStorage + .getMatrix(lastDate, pop, ResultName.MATRIX_BIOMASS); + biomassReference = matlastdatereference.sumAll(); + + } + } + + out.write(Double.toString((biomass / firstbiomass) + / (biomassReference / firstbiomassReference))); + + } + + @Override + public String getDescription() { + return _("Biomass for the last time step. Biomass is the sum on the groups and zones"); + } + + @Override + public String getExportFilename() { + return "SensitivityBiomassRelativeReferenceY12"; + } + + @Override + public String getExtensionFilename() { + return ".csv"; + } + + @Override + public String[] getNecessaryResult() { + return this.necessaryResult; + } + +} \ No newline at end of file Modified: trunk/exports/SensitivityBiomassRelativeY6.java =================================================================== --- trunk/exports/SensitivityBiomassRelativeY6.java 2009-04-16 12:00:03 UTC (rev 107) +++ trunk/exports/SensitivityBiomassRelativeY6.java 2009-04-16 13:25:07 UTC (rev 108) @@ -31,14 +31,14 @@ @Override public void export(SimulationStorage simulation, Writer out) throws Exception { - Date lastDate = simulation.getResultStorage().getLastDate(); + ResultStorage resultStorage = simulation.getResultStorage(); + Date lastDate = resultStorage.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(); + if (pop.getName().equals(param_pop.getName())) { //Get the biomass on december of the first year MatrixND matfirstdate = resultStorage.getMatrix(firstDate, pop, Added: trunk/exports/SensitivityCapturesWeightReferenceY7.java =================================================================== --- trunk/exports/SensitivityCapturesWeightReferenceY7.java (rev 0) +++ trunk/exports/SensitivityCapturesWeightReferenceY7.java 2009-04-16 13:25:07 UTC (rev 108) @@ -0,0 +1,94 @@ +package exports; + +import static org.codelutin.i18n.I18n._; + +import java.io.Writer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.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; + +@Doc("Doc for SensitivityCapturesPoids") +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 + MatrixND matlastdatereference = referenceResultStorage + .getMatrix( + new Date(lastDate.getDate() - i), + pop, + ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + capturesWeightReference += matlastdatereference.sumAll(); + + } + + } + } + + 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 Added: trunk/exports/SensitivityCapturesWeightRelativeReferenceY10.java =================================================================== --- trunk/exports/SensitivityCapturesWeightRelativeReferenceY10.java (rev 0) +++ trunk/exports/SensitivityCapturesWeightRelativeReferenceY10.java 2009-04-16 13:25:07 UTC (rev 108) @@ -0,0 +1,112 @@ +package exports; + +import static org.codelutin.i18n.I18n._; + +import java.io.Writer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.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; + +@Doc("Doc for SensitivityCapturesPoids") +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 + MatrixND matlastdatereference = referenceResultStorage + .getMatrix( + new Date(lastDate.getDate() - i), + pop, + ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + capturesWeightreference += matlastdatereference.sumAll(); + + //Get the reference captures Weight of each month of the first year + MatrixND matfirstdatereference = referenceResultStorage + .getMatrix( + new Date(i), + pop, + ResultName.MATRIX_CATCH_WEIGHT_PER_STRATEGY_MET_PER_ZONE_POP); + capturesWeightfirstreference += matfirstdatereference + .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; + } + +} Added: trunk/exports/SensitivityGenitorBiomassReferenceY8.java =================================================================== --- trunk/exports/SensitivityGenitorBiomassReferenceY8.java (rev 0) +++ trunk/exports/SensitivityGenitorBiomassReferenceY8.java 2009-04-16 13:25:07 UTC (rev 108) @@ -0,0 +1,103 @@ +package exports; + +import static org.codelutin.i18n.I18n._; + +import java.io.Writer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.math.matrix.MatrixIterator; +import org.codelutin.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; + +@Doc("Doc for SensitivityBiomass") +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 + MatrixND matlastdatereference = referenceResultStorage + .getMatrix(pop, ResultName.MATRIX_BIOMASS); + 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(); + } + } + } + } + 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; + } + +} Added: trunk/exports/SensitivityGenitorBiomassRelativeReferenceY11.java =================================================================== --- trunk/exports/SensitivityGenitorBiomassRelativeReferenceY11.java (rev 0) +++ trunk/exports/SensitivityGenitorBiomassRelativeReferenceY11.java 2009-04-16 13:25:07 UTC (rev 108) @@ -0,0 +1,138 @@ +package exports; + +import static org.codelutin.i18n.I18n._; + +import java.io.Writer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.math.matrix.MatrixIterator; +import org.codelutin.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; + +@Doc("Doc for SensitivityBiomass") +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 + MatrixND matfirstdatereference = referenceResultStorage + .getMatrix(pop, ResultName.MATRIX_BIOMASS); + 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(pop, ResultName.MATRIX_BIOMASS); + 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(); + } + } + } + } + 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 Modified: trunk/exports/SensitivityGenitorBiomassRelativeY5.java =================================================================== --- trunk/exports/SensitivityGenitorBiomassRelativeY5.java 2009-04-16 12:00:03 UTC (rev 107) +++ trunk/exports/SensitivityGenitorBiomassRelativeY5.java 2009-04-16 13:25:07 UTC (rev 108) @@ -42,7 +42,7 @@ if (pop.getName().equals(param_pop.getName())) { ResultStorage resultStorage = simulation.getResultStorage(); - //Get the biomass of the last time step + //Get the biomass of the first time step MatrixND matfirstdate = resultStorage.getMatrix(pop, ResultName.MATRIX_BIOMASS); for (MatrixIterator i = matfirstdate.iterator(); i.hasNext();) {