net.simplace.sim.transformers.DiurnalSineWeatherTransformer

Transforms daily radiation and temperature to diurnal values using sine curves.

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

as defined by (G).

Input variables

Output variables

Output variables in the following order

Example

First we need a resource with daily weather, including min and max temp and radiation.

|    <resource id="weather" interface="weatherfile" frequence="DAILY">
|      <header>
|        <res id="KeyValue" datatype="CHAR" key="vWeatherKey"/>
|        <res id="PolygonCode" datatype="CHAR" />
|        <res id="CURRENTDATE" datatype="DATE" key="CURRENT.DATE" />
|        <res id="Rain" unit="mm" datatype="DOUBLE" />
|        <res id="AirTemperatureMax" unit="°C" datatype="DOUBLE" />
|        <res id="AirTemperatureMin" unit="°C" datatype="DOUBLE" />
|        <res id="GlobalSolarRadiation" unit="MJ*m**-2" datatype="DOUBLE" />
|        <res id="WindSpeed" unit="m*s**-1" datatype="DOUBLE" />
|        <res id="ReferenceEvapotranspiration" unit="mm" datatype="DOUBLE" />
|      </header>
|    </resource>

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.

|    <transform id="diurnal" frequence="DAILY" resource="weather" class="net.simplace.sim.transformers.DiurnalSineWeatherTransformer">
|      <header>
|        <res id="KeyValue" datatype="CHAR" key="vWeatherKey"/>
|        <res id="CURRENTDATE" datatype="DATE" key="CURRENT.DATE" />
|        <res id="Hours" datatype="DOUBLEARRAY" />
|        <res id="Temperature" datatype="DOUBLEARRAY" />
|        <res id="RadiationIntensity" datatype="DOUBLEARRAY" />
|        <res id="Radiation" datatype="DOUBLEARRAY" />
|        <res id="Doy" datatype="INT" />
|        <res id="Daylength" datatype="DOUBLE" />
|        <res id="GlobalRadiation" datatype="DOUBLE" />
|      </header>
|      <input id="DateField">CURRENTDATE</input>
|      <input id="MinTempField">AirTemperatureMin</input>
|      <input id="MaxTempField">AirTemperatureMax</input>
|      <input id="RadiationField">GlobalSolarRadiation</input>
|      <input id="Steps">48</input>
|      <input id="Latitude" source="vLatitude" />
|      <input id="RadiationCurve">Sine</input>
|    </transform>

Temperature

Temperature is calculated according to (G) eq. 3.9 for daytime

\(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}) \]

and (G) eq. 3.10 for nighttime

\(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.

Radiation

If RadiationCurve has the value 'Sine', then the radiation intensitiy follows the curve

\[ I(t) \propto s(t) = \sin(\frac{\pi}{d} (t - (12-\frac{d}{2}))) \]

If it has the value SinBeta the curve (G), eq. 3.2 is used:

\[ 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 \]

References

(G) Goudriaan, Modeling Potential Crop Growth Processes, 1994, (revised version Nov. 2004)




public class DiurnalSineWeatherTransformer extends
net.simplace.sim.io.resources.FWSimResourceTransformer {
// Public Constructors
public DiurnalSineWeatherTransformer(FWSimSession aSession, Element
aResourceElement, Integer aOrderNumber);
public DiurnalSineWeatherTransformer(FWSimSession aSession, Integer
aOrderNumber);


// Public Instance Methods
public HashMap createVariables(); // Defines
net.simplace.sim.io.FWSimIOAdapter


public FWSimResourceCache getData(FWSimVarMap aVarMap)
throws MissingSimResourceException; // Defines
net.simplace.sim.io.resources.FWSimInputAdapter


standard method from outside
public FWSimResourceCache getData(FWSimVarMap aVarMap, FWSimResourceCache
aResourceCache) throws MissingSimResourceException;

used by test cases
returns delivered new data from transformer
public FWSimResourceCache calculateDiurnalValues(int aSteps, double
aLatitude, double aTimeOffset, double timeCoefficient, String
radiationCurve, String aDateField, String aMinTempField, String
aMaxTempField, String aRadiationField, String aProjectID,
FWSimResourceCache aCache) throws MissingSimResourceException;

Calculates Daylengths
returns the new created {@link FWSimResourceCache}
public void updateFields(FWObservable aObservable);
// Defines net.simplace.sim.io.resources.FWSimResourceTransformer



// Protected Instance Methods
protected Object[] MergeKeysAndValues(int aKeyFieldCount, Object aKeys,
HashMap aValues);


returns


}



Hierarchy: java.lang.Object - net.simplace.sim.io.FWSimIOAdapter (net.simplace.sim.util.FWSimFieldContainer) - net.simplace.sim.io.resources.FWSimInputAdapter - net.simplace.sim.io.resources.FWSimResourceTransformer - DiurnalSineWeatherTransformer