Struct measurements::humidity::Humidity
source · [−]pub struct Humidity { /* private fields */ }
Expand description
The Humidity
struct can be used to deal with relative humidity
in air in a common way. Relative humidity is an important metric used
in weather forecasts.
Relative humidity (as a ratio and percentage) and conversions between relative humidity and dewpoint are supported. It also provides calculations giving vapour pressure and absolute humidity.
Relative humidity gives the ratio of how much moisture the air is holding to how much moisture it could hold at a given temperature. Here we use the technical definition of humidity as ratio of the actual water vapor pressure to the equilibrium vapor pressure (often called the “saturation” vapor pressure).
For dewpoint calculations, we use the algorithm commonly known as the Magnus formula, with coefficients derived by Alduchov and Eskridge (1996), which gives resonable accuracy (vapour pressure error < 0.2%) for temperatures between 0 deg C, and 50 deg C.
Example:
// calculate the dewpoint from the relative humidity
use measurements::{Humidity,Temperature};
let humidity = Humidity::from_percent(85.0);
let temp = Temperature::from_celsius(18.0);
let dewpoint = humidity.as_dewpoint(temp);
println!("At {} humidity, air at {} has a dewpoint of {}", humidity, temp, dewpoint);
Implementations
Create a new Humidity from a floating point value percentage (i.e. 0.0% to 100.0%)
Create a new Humidity from a floating point value ratio (i.e. 0.0 to 1.0)
Convert this relative humidity to a value expressed as a ratio (i.e. 0.0 to 1.0)
Convert this relative humidty to a value expressed as a percentage (i.e. 0.0% to 100.0%)
Calculates Dewpoint from humidity and air temperature using the Magnus-Tetens approximation, with coefficients derived by Alduchov and Eskridge (1996). The formulas assume
Calculates the actual vapour pressure in the air, based on the air temperature and humidity at standard atmospheric pressure (1013.25 mb), using the Buck formula (accurate to +/- 0.02% between 0 deg C and 50 deg C)
Calculates the absolute humidity (i.e. the density of water vapor in the air (kg/m3)), using the Ideal Gas Law equation.
Calculates humidity from dewpoint and air temperature using the Magnus-Tetens Approximation, with coefficients derived by Alduchov and Eskridge (1996). The formulas assume
Trait Implementations
Get this quantity in the base units
Create a new quantity from the base units
Return the base unit for this type, as a string. For example “kilograms” Read more
Returns a string containing the most appropriate units for this quantity, and a floating point value representing this quantity in those units. Useful when, for example, a length might be in millimeters if it is very small, or kilometers when it is very large. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Humidity
impl UnwindSafe for Humidity
Blanket Implementations
Mutably borrows from an owned value. Read more