Skip to content
Snippets Groups Projects
Commit 6bd9f5e1 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Bugfix in single sine wave function alpha * cos, not acos....

parent a1340aa4
No related branches found
No related tags found
No related merge requests found
...@@ -87,7 +87,7 @@ public class NonLinearCurves { ...@@ -87,7 +87,7 @@ public class NonLinearCurves {
* <p>Based on Baskerville et al (1969): Rapid estimation of heat accumulation * <p>Based on Baskerville et al (1969): Rapid estimation of heat accumulation
* from maximum and minimum temperatures. Ref Figure 1</p> * from maximum and minimum temperatures. Ref Figure 1</p>
* <p>Formulas from Zalom et al 1983: Degree-days: The calculation and use * <p>Formulas from Zalom et al 1983: Degree-days: The calculation and use
* of heat units in pest managemeng. Division of Agriculture and Natural resources, * of heat units in pest management. Division of Agriculture and Natural resources,
* University of California. Leaflet 21373</p> * University of California. Leaflet 21373</p>
* @param Tmin minimum value of sine wave * @param Tmin minimum value of sine wave
* @param Tmax maximum value of sine wave * @param Tmax maximum value of sine wave
...@@ -137,7 +137,7 @@ public class NonLinearCurves { ...@@ -137,7 +137,7 @@ public class NonLinearCurves {
return (1/Math.PI) * ( return (1/Math.PI) * (
(m-Tl)*(theta_2 + Math.PI/2) (m-Tl)*(theta_2 + Math.PI/2)
+ (Tu-Tl)*(Math.PI/2-theta_2) + (Tu-Tl)*(Math.PI/2-theta_2)
- Math.acos(theta_2) - (alpha * Math.cos(theta_2))
); );
} }
......
...@@ -198,6 +198,15 @@ public class NonLinearCurvesTest extends TestCase { ...@@ -198,6 +198,15 @@ public class NonLinearCurvesTest extends TestCase {
result = instance.calculateSingleSineWaveWithCutoff(tMin, tMax, thresholdLower, thresholdUpper); result = instance.calculateSingleSineWaveWithCutoff(tMin, tMax, thresholdLower, thresholdUpper);
assertEquals(expectedResult, result,0.1); assertEquals(expectedResult, result,0.1);
// tMax is above Tu, tMin is above Tl
tMax = 31.8;
tMin = 16.6;
thresholdUpper = 31.1;
thresholdLower = 15.0;
expectedResult = 9.135946967874313;
result = instance.calculateSingleSineWaveWithCutoff(tMin, tMax, thresholdLower, thresholdUpper);
assertEquals(expectedResult, result,0.1);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment