net.simplace.client.simulation.lap.util.DataTransformHelper
Methods for calculating daylength and diurnal values
Includes methods for integration/normalization/rescaling of piecewise
linear functions, as well as methods for calculating diurnal values
for radiation and temperature.
Reference: (G) Goudriaan, Modeling Potential Crop Growth Processes, 1994, (revised version Nov. 2004)
public class DataTransformHelper {
// Public Constructors
public DataTransformHelper();
// Class Methods public static HashMap
AstronomicParameters(int doy, double latitude);
Calculates day length and other parameters from DOY and latitude
- doy Day of year (from 1 to 366)
- latitude Latitude in degrees
returns HashMap with values for DAYL, DDLP, SC, SINLD, DSINB, DSINBE
public static HashMap
AstronomicParameters(int doy, double latitude, double
inclination);
Calculates day length and other parameters from DOY, latitude and sun inclination
- doy Day of year (from 1 to 366)
- latitude Latitude in degrees
- inclination Sun inclination in degrees
returns HashMap with values for DAYL, DDLP, SC, SINLD, DSINB, DSINBE
public static double[]
NormalizeCurve(double[] xs, double[] ys);
Normalizes the y-values of an x-y-curve so that the area under the curve is 1.
- xs the x values
- ys the y values
returns new y values
public static double[]
NormalizeCurve(double[] xs, double[] ys, double area);
Normalizes the y-values of an x-y-curve so that the area under the curve has given value.
- xs the x values
- ys the y values
- area the target area under the new curve
returns new y values
public static double[]
RescaleValues(double min, double max, double[] vs);
Rescales an array of values proportionally from new mininimum to new maximum.
- min minimum value of the new array
- max maximum value of the new array
- vs values
returns the rescaled values
public static double
Interpolate(double x, double[] xs, double[] ys, boolean
extrapolate);
Linear interpolation of a piecewise linear curve
- x position where the value should be interpolated
- xs array of x values
- ys array of corresponding y values
- extrapolate if true then first or last y value is returned if x is out of range, if false 0 is returned
returns the interpolated value
public static double
Integral(double[] xs, double[] ys);
Calculates the area under the curve defined by arrays of x and y values
- xs the x values defining the curve
- ys the y values defining the curve
returns the area
public static double
IntegralFromTo(double t1, double t2, double[] xs,
double[] ys);
Calculates the area under the curve defined by arrays of x and y values between the points t1 and t2
- t1 lower boundary of integration interval
- t2 upper boundary of integration interval
- xs the x values defining the curve
- ys the y values defining the curve
returns the area
public static double
RadiationIntensitySine(double t, double radiation,
double daylength);
Calculates the radiation intensity [radiation per hour] at a specified hour using simple sine curve
- t the hour (decimal from 0 to 24) [h]
- daylength day length in hours [h]
- radiation daily total radiation [J m^-2, kJ m^-2 or MJ m^-2]
returns radiation intensity [J m^-2 h^-1, kJ m^-2 h^-1 or MJ m^-2 h^-1]
public static double
RadiationSine(double t, double radiation, double
daylength);
Calculates the radiation accumulated from beginning of day till a specified hour using simple sine curve
- t the hour (decimal from 0 to 24) [h]
- radiation daily total radiation [J m^-2, kJ m^-2 or MJ m^-2]
- daylength day length in hours [h]
returns radiation from begin of day until hour t [J m^-2, kJ m^-2 or MJ m^-2]
public static double
RadiationSineFromTo(double t1, double t2, double
radiation, double daylength);
Calculates the radiation that is accumulated within the time span from t1 to t2 using simple sine curve
- t1 begin of interval (hour as decimal from 0 to 24)
- t2 end of interval (hour as decimal from 0 to 24)
- radiation daily total radiation [J m^-2, kJ m^-2 or MJ m^-2]
- daylength in hours [h]
returns radiation accumulated during time span from t1 to t2 [J m^-2, kJ m^-2 or MJ m^-2]
public static double
RadiationIntensitySinBeta(double t, double radiation,
double daylength, int doy, double a, double b, double integral);
Calculates the radiation intensity [radiation per hour] at a specified hour using SinBeta curve
Uses SinBeta curve as defined in (G), eq. 3.2
- t the hour (decimal from 0 to 24) [h]
- daylength day length in hours [h]
- radiation daily total radiation [J m^-2, kJ m^-2 or MJ m^-2]
- doy day of year [day]
- a shift of SinBeta curve, (G) eq. 3.3 [-]
- b amplitude of SinBeta curve, (G) eq. 3.3 [-]
- integral surface under the SinBeta curve, (G) eq. 3.7 [h]
returns radiation intensity [J m^-2 h^-1, kJ m^-2 h^-1 or MJ m^-2 h^-1]
public static double
RadiationSinBeta(double t, double radiation, double
daylength, int doy, double a, double b, double integral);
Calculates the radiation accumulated from beginning of day till a specified hour using SinBeta curve
Uses SinBeta curve as defined in (G), eq. 3.2
- t the hour (decimal from 0 to 24) [h]
- radiation daily total radiation [J m^-2, kJ m^-2 or MJ m^-2]
- daylength day length in hours [h]
- doy day of year [day]
- a shift of SinBeta curve, (G) eq. 3.3 [-]
- b amplitude of SinBeta curve, (G) eq. 3.3 [-]
- integral surface under the SinBeta curve, (G) eq. 3.7 [h]
returns radiation from begin of day until hour t [J m^-2, kJ m^-2 or MJ m^-2]
public static double
RadiationSinBetaFromTo(double t1, double t2, double
radiation, double daylength, int doy, double a, double b, double
integral);
Calculates the radiation that is accumulated within the time span from a to b using SinBeta curve
Uses SinBeta curve as defined in (G), eq. 3.2
- t1 begin of interval (hour as decimal from 0 to 24) [h]
- t2 end of interval (hour as decimal from 0 to 24) [h]
- radiation daily total radiation [J m^-2, kJ m^-2 or MJ m^-2]
- daylength in hours [h]
- a shift of SinBeta curve, (G) eq. 3.3 [-]
- b amplitude of SinBeta curve, (G) eq. 3.3 [-]
- integral surface under the SinBeta curve, (G) eq. 3.7 [h]
returns radiation accumulated during time span from a to b [J m^-2, kJ m^-2 or MJ m^-2]
public static double
Temperature(double t, double ptmax, double tmin, double
tmax, double ntmin, double daylength, double p, double tc);
Calculates temperature at hour t
Calculates the temperature during day and night according to (G) eq. 3.9, 3.10
- t the hour (decimal from 0 to 24) [h]
- ptmax daily maximum temperature of previous day [°C]
- tmin daily minimum temperature [°C]
- tmax daily maximum temperature [°C]
- ntmin daily minimum temperature of next day [°C]
- daylength in hours [h]
- p time duration between solar noon and maximum temperature [h]
- tc nocturnal time coefficient [h]
returns temperature at hour t [°C]
}
Extended by: net.simplace.client.simulation.lap.test.model.DataTransformHelperTest