Class FWSimStatisticVariable
java.lang.Object
net.simplace.sim.io.output.FWSimStatisticVariable
- Direct Known Subclasses:
DefaultSimStatistic
A statistic of an output that compares simulated with observed values, e.g. the model efficiency of the yield. It is
defined by a
stat element of the output. Subclasses implement the calculation; the default is
DefaultSimStatistic.- Author:
- Andreas Enders
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFWSimStatisticVariable(org.jdom2.Element aStatElement, FWSimOutputAdapter aFwSimOutputAdapter) Reads the attributes of thestatelement; the names of the simulated and observed columns are prefixed with the name of the output. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract DoubleCalculates the statistic; to be implemented by subclasses.calculateStatistics(Object[] aDataArray, Object[] aDataArray2) Calculates the statistic with the mode of this statistic.static FWSimStatisticVariablecreateStatistic(org.jdom2.Element aStatElement, FWSimOutputAdapter aFwSimOutputAdapter) Factory method: creates a statistic from an element like<stat id="YIELD_ME" mode="MODELEFFICIENCY" simulated="Yield" observed="Yield_res"/>.getUnit()org.jdom2.ElementtoXML()Creates thestatelement;simulatedandobservedare written as given (without output name), as the constructor adds the output name when the element is read.
-
Constructor Details
-
FWSimStatisticVariable
protected FWSimStatisticVariable(org.jdom2.Element aStatElement, FWSimOutputAdapter aFwSimOutputAdapter) Reads the attributes of thestatelement; the names of the simulated and observed columns are prefixed with the name of the output.- Parameters:
aStatElement- thestatelementaFwSimOutputAdapter- the output adapter the statistic belongs to- Throws:
SimFieldMissingException- ifid,simulated,observedormodeis missing
-
-
Method Details
-
createStatistic
public static FWSimStatisticVariable createStatistic(org.jdom2.Element aStatElement, FWSimOutputAdapter aFwSimOutputAdapter) Factory method: creates a statistic from an element like<stat id="YIELD_ME" mode="MODELEFFICIENCY" simulated="Yield" observed="Yield_res"/>. If the mode starts withnet.simplace., it is the class name of a custom statistic with the constructor(Element, FWSimOutputAdapter); otherwise aDefaultSimStatisticis created, which interprets the mode as error calculation method.- Parameters:
aStatElement- thestatelementaFwSimOutputAdapter- the output adapter the statistic belongs to- Returns:
- the statistic, or
nullif the custom class cannot be instantiated (the error is logged) - Throws:
SimFieldMissingException- if the mode is missing
-
calculateStatistics
-
calculate
Calculates the statistic; to be implemented by subclasses.- Parameters:
aDataArray- observed valuesaDataArray2- simulated values (same length and order)aStatMode- the mode of the statistic- Returns:
- the calculated value
-
getStatID
- Returns:
- the id of the statistic
-
getStatSimVarID
- Returns:
- the full name of the simulated values (
<output>.<column>)
-
getStatObsVarID
- Returns:
- the full name of the observed values (
<output>.<column>)
-
getStatMode
- Returns:
- the calculation method or class name
-
getUnit
- Returns:
- the unit of the result, or
null
-
getDescription
- Returns:
- the description, or
null
-
toXML
public org.jdom2.Element toXML()Creates thestatelement;simulatedandobservedare written as given (without output name), as the constructor adds the output name when the element is read.- Returns:
- the
statelement
-