Class: WrfForecast::JsonConverter::HourlyForecastJsonConverter

Inherits:
ForecastStationJsonConverter
  • Object
show all
Defined in:
lib/wrf_forecast/json_converter/hourly_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 collapse

Attributes inherited from ForecastStationJsonConverter

#forecast, #warnings

Instance Method Summary collapse

Methods inherited from ForecastStationJsonConverter

#add_additions, #convert_suntime, #generate_data_values, #generate_warnings

Constructor Details

#initialize(wrf_handler, forecast, warnings) ⇒ HourlyForecastJsonConverter

initialization

Parameters:

  • wrf_handler (WrfHandler)

    the wrf handler with the input data

  • forecast (ForecastRepository)

    the specific forecast data

  • warnings (Hash)

    the mapping of measurand and triggered thresholds for the current forecast



15
16
17
18
# File 'lib/wrf_forecast/json_converter/hourly_forecast_converter.rb', line 15

def initialize(wrf_handler, forecast, warnings)
  @wrf_handler = wrf_handler
  super(wrf_handler.data_repository, forecast, warnings)
end

Instance Attribute Details

#wrf_handlerWrfHandler (private)

Returns the wrf handler with the data of the model run.

Returns:

  • (WrfHandler)

    the wrf handler with the data of the model run



23
24
25
# File 'lib/wrf_forecast/json_converter/hourly_forecast_converter.rb', line 23

def wrf_handler
  @wrf_handler
end

Instance Method Details

#generate_air_temperature_valuesArray (private)

method to create the output hash for the air temperature values

Returns:

  • (Array)

    the array with the hourly temperature values



35
36
37
# File 'lib/wrf_forecast/json_converter/hourly_forecast_converter.rb', line 35

def generate_air_temperature_values
  WrfLibrary::Statistic::Hourly.calculate_hourly_means(:air_temperature, @wrf_handler)
end

#generate_apparent_temperature_valuesArray (private)

method to create the output hash for the temperature values

Returns:

  • (Array)

    the array with the hourly temperature values



27
28
29
30
31
# File 'lib/wrf_forecast/json_converter/hourly_forecast_converter.rb', line 27

def generate_apparent_temperature_values
  timestamps = @wrf_handler.retrieve_data_set(:forecast_time)
  data = @forecast.forecast_data[:apparent_temperature]
  WrfLibrary::Statistic::Hourly.calculate_hourly_data_means(timestamps, data)
end

#generate_pressure_valuesArray (private)

method to create the output hash for the pressure values

Returns:

  • (Array)

    the array with the hourly pressure values



41
42
43
# File 'lib/wrf_forecast/json_converter/hourly_forecast_converter.rb', line 41

def generate_pressure_values
  WrfLibrary::Statistic::Hourly.calculate_hourly_means(:pressure, @wrf_handler)
end

#generate_rain_valuesArray (private)

method to create the output hash for the precipitation values

Returns:

  • (Array)

    the array with the hourly precipitation values



59
60
61
# File 'lib/wrf_forecast/json_converter/hourly_forecast_converter.rb', line 59

def generate_rain_values
  WrfLibrary::Statistic::Hourly.calculate_hourly_rainsum(@wrf_handler)        
end

#generate_winddirection_valuesArray (private)

method to create the output hash for wind direction values

Returns:

  • (Array)

    the array with the hourly values



53
54
55
# File 'lib/wrf_forecast/json_converter/hourly_forecast_converter.rb', line 53

def generate_winddirection_values
  WrfLibrary::Statistic::Hourly.calculate_hourly_winddirection_means(@wrf_handler)
end

#generate_windspeed_valuesArray (private)

method to create the output hash for the wind values

Returns:

  • (Array)

    the array with the hourly wind values



47
48
49
# File 'lib/wrf_forecast/json_converter/hourly_forecast_converter.rb', line 47

def generate_windspeed_values
  WrfLibrary::Statistic::Hourly.calculate_hourly_windspeed_means(@wrf_handler)
end