Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion metar_taf_parser/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def parse_delivery_time(abstract_weather_code, time_string):
Parses the delivery time of a METAR/TAF. It will return False
if it is not a delivery time but a validity time. If the delivery time
is not specified, we can assume the start of the validity time is the delivery time.

This occurred in the line TEMPO 2308/2312 9999/8000 RA/DZ BKN020, where the delivery time is
2300/2312, but the validity time that follows, 9999/9000 was parsed as a delivery time,
causing the parser to give erroneous results.

:param abstract_weather_code: The TAF or METAR object
:param time_string: The string representing the delivery time
:return: None
Expand Down Expand Up @@ -313,7 +318,7 @@ def _extract_lines_tokens(self, taf_code: str):
"""
single_line = taf_code.replace('\n', ' ')
clean_line = re.sub(r'\s{2,}', ' ', single_line)
lines = re.sub(r'\s(PROB\d{2}\sTEMPO|TEMPO|INTER|BECMG|FM(?![A-Z]{2}\s)|PROB)', '\n\g<1>', clean_line).splitlines()
lines = re.sub(r'\s(PROB\d{2}\sTEMPO|TEMPO|INTER|BECMG|FM(?![A-Z]{2}\s)|PROB)', r'\n\g<1>', clean_line).splitlines()
lines_token = [self.tokenize(line) for line in lines]

if len(lines_token) > 1:
Expand Down
Loading