Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- public class ObsMath {
- public static final int PAD = -1000;
- public static int heatStressTempCalc (int tdry, int RH, int statHeight) {
- // Calculates heat stress temperature (deg. C) from
- // dry temperature (deg. C) and relative humidity (%)
- // Uses station height for station level pressure calculation
- int twet = wetTempCalc (tdry, RH, statHeight);
- return (int) Math.round ((tdry + twet) / 2.);
- }
- public static int heatStressIndexCalc (int temp) {
- // Calculates heat stress index from heat stress temperature
- int index = PAD;
- if (temp > 22 && temp <= 24)
- index = 1;
- else if (temp > 24 && temp <= 26)
- index = 2;
- else if (temp > 26 && temp <= 28)
- index = 3;
- else if (temp > 28 && temp <= 30)
- index = 4;
- else if (temp > 30)
- index = 5;
- return index;
- }
- private static int wetTempCalc (int tdry, int RH, int statHeight) {
- // Calculates wet temperature (deg. C) from dry temperature (deg. C) and relative humidity (%)
- // Uses station height for station level pressure calculation
- double twx, twn, twi=99999., EsTw, Ei, Ri=99999.;
- double pst = 101.3 * Math.pow (( 293. - 0.0065 * statHeight )/293., 5.26);
- double Psych = 0.000792 * pst;
- double EsTd = 0.611 * Math.exp( 17.27 * tdry / (237.3 + tdry));
- double R = RH / 100.;
- double E = R * EsTd;
- if ( Math.abs (E-0.611) < 0.0022 )
- twn = 0.;
- else
- twn = 13.7406 / ( 1./Math.log (E/.611) - .05791 );
- twx = tdry;
- while (Math.abs (R - Ri) >= 0.005) {
- twi = (twn + twx)/2.;
- EsTw = 0.611 * Math.exp( 17.27 * twi / (237.3 + twi) );
- Ei = EsTw - Psych * (tdry - twi) * ( 1 + 0.00115*twi);
- Ri = Ei / EsTd ;
- if ( Ri > R )
- twx = twi;
- else
- twn = twi;
- }
- return (int) Math.round (twi);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement