# Path: ish_parser/Speed.py
# class Speed(Observation):
#   ''' observation of a wind speed, which we can convert
#   between m/s and mph, yay '''
#   METERSPERSECOND = 1
#   MILESPERHOUR = 2
#   SPEED_SCALE = 10
#   MPH_PER_MPS = 100 / 2.54 / 12 / 5280 * 60 * 60
#   MISSING = [999, 9999, 999.9]
# 
#   def get_MilesPerHour(self):
#     ''' convert the measurement to inches '''
#     if self._obs_value in self.MISSING:
#       return None
#     if self._obs_units == self.METERSPERSECOND:
#       return round(self._obs_value * self.MPH_PER_MPS, 4)
# 
#   def __str__(self):
#     if self._obs_value in self.MISSING:
#       return 'MISSING'
#     else:
#       return str(self._obs_value)
# 
# Path: ish_parser/Direction.py
# class Direction(Observation):
#   ''' Direction reflects an angle (usually wind direction). It should
#   always range from 0-360. Missing is 999 '''
#   RADIANS = 1
#   MISSING = 999
# 
#   def __str__(self):
#     if int(self._obs_value) == self.MISSING:
#       return 'MISSING'
#     else:
#       return str(self._obs_value)
# 
#   def __eq__(self, other_value):
#     if int(self._obs_value) == int(other_value):
#       return True
#     else:
#       return False
# 
# Path: ish_parser/Components/BaseComponent.py
# class BaseComponent(object):
#   ''' base component handler '''


from ..Speed import Speed
from ..Direction import Direction
from .BaseComponent import BaseComponent


class WindObservationComponent(BaseComponent):
  ''' handle OD1/OD2/OD3 Additional Wind observation types '''
  WIND_OBSERVATION_TYPES = {
    '1': 'Average speed of prevailing wind',
    '2': 'Mean wind speed',
    '3': 'Maximum instantaneous wind speed',
    '4': 'Maximum gust speed',
    '5': 'Maximum mean wind speed',
    '6': 'Maximum 1 - minute mean wind speed',
    '9': 'Missing'
  }

  def loads(self, string):
    self.wind_observation = {
      'type': self.WIND_OBSERVATION_TYPES[string[0:1]],
      'hours': int(string[1:3]),

# Path: ish_parser/Speed.py
# class Speed(Observation):
#   ''' observation of a wind speed, which we can convert
#   between m/s and mph, yay '''
#   METERSPERSECOND = 1
#   MILESPERHOUR = 2
#   SPEED_SCALE = 10
#   MPH_PER_MPS = 100 / 2.54 / 12 / 5280 * 60 * 60
#   MISSING = [999, 9999, 999.9]
# 
#   def get_MilesPerHour(self):
#     ''' convert the measurement to inches '''
#     if self._obs_value in self.MISSING:
#       return None
#     if self._obs_units == self.METERSPERSECOND:
#       return round(self._obs_value * self.MPH_PER_MPS, 4)
# 
#   def __str__(self):
#     if self._obs_value in self.MISSING:
#       return 'MISSING'
#     else:
#       return str(self._obs_value)
# 
# Path: ish_parser/Direction.py
# class Direction(Observation):
#   ''' Direction reflects an angle (usually wind direction). It should
#   always range from 0-360. Missing is 999 '''
#   RADIANS = 1
#   MISSING = 999
# 
#   def __str__(self):
#     if int(self._obs_value) == self.MISSING:
#       return 'MISSING'
#     else:
#       return str(self._obs_value)
# 
#   def __eq__(self, other_value):
#     if int(self._obs_value) == int(other_value):
#       return True
#     else:
#       return False
# 
# Path: ish_parser/Components/BaseComponent.py
# class BaseComponent(object):
#   ''' base component handler '''


# Path: ish_parser/Components/WindObservationComponent.py
from ..Speed import Speed
from ..Direction import Direction
from .BaseComponent import BaseComponent



class WindObservationComponent(BaseComponent):
  ''' handle OD1/OD2/OD3 Additional Wind observation types '''
  WIND_OBSERVATION_TYPES = {
    '1': 'Average speed of prevailing wind',
    '2': 'Mean wind speed',
    '3': 'Maximum instantaneous wind speed',
    '4': 'Maximum gust speed',
    '5': 'Maximum mean wind speed',
    '6': 'Maximum 1 - minute mean wind speed',
    '9': 'Missing'
  }

  def loads(self, string):
    self.wind_observation = {
      'type': self.WIND_OBSERVATION_TYPES[string[0:1]],
      'hours': int(string[1:3]),

      'speed': Speed(float(string[3:7]) / 10.0, Speed.METERSPERSECOND, string[7:8]),