public void CalculateBarometricPressureWithHumidity(double measuredValue, double temperature, double altitude, double relativeHumidity, double expected) { var result = WeatherHelper.CalculateBarometricPressure(Pressure.FromHectopascal(measuredValue), Temperature.FromCelsius(temperature), altitude, relativeHumidity); Assert.Equal(expected, result.Hectopascal, 2); }
public void ToStringDefault() { using (new SetCultureForTest("de-CH")) { Pressure p = Pressure.FromHectopascal(1024.24); Assert.Equal("1024.24hPa", p.ToString()); } }
/// <summary> /// Calculates the barometric pressure from a raw reading, using the reduction formula from the german met service. /// This is a more complex variant of <see cref="CalculateSeaLevelPressure"/>. It gives the value that a weather station gives /// for a particular area and is also used in meteorological charts. /// <example> /// You are at 650m over sea and measure a pressure of 948.7 hPa and a temperature of 24.0°C. The met service will show that /// you are within a high-pressure area of around 1020 hPa. /// </example> /// </summary> /// <param name="measuredPressure">Measured pressure at the observation point</param> /// <param name="measuredTemperature">Measured temperature at the observation point</param> /// <param name="vaporPressure">Vapor pressure, meteorologic definition</param> /// <param name="measurementAltitude">Height over sea level of the observation point (to be really precise, geopotential heights have /// to be used above ~750m)</param> /// <returns>The barometric pressure at the point of observation</returns> /// <remarks> /// From https://de.wikipedia.org/wiki/Barometrische_Höhenformel#Anwendungen /// </remarks> public static Pressure CalculateBarometricPressure(Pressure measuredPressure, Temperature measuredTemperature, Pressure vaporPressure, double measurementAltitude) { double x = (9.80665 / (287.05 * ((measuredTemperature.Kelvin) + 0.12 * vaporPressure.Hectopascal + (0.0065 * measurementAltitude) / 2))) * measurementAltitude; double barometricPressure = measuredPressure.Hectopascal * Math.Exp(x); return(Pressure.FromHectopascal(barometricPressure)); }
public void ConversionFactorTests() { Pressure p = Pressure.FromMillibar(1024.24); Assert.Equal(p, Pressure.FromHectopascal(1024.24)); // Conversion factor from mmHg to Pascal Assert.Equal((1.0 / 0.00750062) * p.MillimeterOfMercury, p.Pascal, 5); // 1 inch = 25.4mm Assert.Equal(p.MillimeterOfMercury / 25.4, p.InchOfMercury, 3); }
public void Compare() { Pressure a = Pressure.FromHectopascal(950.21); Pressure b = Pressure.FromHectopascal(920.59); Pressure c = Pressure.FromPascal(95021); Assert.NotEqual(a, b); Assert.True(a != b); Assert.True(a.CompareTo(b) > 0); Assert.True(a == c); Assert.True(b < a); Assert.True(a > b); Assert.True(a >= c); Assert.True(a <= c); Assert.False(a < b); }
public void AltitudeIsCalculatedCorrectlyAtMslpAndDefaultTemp(double expected, double hpa) { var altitude = WeatherHelper.CalculateAltitude(Pressure.FromHectopascal(hpa)); Assert.Equal(expected, Math.Round(altitude, 2)); }
public void TemperatureIsCalculatedCorrectly(double expected, double pressure, double seaLevelPressure, double altitude) { var temperature = WeatherHelper.CalculateTemperature(Pressure.FromHectopascal(pressure), Pressure.FromHectopascal(seaLevelPressure), altitude); Assert.Equal(expected, Math.Round(temperature.Celsius, 0)); }
public void PressureIsCalculatedCorrectly(double expected, double seaLevelPressure, double altitude, double celsius) { var pressure = WeatherHelper.CalculatePressure(Pressure.FromHectopascal(seaLevelPressure), altitude, Temperature.FromCelsius(celsius)); Assert.Equal(expected, Math.Round(pressure.Hectopascal, 2)); }
public void AltitudeIsCalculatedCorrectly(double expected, double hpa, double seaLevelHpa, double celsius) { var altitude = WeatherHelper.CalculateAltitude(Pressure.FromHectopascal(hpa), Pressure.FromHectopascal(seaLevelHpa), Temperature.FromCelsius(celsius)); Assert.Equal(expected, Math.Round(altitude, 2)); }
/// <summary> /// Calculates the barometric pressure from a raw reading, using the reduction formula from the german met service. /// This is a more complex variant of <see cref="CalculateSeaLevelPressure"/>. It gives the value that a weather station gives /// for a particular area and is also used in meteorological charts. /// <example> /// You are at 650m over sea and measure a pressure of 948.7 hPa and a temperature of 24.0°C. The met service will show that /// you are within a high-pressure area of around 1020 hPa. /// </example> /// </summary> /// <param name="measuredPressure">Measured pressure at the observation point</param> /// <param name="measuredTemperature">Measured temperature at the observation point</param> /// <param name="measurementAltitude">Height over sea level of the observation point (to be really precise, geopotential heights have /// to be used above ~750m)</param> /// <returns>The barometric pressure at the point of observation</returns> /// <remarks> /// From https://de.wikipedia.org/wiki/Barometrische_Höhenformel#Anwendungen /// </remarks> public static Pressure CalculateBarometricPressure(Pressure measuredPressure, Temperature measuredTemperature, double measurementAltitude) { double vaporPressure; if (measuredTemperature.Celsius >= 9.1) { vaporPressure = 18.2194 * (1.0463 - Math.Exp((-0.0666) * measuredTemperature.Celsius)); } else { vaporPressure = 5.6402 * (-0.0916 + Math.Exp((-0.06) * measuredTemperature.Celsius)); } return(CalculateBarometricPressure(measuredPressure, measuredTemperature, Pressure.FromHectopascal(vaporPressure), measurementAltitude)); }
/// <summary> /// Calculates the actual vapor pressure. /// </summary> /// <param name="airTemperature">The dry air temperature</param> /// <param name="relativeHumidity">The relative humidity (RH) expressed as a percentage</param> /// <returns>The actual vapor pressure</returns> public static Pressure CalculateActualVaporPressure(Temperature airTemperature, double relativeHumidity) { return(Pressure.FromHectopascal((relativeHumidity * CalculateSaturatedVaporPressureOverWater(airTemperature).Hectopascal) / 100)); }