Class FWSimStatisticVariable

java.lang.Object
net.simplace.sim.io.output.FWSimStatisticVariable
Direct Known Subclasses:
DefaultSimStatistic

public abstract class FWSimStatisticVariable extends Object
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 Details

    • FWSimStatisticVariable

      protected FWSimStatisticVariable(org.jdom2.Element aStatElement, FWSimOutputAdapter aFwSimOutputAdapter)
      Reads the attributes of the stat element; the names of the simulated and observed columns are prefixed with the name of the output.
      Parameters:
      aStatElement - the stat element
      aFwSimOutputAdapter - the output adapter the statistic belongs to
      Throws:
      SimFieldMissingException - if id, simulated, observed or mode is 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 with net.simplace., it is the class name of a custom statistic with the constructor (Element, FWSimOutputAdapter); otherwise a DefaultSimStatistic is created, which interprets the mode as error calculation method.
      Parameters:
      aStatElement - the stat element
      aFwSimOutputAdapter - the output adapter the statistic belongs to
      Returns:
      the statistic, or null if the custom class cannot be instantiated (the error is logged)
      Throws:
      SimFieldMissingException - if the mode is missing
    • calculateStatistics

      public Double calculateStatistics(Object[] aDataArray, Object[] aDataArray2)
      Calculates the statistic with the mode of this statistic.
      Parameters:
      aDataArray - observed values
      aDataArray2 - simulated values (same length and order)
      Returns:
      the calculated value
    • calculate

      protected abstract Double calculate(Object[] aDataArray, Object[] aDataArray2, String aStatMode)
      Calculates the statistic; to be implemented by subclasses.
      Parameters:
      aDataArray - observed values
      aDataArray2 - simulated values (same length and order)
      aStatMode - the mode of the statistic
      Returns:
      the calculated value
    • getStatID

      public String getStatID()
      Returns:
      the id of the statistic
    • getStatSimVarID

      public String getStatSimVarID()
      Returns:
      the full name of the simulated values (<output>.<column>)
    • getStatObsVarID

      public String getStatObsVarID()
      Returns:
      the full name of the observed values (<output>.<column>)
    • getStatMode

      public String getStatMode()
      Returns:
      the calculation method or class name
    • getUnit

      public String getUnit()
      Returns:
      the unit of the result, or null
    • getDescription

      public String getDescription()
      Returns:
      the description, or null
    • toXML

      public org.jdom2.Element toXML()
      Creates the stat element; simulated and observed are written as given (without output name), as the constructor adds the output name when the element is read.
      Returns:
      the stat element