Class DiurnalSineWeatherTransformer

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

public class DiurnalSineWeatherTransformer extends net.simplace.sim.io.resources.FWSimResourceTransformer
Transforms daily radiation and temperature to diurnal values using sine curves. WIKI_START Temperature follows a sine curve during daylight and an exponential decay curve during night between minimum and maximum temperature. Radiation follows one of the curves specified by the user - `Sine` - a simple sine curve , - `SinBeta` - sine of solar elevation (shifted sine curve) - `SinBetaEffective` - as `SinBeta`, but corrected for lower atmospheric transmission at lower solar elevation. as defined by (G). == Input variables == - The field names (column names) of date, radiation, min and max temperature in the resource (CHAR) - The number of steps the diurnal values are calculated (default is 24, i.e. hourly values) (INT) - Latitude of the location (DOUBLE) - The offset from noon of max temp `MaxTempTimeOffset` (default 1.5, i.e. max temperature occurs at 1:30 pm) (DOUBLE) - The nocturnal time coefficient for temperature `NocturnalTimeCoefficient` (default is 4 hours) (DOUBLE) - The radiation curve that should be used - one of `Sine`, `SinBeta` or `SinBetaEffective` (CHAR) == Output variables == Output variables in the following order - Key column(s) of the original resource (including date) in the same order and same datatype - Time - Array of time for each step (h) (INTARRAY) - Temperature - Array of Temperature for each step (°C) (DOUBLEARRAY) - Radiation intensity - Array of radiation intensity for each time step (J m^-2 h^-1, kJ m^-2 h^-1 or MJ m^-2 h^-1) (DOUBLEARRAY) - Radiation - Array of radiation accumulated between two time steps (DOUBLEARRAY) - DOY - day of year (d) (INT) - Daylength - (h) (DOUBLE) - Daily total radiation - (J m^-2, kJ m^-2 or MJ m^-2) (DOUBLE) === Example === First we need a resource with daily weather, including min and max temp and radiation. {{{ | |
| | | | | | | | | |
|
}}} The transformer needs the resource id in it's `resource` attribute. Output variables in the header section start with the resources key variables, followed by calculated variables. The inputs for `DateField`, `!MinTempField`, `MaxTempField` and `RadiationField` contain the names of the columns as defined in the resource above. {{{ | |
| | | | | | | | | |
| CURRENTDATE | AirTemperatureMin | AirTemperatureMax | GlobalSolarRadiation | 48 | | Sine | 1.5 | 4.0 |
}}} == Temperature == Temperature is calculated according to (G) eq. 3.9 for daytime WIKI_END \(12-d/2 < t_h < 12+d/2\): \[ T_a(t_h) =T_{min} + (T_{max} - T_{min})\sin(\pi \frac{t_h - 12 + \frac{d}{2}}{d + 2p}) \] WIKI_START and (G) eq. 3.10 for nighttime WIKI_END \(t_h \leq 12-d/2 \quad\text{or}\quad 12+d/2 \leq t_h\): \[ T_a(t_h) = \frac{T_{min}-T_{sset} e^{-\frac{n}{TC}} + (T_{sset}-T_{min})e^{-\frac{t_h - t_{sset}}{TC}}}{1-e^{-\frac{n}{TC}}} \] where \(T_a\) is the air temperature at hour \(t_h\), \(d, n\) are day- and nightlength, \(p\) is the offset from noon of max temperature and \(TC\) the nocturnal time coefficient. \(T_{sset}, t_{sset}\) are temperature and time at sunsset. WIKI_START == Radiation == If `RadiationCurve` has the value 'Sine', then the radiation intensitiy follows the curve WIKI_END \[ I(t) \propto s(t) = \sin(\frac{\pi}{d} (t - (12-\frac{d}{2}))) \] WIKI_START If it has the value `SinBeta` the curve (G), eq. 3.2 is used: WIKI_END \[ I(t) \propto sin\beta(t) = a + b\cos(2\pi \frac{t - 12}{24}) \] where parameters \(a,b\) depend on latitude and daylength. Diurnal Radiation at a timestep \(t_i\) is the radiation accumulated between the previous and actual timestep. \[ R(t_i) = \int_{t_{i-1}}^{t_i}I(t)dt \] WIKI_START == References == (G) Goudriaan, Modeling Potential Crop Growth Processes, 1994, (revised version Nov. 2004) WIKI_END
Author:
Gunther Krauss
  • 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
    DiurnalSineWeatherTransformer(net.simplace.sim.FWSimSession aSession, Integer aOrderNumber)
     
    DiurnalSineWeatherTransformer(net.simplace.sim.FWSimSession aSession, org.jdom2.Element aResourceElement, Integer aOrderNumber)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.simplace.sim.io.resources.FWSimResourceCache
    calculateDiurnalValues(int aSteps, double aLatitude, double aTimeOffset, double timeCoefficient, String radiationCurve, String aDateField, String aMinTempField, String aMaxTempField, String aRadiationField, String aProjectID, net.simplace.sim.io.resources.FWSimResourceCache aCache)
    Calculates Daylengths
    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[]
     
    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

    • DiurnalSineWeatherTransformer

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

      public DiurnalSineWeatherTransformer(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)
    • MergeKeysAndValues

      protected Object[] MergeKeysAndValues(int aKeyFieldCount, Object aKeys, DiurnalWeatherCalculator.DiurnalValues aValues)
      Parameters:
      aKeyFieldCount -
      aKeys -
      aValues -
      Returns:
    • 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
    • calculateDiurnalValues

      public net.simplace.sim.io.resources.FWSimResourceCache calculateDiurnalValues(int aSteps, double aLatitude, double aTimeOffset, double timeCoefficient, String radiationCurve, String aDateField, String aMinTempField, String aMaxTempField, String aRadiationField, String aProjectID, net.simplace.sim.io.resources.FWSimResourceCache aCache) throws net.simplace.sim.exceptions.MissingSimResourceException
      Calculates Daylengths
      Parameters:
      aSteps -
      aLatitude -
      aTimeOffset -
      timeCoefficient -
      radiationCurve -
      aDateField -
      aMinTempField -
      aMaxTempField -
      aRadiationField -
      aProjectID - id of the project
      aCache - original weather
      Returns:
      the new created FWSimResourceCache
      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)