Class: WrfLibrary::MetaData

Inherits:
RubyUtils::MetaData
  • Object
show all
Defined in:
lib/wrf_library/meta_data.rb

Overview

Childclass that represents the meta data of a wrf station output

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header_line, start_date) ⇒ MetaData

initialization relevant meta information

Parameters:

  • header_line (Array)

    the head line of a data set holding the

  • start_date (Time)

    the start date and time of the data set



23
24
25
26
# File 'lib/wrf_library/meta_data.rb', line 23

def initialize(header_line, start_date)
  @start_date = start_date
  super(header_line)
end

Instance Attribute Details

#grid_dataGridPoint (readonly)

Returns the corresponding grid point.

Returns:

  • (GridPoint)

    the corresponding grid point



11
12
13
# File 'lib/wrf_library/meta_data.rb', line 11

def grid_data
  @grid_data
end

#start_dateTime (readonly)

Returns the start date and time of the data series.

Returns:

  • (Time)

    the start date and time of the data series



17
18
19
# File 'lib/wrf_library/meta_data.rb', line 17

def start_date
  @start_date
end

#stationStation (readonly)

Returns the information abount the station.

Returns:

  • (Station)

    the information abount the station



14
15
16
# File 'lib/wrf_library/meta_data.rb', line 14

def station
  @station
end

Instance Method Details

#delete_special_chars(entries) ⇒ Array (private)

helper method to clear entries of certain special character

Parameters:

  • entries (Array)

    the array with the header information

Returns:

  • (Array)

    the adjusted entry



50
51
52
53
54
55
# File 'lib/wrf_library/meta_data.rb', line 50

def delete_special_chars(entries)
  entries.each { |entry|
    entry.delete("(),")
  }
  return entries
end

#parse_header(header_line) ⇒ Object (private)

method which parses the required meta information from the head line

relevant meta information

Parameters:

  • header_line (Array)

    the head line of a data set holding the



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/wrf_library/meta_data.rb', line 34

def parse_header(header_line)
  entries = delete_special_chars(header_line)
  # switch entries for geo coordinates since latitude comes before longitude
  geo_coordinate = Entity::Coordinate.new(entries[6].to_f, entries[5].to_f)
  @grid_data = Entity::GridPoint.new(entries[8].to_f, entries[9].to_f,
                             entries[12].to_f, entries[11].to_f)
  # special case for multi word locations
  station_name = entries[0].sub("_", " ")
  @station = Entity::Station.new(station_name, entries[3], entries[13].to_f,
                                 geo_coordinate)
  nil
end