unit uWxUtilsVP; // This source code may be freely used, including for commercial purposes // Steve Hatchett info@softwx.com // http://www.softwx.org/weather {********************************************** This file contains functions for calculating the raw sensor pressure of a Vantage Pro weather station from the sea level reduced pressure it provides. The sensor pressure can then be used to calcuate altimeter setting using other functions in the uWxUtils and uWxUtilsUS units. notes about input parameters: currentTemp - current instantaneous station temperature temp12HrsAgoF - temperature from 12 hours ago. If the 12 hour temp is not known, simply pass the same value as currentTemp for the 12 hour temp. For the vantage pro sea level to sensor pressure conversion, the 12 hour temp should be the hourly temp that is 11 hours to 11:59 in the past. For example, if the current time is 3:59pm, use the 4:00am temp, and if it is currently 4:00pm, use the 5:00am temp. Also, the vantage pro seems to use only whole degree temp values in the sea level calculation, so the function performs rounding on the temperature. meanTemp - average of current temp and the temperature 12 hours in the past. If the 12 hour temp is not known, simply pass the same value as currentTemp for the mean temp. For the Vantage Pro, the mean temperature should come from the BARDATA.VirtualTemp. The value in BARDATA is an integer (whole degrees). The vantage pro calculates the mean by Round(((Round(currentTempF - 0.01) + Round(temp12HrsAgoF - 0.01)) / 2) - 0.01); humidity - Value should be 0 to 100. For the pressure conversion functions, pass a value of zero if you do not want to the algorithm to include the humidity correction factor in the calculation. If you provide a humidity value > 0, then humidity effect will be included in the calculation. elevation - This should be the geometric altitude of the station (this is the elevation provided by surveys and normally used by people when they speak of elevation). Some algorithms will convert the elevation internally into a geopotential altitude. **********************************************} interface uses uWxUtilsUS, uWxUtils; type TWxUtilsVP = class(TObject) // this function is used if you have access to BARDATA (see Davis Serial docs) // meanTempF is from BARDATA.VirtualTemp // humidityCorr is from BARDATA.C (remember to first divide C by 10) class function SeaLevelToSensorPressure(pressureIn: TWxReal; elevationFt: TWxReal; meanTempF: integer; humidityCorr: TWxReal): TWxReal; overload; // this function is used if you do not have access to BARDATA. The function // will internally calculate the mean temp and the humidity correction // the would normally come from the BARDATA. // currentTempF is the value of the current sensor temp // temp12HrsAgoF is the temperature from 12 hours ago (see comments on // temp12Hr from earlier in this document for more on this). class function SeaLevelToSensorPressure(pressureIn: TWxReal; elevationFt: TWxReal; currentTempF: TWxReal; temp12HrsAgoF: TWxReal; humidity: TWxHumidity): TWxReal; overload; end; implementation class function TWxUtilsVP.SeaLevelToSensorPressure(pressureIn: TWxReal; elevationFt: TWxReal; meanTempF: integer; humidityCorr: TWxReal): TWxReal; begin Result := TWxUtilsUS.SeaLevelToStationPressure(pressureIn, elevationFt, meanTempF, meanTempF + humidityCorr, 0, paDavisVp); end; class function TWxUtilsVP.SeaLevelToSensorPressure(pressureIn: TWxReal; elevationFt: TWxReal; currentTempF: TWxReal; temp12HrsAgoF: TWxReal; humidity: TWxHumidity): TWxReal; begin Result := TWxUtilsUS.SeaLevelToStationPressure(pressureIn, elevationFt, currentTempF, Round(((Round(currentTempF - 0.01) + Round(temp12HrsAgoF - 0.01)) / 2) - 0.01), humidity, paDavisVp); end; end.