Class: WrfForecast::JsonConverter::TextForecastJsonConverter

Inherits:
ForecastStationJsonConverter
  • Object
show all
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

#forecast, #warnings

Instance Method Summary collapse

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_valuesHash (private)

method to create the output hash for the air temperature values

Returns:

  • (Hash)

    the extreme values of the air temperature



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_valuesHash (private)

method to create the output hash for the apparent temperature values

Returns:

  • (Hash)

    the extreme values of the apparent temperature



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_valuesHash (private)

method to create the output hash for the pressure values

Returns:

  • (Hash)

    the extreme values of the pressure



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_valuesHash (private)

method to create the output hash for the precipitation values

Returns:

  • (Hash)

    the extreme values and sums of the precipitation



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_valuesArray (private)

method to create the output hash for wind direction values

Returns:

  • (Array)

    the array with the hourly 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_valuesHash (private)

method to create the output hash for the wind values

Returns:

  • (Hash)

    the extreme values and prevalent direction of the wind speed



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