class SimpleMetarParser::Temperature
Attributes
degrees[R]
Temperature
in C
dew[R]
Dew temperature
humidity[R]
Relative humidity
temperature[R]
Temperature
in C
wind_chill[R]
Wind
chill index
wind_chill_us[R]
US Wind
chill index
Public Instance Methods
calculate_humidity()
click to toggle source
# File lib/simple_metar_parser/metar/temperature.rb, line 62 def calculate_humidity # Calculate relative humidity return if self.temperature.nil? or self.dew.nil? # http://github.com/brandonh/ruby-metar/blob/master/lib/metar.rb # http://www.faqs.org/faqs/meteorology/temp-dewpoint/ es0 = 6.11 # hPa t0 = 273.15 # kelvin td = self.dew + t0 # kelvin t = self.temperature + t0 # kelvin lv = 2500000 # joules/kg rv = 461.5 # joules*kelvin/kg e = es0 * Math::exp(lv/rv * (1.0/t0 - 1.0/td)) es = es0 * Math::exp(lv/rv * (1.0/t0 - 1.0/t)) rh = 100 * e/es @humidity = rh.round end
calculate_wind_chill()
click to toggle source
# File lib/simple_metar_parser/metar/temperature.rb, line 82 def calculate_wind_chill return if self.temperature.nil? or self.parent.wind.wind_speed.nil? return if self.temperature > 10 or self.parent.wind.wind_speed_kmh < 4.8 # http://en.wikipedia.org/wiki/Wind_chill v = self.parent.wind.wind_speed ta = self.temperature @wind_chill_us = 13.12 + 0.6215 * ta - 11.37 * v + 0.3965 * ta * v @wind_chill = (10.0 * Math.sqrt(v) - v + 10.5)*(33.0 - ta) end
decode_split(s)
click to toggle source
# File lib/simple_metar_parser/metar/temperature.rb, line 27 def decode_split(s) # Temperature in Celsius degrees if s =~ /^(M?)(\d{2})\/(M?)(\d{2})$/ if $1 == "M" @temperature = -1.0 * $2.to_f else @temperature = $2.to_f end if $3 == "M" @dew = -1.0 * $4.to_f else @dew = $4.to_f end return end # shorter version if s =~ /^(M?)(\d{2})\/$/ if $1 == "M" @temperature = -1.0 * $2.to_f else @temperature = $2.to_f end return end end
post_process()
click to toggle source
# File lib/simple_metar_parser/metar/temperature.rb, line 57 def post_process calculate_humidity calculate_wind_chill end
reset()
click to toggle source
# File lib/simple_metar_parser/metar/temperature.rb, line 6 def reset @temperature = nil @dew = nil end