Class LayerAggregationTransformer

java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.resources.FWSimInputAdapter
net.simplace.sim.io.resources.FWSimResourceTransformer
net.simplace.sim.transformers.LayerAggregationTransformer
All Implemented Interfaces:
net.simplace.sim.util.FWSimFieldContainer

public class LayerAggregationTransformer extends net.simplace.sim.io.resources.FWSimResourceTransformer
Aggregates values of several soil layers up to the user-specified maximal soil depth. WIKI_START It can compute the sum for absolute values (e.g. N content in g/m^2). It can compute the avg for relative values (as volumetric water content m^3/m^3). == Configuration == * method - aggregation method (currently only sum and avg are supported) * depthfieldname - name of the field, that contains the depth \(d_i\) (lower boundary) of each layer * maxdepthfield - optional: name of the field, that contains the maximum depth \(m\), up to which values should be aggregated == Calculation details == The transformer transforms all DOUBLEARRAY entries of the original resource and outputs the resulting doubles in the same order. The aggregation method is applied to all entries, it is not possible to define methods per entry. The layer thickness d is calculated as \(t_0=d_0\) and \(t_i = d_{i}-d_{i-1}\) for \(i>0\) As user-specified maxdepth can be smaller than the soil profile depth, for each layer the remaining depth is calculated \(r_i = max(m-d_{i-1},0)\), which is zero if the actual layer is completely below maxdepth. If `maxdepthfieldid` is omitted, then all layers are aggregated. === Sum of absolute values === Values from all layers, that are above maxdepth are summed up. From the layer that contains maxdepth, only the fraction from the upper boundary to maxdepth is summed up. \[\sum_{i=0}^{n-1}V_i \frac{min(t_i,r_i)}{t_i}\] === Average of relative values === Average values over the layers that are above maxdepth are computed by multiplying relative values with layer thickness d. From the layer that contains maxdepth, only the fraction from the upper boundary to maxdepth is used as weighing factor. Then the sum is divided by maxdepth m (or the total depth, if maxdepth m exceeds the soil profile depth). \[\frac{\sum_{i=0}^{n-1}V_i min(t_i,r_i)}{min(m,d_{n-1})}\] == Utilisation == The transformer is used by soilwater models that need soil properties per layer as well as aggregated properties for a specific depth, that contains multiple layers, e.g. - Hillflow1D == Notice == The transformer is mainly designed for layered soil properties, but can be used also for other layered data that has a kind of 'depth' information (e.g. air temperature at different heights). It transforms all numeric arrays of the resource and outputs them in the same order as they are specified in the resource. Non-array data in the resource is omitted in the transformer (except the keys). WIKI_END
Author:
Gunther Krauss, Andreas Enders
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.simplace.sim.io.FWSimIOAdapter

    net.simplace.sim.io.FWSimIOAdapter.FREQUENCE
  • Field Summary

    Fields inherited from class net.simplace.sim.io.resources.FWSimResourceTransformer

    iFieldMap, iIntColumnMap, iLastInputValuesMap, iLastProjectID, iLastUniqueID, iPoolName, iSourceName

    Fields inherited from class net.simplace.sim.io.resources.FWSimInputAdapter

    iJexlScript, iShouldCacheToDB

    Fields inherited from class net.simplace.sim.io.FWSimIOAdapter

    iArrayMode, iFieldcount, iFrequence, iHeaderVariables, iInterface, iJexlRule, iKeyMap, iName, iOrderNumber, iProcessTime, iResourceElement, iSession, iSourceKey
  • Constructor Summary

    Constructors
    Constructor
    Description
    LayerAggregationTransformer(net.simplace.sim.FWSimSession aSession, Integer aOrderNumber)
     
    LayerAggregationTransformer(net.simplace.sim.FWSimSession aSession, org.jdom2.Element aResourceElement, Integer aOrderNumber)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.simplace.sim.io.resources.FWSimResourceCache
    calculateAggregatedData(net.simplace.sim.util.FWSimVariable<String> aDepthField, net.simplace.sim.util.FWSimVariable<String> aMaxdepthField, net.simplace.sim.util.FWSimVariable<String> aMethod, String aProjectID, net.simplace.sim.io.resources.FWSimResourceCache aCache)
     
    HashMap<String,net.simplace.sim.util.FWSimVariable<?>>
     
    net.simplace.sim.io.resources.FWSimResourceCache
    getData(net.simplace.sim.util.FWSimVarMap aVarMap)
    standard method from outside
    net.simplace.sim.io.resources.FWSimResourceCache
    getData(net.simplace.sim.util.FWSimVarMap aVarMap, net.simplace.sim.io.resources.FWSimResourceCache aResourceCache)
    used by test cases
    protected Object[]
    MergeKeysAndValues(int aKeyFieldCount, Object aKeys, Object[] aValues)
     
    void
    updateFields(net.simplace.core.FWObservable aObservable)
     

    Methods inherited from class net.simplace.sim.io.resources.FWSimResourceTransformer

    addVariable, createFormFields, createResourceTransformer, createResourceTransformer, createResourceTransformer, fillVarMap, getCreateFormXML, getEditFormXML, getSourceResourceCache, getVariable, isUpdated, toXML

    Methods inherited from class net.simplace.sim.io.resources.FWSimInputAdapter

    getContentType, getInputVariables, getJexlScript, getOutputVariables, getVarMap, isTransformer, shouldCacheToDB, toHTMLTablestring

    Methods inherited from class net.simplace.sim.io.FWSimIOAdapter

    addProcessTime, checkCondition, createFormFields, finalize, getFieldMap, getFrequence, getHeaderVariables, getHeaderXML, getInterface, getJexlRule, getKeyMap, getName, getOrderNumber, isArrayMode, isConditionCheck, removeVariable, setInterface, setOrderNumber, toString, writeHeaderList

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LayerAggregationTransformer

      public LayerAggregationTransformer(net.simplace.sim.FWSimSession aSession, org.jdom2.Element aResourceElement, Integer aOrderNumber)
      Parameters:
      aSession -
      aResourceElement -
      aOrderNumber -
    • LayerAggregationTransformer

      public LayerAggregationTransformer(net.simplace.sim.FWSimSession aSession, Integer aOrderNumber)
      Parameters:
      aSession -
      aOrderNumber -
  • Method Details

    • createVariables

      public HashMap<String,net.simplace.sim.util.FWSimVariable<?>> createVariables()
      Specified by:
      createVariables in interface net.simplace.sim.util.FWSimFieldContainer
      Overrides:
      createVariables in class net.simplace.sim.io.FWSimIOAdapter
    • getData

      public net.simplace.sim.io.resources.FWSimResourceCache getData(net.simplace.sim.util.FWSimVarMap aVarMap) throws net.simplace.sim.exceptions.MissingSimResourceException
      standard method from outside
      Specified by:
      getData in class net.simplace.sim.io.resources.FWSimInputAdapter
      Throws:
      net.simplace.sim.exceptions.MissingSimResourceException
      See Also:
      • FWSimInputAdapter.getData(net.simplace.sim.util.FWSimVarMap)
    • getData

      public net.simplace.sim.io.resources.FWSimResourceCache getData(net.simplace.sim.util.FWSimVarMap aVarMap, net.simplace.sim.io.resources.FWSimResourceCache aResourceCache) throws net.simplace.sim.exceptions.MissingSimResourceException
      used by test cases
      Parameters:
      aVarMap - variable map
      aResourceCache - Cached resources (soil data)
      Returns:
      delivered new data from transformer
      Throws:
      net.simplace.sim.exceptions.MissingSimResourceException
    • calculateAggregatedData

      public net.simplace.sim.io.resources.FWSimResourceCache calculateAggregatedData(net.simplace.sim.util.FWSimVariable<String> aDepthField, net.simplace.sim.util.FWSimVariable<String> aMaxdepthField, net.simplace.sim.util.FWSimVariable<String> aMethod, String aProjectID, net.simplace.sim.io.resources.FWSimResourceCache aCache) throws net.simplace.sim.exceptions.MissingSimResourceException
      Parameters:
      aIdname -
      aDepthField -
      aMaxdepthField -
      aMethod -
      aProjectID -
      aCache -
      Returns:
      the transformed resource cache
      Throws:
      net.simplace.sim.exceptions.MissingSimResourceException
    • updateFields

      public void updateFields(net.simplace.core.FWObservable aObservable)
      Specified by:
      updateFields in class net.simplace.sim.io.resources.FWSimResourceTransformer
      See Also:
      • FWSimResourceTransformer.updateFields(net.simplace.core.FWObservable)
    • MergeKeysAndValues

      protected Object[] MergeKeysAndValues(int aKeyFieldCount, Object aKeys, Object[] aValues)
      Parameters:
      aKeyFieldCount -
      aKeys -
      aValues -
      Returns: