Skip to content

Commit

Permalink
Merge pull request #19 from vtoupet/master
Browse files Browse the repository at this point in the history
Add support for additional wind observations (OD1, OD2, OD3)
  • Loading branch information
haydenth committed Jul 22, 2021
2 parents 0a33d69 + 9bc54ac commit 2ba2073
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
24 changes: 24 additions & 0 deletions ish_parser/Components/WindObservationComponent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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]),
'direction': Direction(string[8:11], Direction.RADIANS)
}
1 change: 1 addition & 0 deletions ish_parser/Components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
from .SnowDepthComponent import SnowDepthComponent
from .SolarIrradianceComponent import SolarIrradianceComponent
from .PressureComponent import PressureComponent
from .WindObservationComponent import WindObservationComponent
6 changes: 3 additions & 3 deletions ish_parser/ish_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ class ish_report(object):
'OB1': ['HOURLY-SUBHOURLY-WIND', 28],
'OB2': ['HOURLY-SUBHOURLY-WIND', 28],
'OC1': ['WIND-GUST-OBSERVATION', 5],
'OD1': ['SUPPLEMENTARY-WIND-OBSERVATION', 11],
'OD2': ['SUPPLEMENTARY-WIND-OBSERVATION', 11],
'OD3': ['SUPPLEMENTARY-WIND-OBSERVATION', 11],
'OD1': ['SUPPLEMENTARY-WIND-OBSERVATION', 11, WindObservationComponent],
'OD2': ['SUPPLEMENTARY-WIND-OBSERVATION', 11, WindObservationComponent],
'OD3': ['SUPPLEMENTARY-WIND-OBSERVATION', 11, WindObservationComponent],
'OE1': ['SUMMARY-OF-DAY-WIND', 16],
'OE2': ['SUMMARY-OF-DAY-WIND', 16],
'OE3': ['SUMMARY-OF-DAY-WIND', 16],
Expand Down

0 comments on commit 2ba2073

Please sign in to comment.