Ejemplo n.º 1
0
        [InlineData(950, 15, 546.89, 1012.9)] // result is changed to 1012.9 from 1013.23
        public void CalculateBarometricPressure(double measuredValue, double temperature, double altitude,
                                                double expected)
        {
            Pressure result = WeatherHelper.CalculateBarometricPressure(Pressure.FromHectopascals(measuredValue),
                                                                        Temperature.FromDegreesCelsius(temperature), Length.FromMeters(altitude));

            Assert.Equal(expected, result.Hectopascals, 2);
        }
Ejemplo n.º 2
0
        public void CalculateBarometricPressureWithHumidity(double measuredValue, double temperature, double altitude, double relativeHumidity,
                                                            double expected)
        {
            var result = WeatherHelper.CalculateBarometricPressure(Pressure.FromHectopascals(measuredValue),
                                                                   Temperature.FromDegreesCelsius(temperature), Length.FromMeters(altitude), Ratio.FromPercent(relativeHumidity));

            Assert.Equal(expected, result.Hectopascals, 2);
        }
Ejemplo n.º 3
0
        /// <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,
                                                           Length measurementAltitude)
        {
            double x = (9.80665 / (287.05 * ((measuredTemperature.Kelvins) + 0.12 * vaporPressure.Hectopascals +
                                             (0.0065 * measurementAltitude.Meters) / 2))) * measurementAltitude.Meters;
            double barometricPressure = measuredPressure.Hectopascals * Math.Exp(x);

            return(Pressure.FromHectopascals(barometricPressure));
        }
Ejemplo n.º 4
0
 internal Readings(ApiWeatherResult apiWeatherResult)
 {
     Weather = new List <WeatherCondition>();
     foreach (var weather in apiWeatherResult.Weather)
     {
         Weather.Add(new WeatherCondition
         {
             ConditionId = weather.Id,
             Main        = weather.Main,
             Description = weather.Description,
             IconId      = weather.Icon
         });
     }
     Temperature        = Temperature.FromKelvins(apiWeatherResult.Main.Temp);
     FeelsLike          = Temperature.FromKelvins(apiWeatherResult.Main.FeelsLike);
     Pressure           = Pressure.FromHectopascals(apiWeatherResult.Main.Pressure);
     Humidity           = RelativeHumidity.FromPercent(apiWeatherResult.Main.Humidity);
     MinimumTemperature = Temperature.FromKelvins(apiWeatherResult.Main.TempMin);
     MaximumTemperature = Temperature.FromKelvins(apiWeatherResult.Main.TempMax);
     if (apiWeatherResult.Main.SeaLevel.HasValue)
     {
         SeaLevelPressure = Pressure.FromHectopascals(apiWeatherResult.Main.SeaLevel.Value);
     }
     if (apiWeatherResult.Main.GrndLevel.HasValue)
     {
         GroundLevelPressure = Pressure.FromHectopascals(apiWeatherResult.Main.GrndLevel.Value);
     }
     WindSpeed     = Speed.FromMetersPerSecond(apiWeatherResult.Wind.Speed);
     WindDirection = Angle.FromDegrees(apiWeatherResult.Wind.Deg);
     if (apiWeatherResult.Wind.Gust.HasValue)
     {
         WindGust = Speed.FromMetersPerSecond(apiWeatherResult.Wind.Gust.Value);
     }
     Cloudiness = Ratio.FromPercent(apiWeatherResult.Clouds.All);
     if (apiWeatherResult.Rain != null)
     {
         RainfallLastHour       = Length.FromMillimeters(apiWeatherResult.Rain.OneHour);
         RainfallLastThreeHours = Length.FromMillimeters(apiWeatherResult.Rain.ThreeHours);
     }
     if (apiWeatherResult.Snow != null)
     {
         SnowfallLastHour       = Length.FromMillimeters(apiWeatherResult.Snow.OneHour);
         SnowfallLastThreeHours = Length.FromMillimeters(apiWeatherResult.Snow.ThreeHours);
     }
     MeasuredTime   = DateTimeOffset.FromUnixTimeSeconds(apiWeatherResult.Dt).UtcDateTime;
     CountryCode    = apiWeatherResult.Sys.Country;
     Sunrise        = DateTimeOffset.FromUnixTimeSeconds(apiWeatherResult.Sys.Sunrise).UtcDateTime;
     Sunset         = DateTimeOffset.FromUnixTimeSeconds(apiWeatherResult.Sys.Sunset).UtcDateTime;
     TimeZoneOffset = TimeSpan.FromSeconds(apiWeatherResult.Timezone);
     CityId         = apiWeatherResult.Id;
     CityName       = apiWeatherResult.Name;
     FetchedTime    = DateTime.UtcNow;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Date and time message (ZDA). This should not normally need the last time as argument, because it defines it.
        /// </summary>
        public MeteorologicalComposite(TalkerId talkerId, IEnumerable <string> fields, DateTimeOffset time)
            : base(talkerId, Id, time)
        {
            IEnumerator <string> field = fields.GetEnumerator();

            double?baroInchesMercury = ReadValue(field);
            string referenceI        = ReadString(field) ?? string.Empty;
            double?baroBars          = ReadValue(field);
            string referenceB        = ReadString(field) ?? string.Empty;
            double?airTemp           = ReadValue(field);
            string referenceAir      = ReadString(field) ?? string.Empty;
            double?waterTemp         = ReadValue(field);
            string referenceWater    = ReadString(field) ?? string.Empty;
            double?relHumidity       = ReadValue(field);

            ReadValue(field); // Absolute humidity (ignored, since meaning unclear)
            double?dewPoint          = ReadValue(field);
            string referenceDewPoint = ReadString(field) ?? string.Empty;

            if (baroBars.HasValue && referenceB == "B")
            {
                BarometricPressure = Pressure.FromHectopascals(baroBars.Value * 1000);
            }
            else if (baroInchesMercury.HasValue && referenceI == "I")
            {
                BarometricPressure = Pressure.FromInchesOfMercury(baroInchesMercury.Value);
            }

            if (airTemp.HasValue && referenceAir == "C")
            {
                AirTemperature = Temperature.FromDegreesCelsius(airTemp.Value);
            }

            if (waterTemp.HasValue && referenceWater == "C")
            {
                WaterTemperature = Temperature.FromDegreesCelsius(waterTemp.Value);
            }

            if (relHumidity.HasValue)
            {
                RelativeHumidity = UnitsNet.RelativeHumidity.FromPercent(relHumidity.Value);
            }

            if (dewPoint.HasValue && referenceDewPoint == "C")
            {
                DewPoint = Temperature.FromDegreesCelsius(dewPoint.Value);
            }

            // Note: The remaining fields are about wind speed/direction. These are not parsed here, use MWV sentence instead
            Valid = true;
        }
Ejemplo n.º 6
0
        public void ConversionRoundTrip()
        {
            Pressure pascal = Pressure.FromPascals(1);

            AssertEx.EqualTolerance(1, Pressure.FromAtmospheres(pascal.Atmospheres).Pascals, AtmospheresTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromBars(pascal.Bars).Pascals, BarsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromCentibars(pascal.Centibars).Pascals, CentibarsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromDecapascals(pascal.Decapascals).Pascals, DecapascalsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromDecibars(pascal.Decibars).Pascals, DecibarsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromDynesPerSquareCentimeter(pascal.DynesPerSquareCentimeter).Pascals, DynesPerSquareCentimeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromFeetOfHead(pascal.FeetOfHead).Pascals, FeetOfHeadTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromGigapascals(pascal.Gigapascals).Pascals, GigapascalsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromHectopascals(pascal.Hectopascals).Pascals, HectopascalsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromInchesOfMercury(pascal.InchesOfMercury).Pascals, InchesOfMercuryTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilobars(pascal.Kilobars).Pascals, KilobarsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareCentimeter(pascal.KilogramsForcePerSquareCentimeter).Pascals, KilogramsForcePerSquareCentimeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareMeter(pascal.KilogramsForcePerSquareMeter).Pascals, KilogramsForcePerSquareMeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareMillimeter(pascal.KilogramsForcePerSquareMillimeter).Pascals, KilogramsForcePerSquareMillimeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareCentimeter(pascal.KilonewtonsPerSquareCentimeter).Pascals, KilonewtonsPerSquareCentimeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareMeter(pascal.KilonewtonsPerSquareMeter).Pascals, KilonewtonsPerSquareMeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareMillimeter(pascal.KilonewtonsPerSquareMillimeter).Pascals, KilonewtonsPerSquareMillimeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilopascals(pascal.Kilopascals).Pascals, KilopascalsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilopoundsForcePerSquareFoot(pascal.KilopoundsForcePerSquareFoot).Pascals, KilopoundsForcePerSquareFootTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromKilopoundsForcePerSquareInch(pascal.KilopoundsForcePerSquareInch).Pascals, KilopoundsForcePerSquareInchTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromMegabars(pascal.Megabars).Pascals, MegabarsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromMeganewtonsPerSquareMeter(pascal.MeganewtonsPerSquareMeter).Pascals, MeganewtonsPerSquareMeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromMegapascals(pascal.Megapascals).Pascals, MegapascalsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromMetersOfHead(pascal.MetersOfHead).Pascals, MetersOfHeadTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromMicrobars(pascal.Microbars).Pascals, MicrobarsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromMicropascals(pascal.Micropascals).Pascals, MicropascalsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromMillibars(pascal.Millibars).Pascals, MillibarsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromMillimetersOfMercury(pascal.MillimetersOfMercury).Pascals, MillimetersOfMercuryTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromMillipascals(pascal.Millipascals).Pascals, MillipascalsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareCentimeter(pascal.NewtonsPerSquareCentimeter).Pascals, NewtonsPerSquareCentimeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareMeter(pascal.NewtonsPerSquareMeter).Pascals, NewtonsPerSquareMeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareMillimeter(pascal.NewtonsPerSquareMillimeter).Pascals, NewtonsPerSquareMillimeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromPascals(pascal.Pascals).Pascals, PascalsTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromPoundsForcePerSquareFoot(pascal.PoundsForcePerSquareFoot).Pascals, PoundsForcePerSquareFootTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromPoundsForcePerSquareInch(pascal.PoundsForcePerSquareInch).Pascals, PoundsForcePerSquareInchTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromPoundsPerInchSecondSquared(pascal.PoundsPerInchSecondSquared).Pascals, PoundsPerInchSecondSquaredTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromPsi(pascal.Psi).Pascals, PsiTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromTechnicalAtmospheres(pascal.TechnicalAtmospheres).Pascals, TechnicalAtmospheresTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareCentimeter(pascal.TonnesForcePerSquareCentimeter).Pascals, TonnesForcePerSquareCentimeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareMeter(pascal.TonnesForcePerSquareMeter).Pascals, TonnesForcePerSquareMeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareMillimeter(pascal.TonnesForcePerSquareMillimeter).Pascals, TonnesForcePerSquareMillimeterTolerance);
            AssertEx.EqualTolerance(1, Pressure.FromTorrs(pascal.Torrs).Pascals, TorrsTolerance);
        }
Ejemplo n.º 7
0
        public void ConversionRoundTrip()
        {
            Pressure pascal = Pressure.FromPascals(1);

            Assert.AreEqual(1, Pressure.FromAtmospheres(pascal.Atmospheres).Pascals, AtmospheresTolerance);
            Assert.AreEqual(1, Pressure.FromBars(pascal.Bars).Pascals, BarsTolerance);
            Assert.AreEqual(1, Pressure.FromCentibars(pascal.Centibars).Pascals, CentibarsTolerance);
            Assert.AreEqual(1, Pressure.FromDecapascals(pascal.Decapascals).Pascals, DecapascalsTolerance);
            Assert.AreEqual(1, Pressure.FromDecibars(pascal.Decibars).Pascals, DecibarsTolerance);
            Assert.AreEqual(1, Pressure.FromGigapascals(pascal.Gigapascals).Pascals, GigapascalsTolerance);
            Assert.AreEqual(1, Pressure.FromHectopascals(pascal.Hectopascals).Pascals, HectopascalsTolerance);
            Assert.AreEqual(1, Pressure.FromKilobars(pascal.Kilobars).Pascals, KilobarsTolerance);
            Assert.AreEqual(1, Pressure.FromKilogramsForcePerSquareCentimeter(pascal.KilogramsForcePerSquareCentimeter).Pascals, KilogramsForcePerSquareCentimeterTolerance);
            Assert.AreEqual(1, Pressure.FromKilogramsForcePerSquareMeter(pascal.KilogramsForcePerSquareMeter).Pascals, KilogramsForcePerSquareMeterTolerance);
            Assert.AreEqual(1, Pressure.FromKilogramsForcePerSquareMillimeter(pascal.KilogramsForcePerSquareMillimeter).Pascals, KilogramsForcePerSquareMillimeterTolerance);
            Assert.AreEqual(1, Pressure.FromKilonewtonsPerSquareCentimeter(pascal.KilonewtonsPerSquareCentimeter).Pascals, KilonewtonsPerSquareCentimeterTolerance);
            Assert.AreEqual(1, Pressure.FromKilonewtonsPerSquareMeter(pascal.KilonewtonsPerSquareMeter).Pascals, KilonewtonsPerSquareMeterTolerance);
            Assert.AreEqual(1, Pressure.FromKilonewtonsPerSquareMillimeter(pascal.KilonewtonsPerSquareMillimeter).Pascals, KilonewtonsPerSquareMillimeterTolerance);
            Assert.AreEqual(1, Pressure.FromKilopascals(pascal.Kilopascals).Pascals, KilopascalsTolerance);
            Assert.AreEqual(1, Pressure.FromKilopoundsForcePerSquareFoot(pascal.KilopoundsForcePerSquareFoot).Pascals, KilopoundsForcePerSquareFootTolerance);
            Assert.AreEqual(1, Pressure.FromKilopoundsForcePerSquareInch(pascal.KilopoundsForcePerSquareInch).Pascals, KilopoundsForcePerSquareInchTolerance);
            Assert.AreEqual(1, Pressure.FromMegabars(pascal.Megabars).Pascals, MegabarsTolerance);
            Assert.AreEqual(1, Pressure.FromMegapascals(pascal.Megapascals).Pascals, MegapascalsTolerance);
            Assert.AreEqual(1, Pressure.FromMicropascals(pascal.Micropascals).Pascals, MicropascalsTolerance);
            Assert.AreEqual(1, Pressure.FromMillibars(pascal.Millibars).Pascals, MillibarsTolerance);
            Assert.AreEqual(1, Pressure.FromNewtonsPerSquareCentimeter(pascal.NewtonsPerSquareCentimeter).Pascals, NewtonsPerSquareCentimeterTolerance);
            Assert.AreEqual(1, Pressure.FromNewtonsPerSquareMeter(pascal.NewtonsPerSquareMeter).Pascals, NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(1, Pressure.FromNewtonsPerSquareMillimeter(pascal.NewtonsPerSquareMillimeter).Pascals, NewtonsPerSquareMillimeterTolerance);
            Assert.AreEqual(1, Pressure.FromPascals(pascal.Pascals).Pascals, PascalsTolerance);
            Assert.AreEqual(1, Pressure.FromPoundsForcePerSquareFoot(pascal.PoundsForcePerSquareFoot).Pascals, PoundsForcePerSquareFootTolerance);
            Assert.AreEqual(1, Pressure.FromPoundsForcePerSquareInch(pascal.PoundsForcePerSquareInch).Pascals, PoundsForcePerSquareInchTolerance);
            Assert.AreEqual(1, Pressure.FromPsi(pascal.Psi).Pascals, PsiTolerance);
            Assert.AreEqual(1, Pressure.FromTechnicalAtmospheres(pascal.TechnicalAtmospheres).Pascals, TechnicalAtmospheresTolerance);
            Assert.AreEqual(1, Pressure.FromTonnesForcePerSquareCentimeter(pascal.TonnesForcePerSquareCentimeter).Pascals, TonnesForcePerSquareCentimeterTolerance);
            Assert.AreEqual(1, Pressure.FromTonnesForcePerSquareMeter(pascal.TonnesForcePerSquareMeter).Pascals, TonnesForcePerSquareMeterTolerance);
            Assert.AreEqual(1, Pressure.FromTonnesForcePerSquareMillimeter(pascal.TonnesForcePerSquareMillimeter).Pascals, TonnesForcePerSquareMillimeterTolerance);
            Assert.AreEqual(1, Pressure.FromTorrs(pascal.Torrs).Pascals, TorrsTolerance);
        }
Ejemplo n.º 8
0
        public void AltitudeIsCalculatedCorrectlyAtDefaultTemp(double expected, double hpa, double seaLevelHpa)
        {
            Length altitude = WeatherHelper.CalculateAltitude(Pressure.FromHectopascals(hpa), Pressure.FromHectopascals(seaLevelHpa));

            Assert.Equal(expected, Math.Round(altitude.Meters, 2));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Calculates the actual vapor pressure.
 /// </summary>
 /// <param name="airTemperature">The dry air temperature</param>
 /// <param name="relativeHumidity">The relative humidity (RH)</param>
 /// <returns>The actual vapor pressure</returns>
 public static Pressure CalculateActualVaporPressure(Temperature airTemperature, Ratio relativeHumidity)
 {
     return(Pressure.FromHectopascals((relativeHumidity.DecimalFractions * CalculateSaturatedVaporPressureOverWater(airTemperature).Hectopascals)));
 }
Ejemplo n.º 10
0
        /// <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). Do not use the height obtained by calling <see cref="CalculateAltitude(UnitsNet.Pressure)"/>
        /// or any of its overloads, since what would use redundant data.</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,
                                                           Length measurementAltitude)
        {
            double vaporPressure;

            if (measuredTemperature.DegreesCelsius >= 9.1)
            {
                vaporPressure = 18.2194 * (1.0463 - Math.Exp((-0.0666) * measuredTemperature.DegreesCelsius));
            }
            else
            {
                vaporPressure = 5.6402 * (-0.0916 + Math.Exp((-0.06) * measuredTemperature.DegreesCelsius));
            }

            return(CalculateBarometricPressure(measuredPressure, measuredTemperature, Pressure.FromHectopascals(vaporPressure),
                                               measurementAltitude));
        }
Ejemplo n.º 11
0
 /// <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.FromHectopascals((relativeHumidity * CalculateSaturatedVaporPressureOverWater(airTemperature).Hectopascals) / 100));
 }
 public static Pressure Hectopascals <T>(this T value) =>
 Pressure.FromHectopascals(Convert.ToDecimal(value));
Ejemplo n.º 13
0
 public static Pressure?Hectopascals <T>(this T?value) where T : struct => Pressure.FromHectopascals(value == null ? (double?)null : Convert.ToDouble(value.Value));
Ejemplo n.º 14
0
 /// <summary>
 /// Calculates the actual vapor pressure.
 /// </summary>
 /// <param name="airTemperature">The dry air temperature</param>
 /// <param name="relativeHumidity">The relative humidity (RH)</param>
 /// <returns>The actual vapor pressure</returns>
 public static Pressure CalculateActualVaporPressure(Temperature airTemperature, RelativeHumidity relativeHumidity) =>
 Pressure.FromHectopascals((relativeHumidity.Percent / 100.0 * CalculateSaturatedVaporPressureOverWater(airTemperature).Hectopascals));
Ejemplo n.º 15
0
        public void AltitudeIsCalculatedCorrectly(double expected, double hpa, double seaLevelHpa, double celsius)
        {
            var altitude = WeatherHelper.CalculateAltitude(Pressure.FromHectopascals(hpa), Pressure.FromHectopascals(seaLevelHpa), Temperature.FromDegreesCelsius(celsius));

            Assert.Equal(expected, Math.Round(altitude.Meters, 2));
        }
Ejemplo n.º 16
0
        public void TemperatureIsCalculatedCorrectly(double expected, double pressure, double seaLevelPressure, double altitude)
        {
            var temperature = WeatherHelper.CalculateTemperature(Pressure.FromHectopascals(pressure), Pressure.FromHectopascals(seaLevelPressure), Length.FromMeters(altitude));

            Assert.Equal(expected, Math.Round(temperature.DegreesCelsius, 0));
        }
Ejemplo n.º 17
0
        public void PressureIsCalculatedCorrectly(double expected, double seaLevelPressure, double altitude, double celsius)
        {
            var pressure = WeatherHelper.CalculatePressure(Pressure.FromHectopascals(seaLevelPressure), Length.FromMeters(altitude), Temperature.FromDegreesCelsius(celsius));

            Assert.Equal(expected, Math.Round(pressure.Hectopascals, 2));
        }
 public void NumberToHectopascalsTest() =>
 Assert.Equal(Pressure.FromHectopascals(2), 2.Hectopascals());
Ejemplo n.º 19
0
        public void AltitudeIsCalculatedCorrectlyAtMslpAndDefaultTemp(double expected, double hpa)
        {
            var altitude = WeatherHelper.CalculateAltitude(Pressure.FromHectopascals(hpa));

            Assert.Equal(expected, Math.Round(altitude.Meters, 2));
        }