Class: WrfForecast::Threshold::ThresholdHandler
- Inherits:
-
Object
- Object
- WrfForecast::Threshold::ThresholdHandler
- Defined in:
- lib/wrf_forecast/threshold/threshold_handler.rb
Overview
This class maintains the different threshold classes and initializes them with the data of the forecast repository.
Instance Attribute Summary collapse
-
#air_temperature_threshold ⇒ AirTemperatureThreshold
readonly
The class holding the air temperature thresholds.
-
#apparent_temperature_threshold ⇒ ApparentTemperatureThreshold
readonly
The class holding the apparent temperature thresholds.
-
#pressure_threshold ⇒ PressureThreshold
readonly
The class holding the pressure thresholds.
-
#rain_threshold ⇒ RainThreshold
readonly
The class holding the rain thresholds.
-
#warnings ⇒ Hash
readonly
The mapping of measurand and triggered thresholds for the current forecast.
-
#wind_threshold ⇒ WindThreshold
readonly
The class holding the wind thresholds.
Instance Method Summary collapse
-
#collect_active_thresholds ⇒ Object
private
method to collect all overstepped thresholds indicating significant weather.
-
#collect_thresholds_for(threshold) ⇒ Object
private
method to collect the overstepped thresholds for the given measurand threshold.
-
#initialize(forecast_repository) ⇒ ThresholdHandler
constructor
initialization.
Constructor Details
#initialize(forecast_repository) ⇒ ThresholdHandler
initialization
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 26 def initialize(forecast_repository) data = forecast_repository.forecast_data @pressure_threshold = WrfForecast::Threshold::PressureThreshold.new(data[:pressure]) @air_temperature_threshold = WrfForecast::Threshold::AirTemperatureThreshold.new(data[:air_temperature]) @apparent_temperature_threshold = WrfForecast::Threshold::ApparentTemperatureThreshold. new(data[:apparent_temperature]) @wind_threshold = WrfForecast::Threshold::WindThreshold.new(data[:wind_speed]) @rain_threshold = WrfForecast::Threshold::RainThreshold.new(forecast_repository.hourly_rain) collect_active_thresholds end |
Instance Attribute Details
#air_temperature_threshold ⇒ AirTemperatureThreshold (readonly)
Returns the class holding the air temperature thresholds.
14 15 16 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 14 def air_temperature_threshold @air_temperature_threshold end |
#apparent_temperature_threshold ⇒ ApparentTemperatureThreshold (readonly)
Returns the class holding the apparent temperature thresholds.
16 17 18 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 16 def apparent_temperature_threshold @apparent_temperature_threshold end |
#pressure_threshold ⇒ PressureThreshold (readonly)
Returns the class holding the pressure thresholds.
12 13 14 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 12 def pressure_threshold @pressure_threshold end |
#rain_threshold ⇒ RainThreshold (readonly)
Returns the class holding the rain thresholds.
20 21 22 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 20 def rain_threshold @rain_threshold end |
#warnings ⇒ Hash (readonly)
Returns the mapping of measurand and triggered thresholds for the current forecast.
22 23 24 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 22 def warnings @warnings end |
#wind_threshold ⇒ WindThreshold (readonly)
Returns the class holding the wind thresholds.
18 19 20 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 18 def wind_threshold @wind_threshold end |
Instance Method Details
#collect_active_thresholds ⇒ Object (private)
method to collect all overstepped thresholds indicating significant weather
40 41 42 43 44 45 46 47 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 40 def collect_active_thresholds @warnings = Hash.new() @warnings[:air_temperature] = collect_thresholds_for(@air_temperature_threshold) @warnings[:apparent_temperature] = collect_thresholds_for(@apparent_temperature_threshold) @warnings[:wind_speed] = collect_thresholds_for(@wind_threshold) @warnings[:rain] = collect_thresholds_for(@rain_threshold) nil end |
#collect_thresholds_for(threshold) ⇒ Object (private)
method to collect the overstepped thresholds for the given measurand threshold
50 51 52 53 54 55 56 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 50 def collect_thresholds_for(threshold) active_thresholds = Array.new() threshold.indicators.each_value { |value| active_thresholds << value if(value.is_active) } active_thresholds end |