Class: WrfForecast::JsonConverter::TextForecastJsonConverter
- Inherits:
-
ForecastStationJsonConverter
- Object
- WrfLibrary::JsonConverter::BaseStationJsonConverter
- ForecastStationJsonConverter
- WrfForecast::JsonConverter::TextForecastJsonConverter
- Defined in:
- lib/wrf_forecast/json_converter/text_forecast_converter.rb
Overview
Child class to generate valid json output for the result data of a given wrf meteogram result already stored in a data repository
Instance Attribute Summary
Attributes inherited from ForecastStationJsonConverter
Instance Method Summary collapse
-
#generate_air_temperature_values ⇒ Hash
private
method to create the output hash for the air temperature values.
-
#generate_apparent_temperature_values ⇒ Hash
private
method to create the output hash for the apparent temperature values.
-
#generate_pressure_values ⇒ Hash
private
method to create the output hash for the pressure values.
-
#generate_rain_values ⇒ Hash
private
method to create the output hash for the precipitation values.
-
#generate_winddirection_values ⇒ Array
private
method to create the output hash for wind direction values.
-
#generate_windspeed_values ⇒ Hash
private
method to create the output hash for the wind values.
Methods inherited from ForecastStationJsonConverter
#add_additions, #convert_suntime, #generate_data_values, #generate_warnings, #initialize
Constructor Details
This class inherits a constructor from WrfForecast::JsonConverter::ForecastStationJsonConverter
Instance Method Details
#generate_air_temperature_values ⇒ Hash (private)
method to create the output hash for the air temperature values
21 22 23 24 25 |
# File 'lib/wrf_forecast/json_converter/text_forecast_converter.rb', line 21 def generate_air_temperature_values extreme_values = @forecast.extreme_values[:air_temperature] { :minimum => extreme_values.minimum.round(3), :maximum => extreme_values.maximum.round(3) } end |
#generate_apparent_temperature_values ⇒ Hash (private)
method to create the output hash for the apparent temperature values
13 14 15 16 17 |
# File 'lib/wrf_forecast/json_converter/text_forecast_converter.rb', line 13 def generate_apparent_temperature_values extreme_values = @forecast.extreme_values[:apparent_temperature] { :minimum => extreme_values.minimum.round(3), :maximum => extreme_values.maximum.round(3) } end |
#generate_pressure_values ⇒ Hash (private)
method to create the output hash for the pressure values
29 30 31 32 33 |
# File 'lib/wrf_forecast/json_converter/text_forecast_converter.rb', line 29 def generate_pressure_values extreme_values = @forecast.extreme_values[:pressure] { :minimum => extreme_values.minimum.round(3), :maximum => extreme_values.maximum.round(3) } end |
#generate_rain_values ⇒ Hash (private)
method to create the output hash for the precipitation values
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/wrf_forecast/json_converter/text_forecast_converter.rb', line 56 def generate_rain_values extreme_values = @forecast.extreme_values[:rain] values = Hash.new() values[:minimum] = extreme_values.minimum.round(3) values[:maximum] = extreme_values.maximum.round(3) rain_sum = 0 @forecast.hourly_rain.each { |value| rain_sum += value } values[:sum] = rain_sum.round(3) values end |
#generate_winddirection_values ⇒ Array (private)
method to create the output hash for wind direction values
47 48 49 50 51 52 |
# File 'lib/wrf_forecast/json_converter/text_forecast_converter.rb', line 47 def generate_winddirection_values prevalent_direction = WrfForecast::Directions.new().get_direction_string(@forecast.prevalent_direction) values = Hash.new() values[:prevalent_direction] = prevalent_direction values end |
#generate_windspeed_values ⇒ Hash (private)
method to create the output hash for the wind values
37 38 39 40 41 42 43 |
# File 'lib/wrf_forecast/json_converter/text_forecast_converter.rb', line 37 def generate_windspeed_values extreme_values = @forecast.extreme_values[:wind_speed] values = Hash.new() values[:minimum] = extreme_values.minimum.round(3) values[:maximum] = extreme_values.maximum.round(3) return values end |