@@ -61,6 +61,49 @@ ORDINATES = {
6161 'NNW' : '157.5'
6262}
6363
64+ class Meteorology :
65+ """
66+ Surface winds tend to be 20-30 degrees backed (vector anticlockwise)
67+ from the winds which steer weather systems:
68+ Friction with the ground surface tends to mean that land surface winds
69+ are as slow as half the speed of the wind at 2000ft. This fudge factor is
70+ a more conservative 1.5:
71+
72+ .. seealso::
73+
74+ [Source Book to the Forecaster's Reference Book](https://digital.nmla
75+ .metoffice.gov.uk/IO_011f7cd4-50fc-4903-b556-d24480ea883d/), section
76+ 1.2
77+ """
78+ SURFACE_BACKING = 2
79+ SURFACE_FRICTION = .66
80+ KT_TO_MPH = 1.15078
81+
82+ @staticmethod
83+ def process_direction (direction : str ) -> str :
84+ """Process raw wind direction:
85+
86+ * Convert direction from 10s of degrees to degrees.
87+ * Convert from Oceanographic (wind to) to Meteorological (wind from)
88+ convention.
89+ * Surface Friction Correction
90+ """
91+ return str (
92+ ((int (direction ) + 18 - Meteorology .SURFACE_BACKING ) % 36 ) * 10 )
93+
94+ @staticmethod
95+ def process_speed (speed : str ) -> str :
96+ """Process Raw wind speed
97+
98+ * Convert to KT to MPH
99+ * Surface Friction Correction
100+ """
101+ return str (
102+ (
103+ int (speed ) * Meteorology .KT_TO_MPH
104+ ) / Meteorology .SURFACE_FRICTION
105+ )
106+
64107
65108class NoDataException (Exception ):
66109 ...
@@ -134,10 +177,10 @@ def synop_grab(site_id, time):
134177
135178 # * Parse the direction from 10's of degrees to degrees
136179 # * Convert direction from to direction it's blowing to
137- data ['direction' ] = str ((( int ( data ['direction' ]) + 18 ) % 36 ) * 10 )
180+ data ['direction' ] = Meteorology . process_direction ( data ['direction' ])
138181
139182 # Convert data in KT to MPH:
140- data ['speed' ] = str ( int ( data ['speed' ]) * 1.15078 )
183+ data ['speed' ] = Meteorology . process_speed ( data ['speed' ])
141184
142185 # Get lat and long from MO Data:
143186 lat , lon = reference_lat_long (site_id )
0 commit comments