# HG changeset patch # User Raimund Renkert # Date 1338994705 0 # Node ID 22da13d1b180e6891729cad1670efdc484ea9893 # Parent 2ff802d66b71de5dc24938a3f2b46321e54a4fd2 Added facet for derivate curve and fixed facet names. flys-artifacts/trunk@4612 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Jun 06 12:20:24 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Jun 06 14:58:25 2012 +0000 @@ -1,3 +1,26 @@ +2012-06-06 Raimund Renkert + + Added facet for derivate curve and fixed facet names. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java: + New. Facet for derivate curve. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java: + Added name for facet to constructor. + + * src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java: + Add one facet for each output using a different name. + + * src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: + Added facet names. + + * doc/conf/artifacts/fixanalysis.xml: + Changed facet names. + 2012-06-06 Felix Wolfsteller * src/main/java/de/intevation/flys/exports/MiddleBedHeightExporter.java: diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/doc/conf/artifacts/fixanalysis.xml --- a/flys-artifacts/doc/conf/artifacts/fixanalysis.xml Wed Jun 06 12:20:24 2012 +0000 +++ b/flys-artifacts/doc/conf/artifacts/fixanalysis.xml Wed Jun 06 14:58:25 2012 +0000 @@ -131,14 +131,36 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed Jun 06 12:20:24 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed Jun 06 14:58:25 2012 +0000 @@ -158,11 +158,25 @@ String RELATIVE_POINT = "relativepoint"; - String FIX_ANALYSIS_EVENTS = "fix_analysis_events"; - String FIX_REFERENCE_EVENTS = "fix_reference_events"; - String FIX_SECTOR_AVERAGE = "fix_sector_average"; + String FIX_ANALYSIS_EVENTS_DWT = "fix_analysis_events_dwt"; + String FIX_ANALYSIS_EVENTS_LS = "fix_analysis_events_ls"; + String FIX_ANALYSIS_EVENTS_WQ = "fix_analysis_events_wq"; + + String FIX_REFERENCE_EVENTS_DWT = "fix_reference_events_dwt"; + String FIX_REFERENCE_EVENTS_LS = "fix_reference_events_ls"; + String FIX_REFERENCE_EVENTS_WQ = "fix_reference_events_wq"; + + String FIX_SECTOR_AVERAGE_DWT = "fix_sector_average_dwt"; + String FIX_SECTOR_AVERAGE_LS = "fix_sector_average_ls"; + String FIX_SECTOR_AVERAGE_WQ = "fix_sector_average_wq"; + String FIX_WQ_CURVE = "fix_wq_curve"; String FIX_OUTLIER = "fix_outlier"; - String FIX_ANALYSIS_PERIODS = "fix_analysis_periods"; + + String FIX_ANALYSIS_PERIODS_DWT = "fix_analysis_periods_dwt"; + String FIX_ANALYSIS_PERIODS_LS = "fix_analysis_periods_ls"; + String FIX_ANALYSIS_PERIODS_WQ = "fix_analysis_periods_wq"; + + String FIX_DERIVATE = "fix_derivate"; } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java Wed Jun 06 12:20:24 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java Wed Jun 06 14:58:25 2012 +0000 @@ -37,9 +37,9 @@ /** * @param name */ - public FixAnalysisEventsFacet(int index, String description) { + public FixAnalysisEventsFacet(int index, String name, String description) { super(index, - FIX_ANALYSIS_EVENTS, + name, description, ComputeType.ADVANCE, null, diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java Wed Jun 06 12:20:24 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java Wed Jun 06 14:58:25 2012 +0000 @@ -37,9 +37,9 @@ /** * @param name */ - public FixAnalysisPeriodsFacet(int index, String description) { + public FixAnalysisPeriodsFacet(int index, String name, String description) { super(index, - FIX_ANALYSIS_PERIODS, + name, description, ComputeType.ADVANCE, null, diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java Wed Jun 06 12:20:24 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java Wed Jun 06 14:58:25 2012 +0000 @@ -34,10 +34,10 @@ } - public FixAvSectorFacet(int ndx, String description) { + public FixAvSectorFacet(int ndx, String name, String description) { super( ndx, - FIX_SECTOR_AVERAGE, + name, description, ComputeType.ADVANCE, null, diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java Wed Jun 06 14:58:25 2012 +0000 @@ -0,0 +1,147 @@ +package de.intevation.flys.artifacts.model.fixings; + +import org.apache.log4j.Logger; + +import de.intevation.artifacts.Artifact; +import de.intevation.artifacts.CallContext; + +import de.intevation.flys.utils.KMIndex; + +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.FixationArtifactAccess; + +import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.DataFacet; +import de.intevation.flys.artifacts.model.CalculationResult; +import de.intevation.flys.artifacts.model.Parameters; + +import de.intevation.flys.artifacts.math.fitting.FunctionFactory; +import de.intevation.flys.artifacts.math.fitting.Function; + +import de.intevation.flys.artifacts.states.DefaultState.ComputeType; + + +/** + * Facet to show the W|Q values. + * + * @author Raimund Renkert + */ +public class FixDerivateFacet +extends DataFacet +implements FacetTypes { + + /** House logger. */ + private static Logger logger = Logger.getLogger(FixDerivateFacet.class); + + /** Trivial Constructor. */ + public FixDerivateFacet() { + } + + + /** + * @param name + */ + public FixDerivateFacet(String name, String description) { + super(0, name, description, ComputeType.ADVANCE, null, null); + } + + + /** + * Returns the data this facet requires. + * + * @param artifact the owner artifact. + * @param context the CallContext (ignored). + * + * @return the data. + */ + @Override + public Object getData(Artifact artifact, CallContext context) { + logger.debug("FixDerivateFacet.getData"); + if (artifact instanceof FLYSArtifact) { + FLYSArtifact flys = (FLYSArtifact)artifact; + FixationArtifactAccess access = new FixationArtifactAccess(flys); + + CalculationResult res = + (CalculationResult) flys.compute(context, + ComputeType.ADVANCE, + false); + + FixResult result = (FixResult) res.getData(); + + double km = access.getCurrentKm(); + + String function = access.getFunction(); + Function ff = FunctionFactory.getInstance().getFunction(function); + Function.Derivative fd = ff.getDerivative(); + + Parameters params = result.getParameters(); + int row = params.binarySearch("km", km, Math.pow(10, -4)); + String[] paramNames = ff.getParameterNames(); + int[] paramInd = params.columnIndices(paramNames); + double[] coeffs = new double[paramNames.length]; + params.get(row, paramInd, coeffs); + + de.intevation.flys.artifacts.math.Function mf = + fd.instantiate(coeffs); + + double maxQ = getMaxQ(result, km); + + FixFunction fix = new FixFunction( + "", + ff.getDescription(), + mf, + maxQ); + + return fix; + } + else { + logger.debug("Not an instance of FixationArtifact."); + return null; + } + } + + + protected double getMaxQ(FixResult result, double km) { + double maxQ = 0; + + KMIndex kmQWRef = result.getReferenced(); + + QW[] qwRef = kmQWRef.binarySearch(km).getValue(); + if (qwRef != null) { + for (int i = 0; i < qwRef.length; i++) { + if (qwRef[i].getQ() > maxQ) { + maxQ = qwRef[i].getQ(); + } + } + } + + KMIndex kmQWDAna = result.getAnalysisPeriods(); + AnalysisPeriod[] periods = kmQWDAna.binarySearch(km).getValue(); + + if(periods != null) { + for (int i = 0; i < periods.length; i++) { + QWD[] qwdAna = periods[i].getQWDs(); + if (qwdAna != null) { + for (int j = 0; j < qwdAna.length; j++) { + if (qwdAna[j].getQ() > maxQ) { + maxQ = qwdAna[j].getQ(); + } + } + } + } + } + return maxQ; + } + + /** + * Create a deep copy of this Facet. + * @return a deep copy. + */ + @Override + public FixDerivateFacet deepCopy() { + FixDerivateFacet copy = new FixDerivateFacet(); + copy.set(this); + return copy; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java Wed Jun 06 12:20:24 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java Wed Jun 06 14:58:25 2012 +0000 @@ -37,8 +37,8 @@ /** * @param name */ - public FixOutlierFacet(String description) { - super(0, FIX_OUTLIER, description, ComputeType.ADVANCE, null, null); + public FixOutlierFacet(String name, String description) { + super(0, name, description, ComputeType.ADVANCE, null, null); } diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java Wed Jun 06 12:20:24 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java Wed Jun 06 14:58:25 2012 +0000 @@ -37,9 +37,9 @@ /** * @param name */ - public FixReferenceEventsFacet(int index, String description) { + public FixReferenceEventsFacet(int index, String name, String description) { super(index, - FIX_REFERENCE_EVENTS, + name, description, ComputeType.ADVANCE, null, diff -r 2ff802d66b71 -r 22da13d1b180 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java Wed Jun 06 12:20:24 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java Wed Jun 06 14:58:25 2012 +0000 @@ -16,10 +16,11 @@ import de.intevation.flys.artifacts.model.fixings.FixAvSectorFacet; import de.intevation.flys.artifacts.model.fixings.FixAnalysisEventsFacet; +import de.intevation.flys.artifacts.model.fixings.FixAnalysisPeriodsFacet; import de.intevation.flys.artifacts.model.fixings.FixReferenceEventsFacet; import de.intevation.flys.artifacts.model.fixings.FixOutlierFacet; import de.intevation.flys.artifacts.model.fixings.FixWQCurveFacet; - +import de.intevation.flys.artifacts.model.fixings.FixDerivateFacet; import de.intevation.flys.artifacts.model.fixings.DateRange; @@ -86,7 +87,7 @@ for (int i = 0; i < count; i++) { DateRange period = access.getAnalysisPeriods()[i]; for (int j = access.getQSectorStart().intValue(); - j < access.getQSectorEnd().intValue(); + j <= access.getQSectorEnd().intValue(); j++) { //TODO: replace j with q sector string. String description = j + ": " + @@ -94,16 +95,54 @@ period.getTo().toString(); facets.add( new FixAvSectorFacet(j - access.getQSectorStart().intValue(), + FIX_SECTOR_AVERAGE_DWT, description)); + facets.add( + new FixAvSectorFacet(j - access.getQSectorStart().intValue(), + FIX_SECTOR_AVERAGE_LS, + description)); + facets.add( + new FixAvSectorFacet(j - access.getQSectorStart().intValue(), + FIX_SECTOR_AVERAGE_WQ, + description)); + } String eventDesc = period.getFrom().toString() + " - " + period.getTo().toString(); - facets.add(new FixAnalysisEventsFacet(i, eventDesc)); + facets.add(new FixAnalysisEventsFacet(i, + FIX_ANALYSIS_EVENTS_DWT, + eventDesc)); + facets.add(new FixAnalysisEventsFacet(i, + FIX_ANALYSIS_EVENTS_LS, + eventDesc)); + facets.add(new FixAnalysisEventsFacet(i, + FIX_ANALYSIS_EVENTS_WQ, + eventDesc)); } - facets.add(new FixReferenceEventsFacet(0, "Referenceperiod")); + facets.add(new FixReferenceEventsFacet(0, + FIX_REFERENCE_EVENTS_DWT, + "Referenceperiod")); + facets.add(new FixReferenceEventsFacet(1, + FIX_REFERENCE_EVENTS_LS, + "Referenceperiod")); + facets.add(new FixReferenceEventsFacet(2, + FIX_REFERENCE_EVENTS_WQ, + "Referenceperiod")); + + facets.add(new FixAnalysisPeriodsFacet(0, + FIX_ANALYSIS_PERIODS_DWT, + "Analysis periods")); + facets.add(new FixAnalysisPeriodsFacet(1, + FIX_ANALYSIS_PERIODS_LS, + "Analysis periods")); + facets.add(new FixAnalysisPeriodsFacet(2, + FIX_ANALYSIS_PERIODS_WQ, + "Analysis periods")); + facets.add(new FixWQCurveFacet("W/Q")); - facets.add(new FixOutlierFacet("Outlier")); + facets.add(new FixOutlierFacet(FIX_OUTLIER, "Outlier")); + facets.add(new FixDerivateFacet(FIX_DERIVATE, "Derivative")); return res; }