net.simplace.client.simulation.lap.transformer.AstronomicParametersTransformer

Calculated daylength, photoperiodic daylength, solar constant and daily total effective solar height for each DOY for a set of given latitudes.

Input and output of the transformer

For each row in the resource it creates 366 rows containing values for each day of year (DOY)

The transformer needs the field names of a resource, that contain

Normally you do not enter the numeric value for latitude, but a reference to the value, i. e. the column name of the resource's column containing the latitudes.

It outputs a resource with following fields

Example

First you need a resource that has a latitude and sun inclination column.

|   <resource id="locations" interface="locationsfile" frequence="COMPLEX" rule="${DefaultManagement.DoSow}">
|      <header>
|        <res id="LocationId" datatype="CHAR" key="vActualLocation" />
|        <res id="Altitude" datatype="DOUBLE" />
|        <res id="Latitude" datatype="DOUBLE" />
|        <res id="SunInclination" datatype="DOUBLE" />
|        <res id="SoilType" description="" datatype="CHAR" />
|      </header>
|    </resource>

Now the resource id="locations" has to be written into the transformers resource attribute.

The header section contains the outputs of the tranformer. Make sure that they are in the same order as in the example. Dont't forget to add to the second element (LocationId) the same key attribute as in the resource.

Finally you tell the transformer the name of the resources id field (LocationId) and the name of the fields that hold the latitude and sun inclination.

Remember: the names have to match exactly, lower and upper case matters!

|    <transform id="at" frequence="DAILY" resource="locations" class="net.simplace.client.simulation.lap.transformer.AstronomicParametersTransformer">
|      <header>
|        <res id="DOY" datatype="INT" key="CURRENT.DOY" />
|        <res id="LocationId" datatype="CHAR" key="vActualLocation" />
|        <res id="DayLength" datatype="DOUBLE" />
|        <res id="PhotoperiodicDayLength" datatype="DOUBLE" />
|        <res id="SolarConstant" datatype="DOUBLE" />
|        <res id="SINLD" datatype="DOUBLE" />
|        <res id="COSLD" datatype="DOUBLE" />
|        <res id="DSINB" datatype="DOUBLE" />
|        <res id="DSINBE" datatype="DOUBLE" />
|      </header>
|      <input id="SunInclinationField">SunInclination</input>
|      <input id="LatitudeField">Latitude</input>
|      <input id="IdField">LocationId</input>
|    </transform>

Remarks

The calculation method follows mainly the routine from the Gecros model (1), see also (2) and (3):

Differences between this routine and Gecros

Formulas

Conversion factor from degrees to radians. The original Fortran/FST-Modules use a less precise approximation of \(\pi \approx 3.141592654\), whereas here \(\pi \approx 3.141592653589793\). \[ \begin{eqnarray} rad &=& \frac{\pi}{180}\\ \end{eqnarray} \] Sine and cosine of latitude, maximal declination. Values calculated only once per location. \[ \begin{eqnarray} sinlat &=& \sin(rad \cdot latitutde)\\ coslat &=& \cos(rad \cdot latitutde)\\ sindcm &=& \sin(rad \cdot 23.45)\\ \end{eqnarray} \] Sine and cosine of declination of the sun as function of day of year. Calculation is taken from Goudriaan, van Laar 1994. Some models first calculate \(dec\) as the arcsine of \(sindec\) and then take the sine and cosine. The methods are mathematically equivalent due to \(sin^2+cos^2=1\) \[ \begin{eqnarray} sindec &=& -sindcm \cos(2 \pi \frac{doy+10}{365})\\ cosdec &=& \sqrt{1-sindec^2}\\ sinld &=& sinlat \cdot sindec\\ cosld &=& coslat \cdot cosdec \end{eqnarray} \] Daylength calculation. \[ \begin{eqnarray} arg &=& \min(1,\max(-1,\frac{sinld}{cosld}))\\ daylength &=& 12 (1 + \frac{2}{\pi} \arcsin(arg))\\ \end{eqnarray} \] Photoperiodic daylength \[ \begin{eqnarray} arg2 &=& \min(1,\max(-1,\frac{-\sin(rad \cdot inclination)+sinld}{cosld}))\\ ddlp &=& 12(1+\frac{2}{\pi}\arcsin(arg2))\\ \end{eqnarray} \] Solar constant \[ \begin{eqnarray} sc &=& 1367(1 + 0.033 \cos(2 \pi\frac{doy-10}{365}))\\ \end{eqnarray} \] Daily total of effective solar height \[ \begin{eqnarray} dsinb &=& 3600(dayl \cdot sinld+24 cosld \frac{\sqrt{1-arg^2}}{\pi})\\ dsinbe &=& 3600(dayl(sinld+0.4(sinld^2+\frac{cosld^2}{2})) + 12 cosld(2+3\cdot 0.4 sinld)\frac{\sqrt{1-arg^2}}{\pi}) \end{eqnarray} \] Notice: The sine of solar height is \(sin\beta(h) = sinld + cosld \cdot \cos(2 \pi \frac{h-12}{24})\), \(dsinb\) is the integral \(\int_0^{24} sin\beta(h)dh\) converted to seconds.

Utilisation

Transformer is used in the FST based models:

Notice

Transformer works only with resources that have a single column key (that identifies the location) The transformed resource has two keys: the DOY and the key from the resource.

Tweaks

Instead of transforming a resource, the transformer can get the values for latitude and inclination directly and generate day lengths etc.

In order to use the transformer this way, you have to omit the resource attribute. LatitudeField and SunInclinationField should then be given directly as numbers or link to coresponding DOUBLE variables.

|    <var id="vLatitude" datatype="DOUBLE>53.1</var>
|    ...
|    <transform id="at" frequence="DAILY" resource="locations" class="net.simplace.client.simulation.lap.transformer.AstronomicParametersTransformer">
|      <header>
|        <res id="DOY" datatype="INT" key="CURRENT.DOY" />
|        <res id="LocationId" datatype="CHAR" key="vActualLocation" />
|        <res id="DayLength" datatype="DOUBLE" />
|        ...
|      </header>
|      <input id="SunInclinationField">-2.5</input>
|      <input id="LatitudeField" source="vLatitude">
|      <input id="IdField" source="vActualLocation">
|    </transform>

It's recommended to use the transformer with a resource, rather than the tweaked method. You can't mix the two methods by taking one value from the resource and another directly. The way of configuring the tweaked method might change (especially the ids of the inputs might be renamed to distinguish them from the inputs of the standart method).

References




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


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


public FWSimResourceCache getData(FWSimVarMap aVarMap)
throws MissingSimResourceException; // Defines
net.simplace.simulation.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 calculateDaylength(FWSimVariable aIdname,
FWSimVariable aLatitudename, FWSimVariable aInclinationname,
FWSimResourceCache aCache, FWSimVarMap aVarMap)
throws MissingSimResourceException;

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




}



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