Skip to content

Commit 096ae04

Browse files
committed
Add a meteorological tweak
Add a meteorological tweak remove unwanted env vars
1 parent 761dbbb commit 096ae04

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/get-observations

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

65108
class 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)

cylc/flow/etc/tutorial/cylc-forecasting-workflow/flow.cylc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@
7474

7575
[[get_rainfall]]
7676
script = get-rainfall
77-
[[[environment]]]
78-
# A template Map file
79-
MAP_FILE = "${CYLC_TASK_LOG_ROOT}-map.html"
80-
# Create the html map file in the task's log directory.
81-
MAP_FILE = "${CYLC_TASK_LOG_ROOT}-map.html"
82-
# The path to the template file used to generate the html map.
83-
MAP_TEMPLATE = "$CYLC_WORKFLOW_RUN_DIR/lib/template/map.html"
8477

8578
[[forecast]]
8679
script = forecast 60 5 # Generate 5 forecasts at 60 minute intervals.

0 commit comments

Comments
 (0)