From: Janet Roseli Date: December 3, 2007 9:58:23 AM MST To: Robert Luke Subject: Dew Point double DlgMeterolDataLb::dewpt(double DryBulb, double WetBulb) { // Will return a (float) dew point when passed a drybulb and // a wetbulb temperature in Degrees C. // Returns 999 if the dew point can not be computed // dew point based on casio program code // coefficients for saturation vapor pressure // with respect to ice, with respect to water double coef[7][2] = {6.109177956, 6.107799961, 5.03469897E-1, 4.436518521E-1, 1.886013408E-2, 1.428945805E-2, 4.176223716E-4, 2.650648471E-4, 5.824720280E-6, 3.031240396E-6, 4.838803174E-8, 2.034080948E-8, 1.838826904E-10, 6.136820929E-11}; double p,q,w,dif,deweq; int i; int ice; //int ihold; CString cshold; if(WetBulb <= 0) ice = true; else ice = false; w=WetBulb; dif=DryBulb - WetBulb; if (dif < 0.0) { return 999.; } i=1; if(ice)i=0; p=coef[0][i]+w*(coef[1][i]+w*(coef[2][i]+w*(coef[3][i]+w*(coef[4][ i]+ w*(coef[5][i]+w*coef[6][i]))))); // use standard atmosphere of 29.92 inches of mercury p=p-(1013.20789*dif*(0.00066*(1.+w* 0.00115))); if(p >= 0.0) { q=log(p); deweq= (243.5*q-440.8)/(19.48-q); //ihold = int(deweq); return deweq; } else return 999.; }