Repository: python-metar/python-metar

Issue:
Cannot parse multiple BECOMING groups
A `ParserError` is raised when trying to parse a report with multiple BECOMING (`BECMG`) groups:

> Unparsed groups in body 'BECMG FM1000 TL1020 6000 NSW' while processing 'METAR WSSS 280900Z 26009KT 180V350 0600 R20R/1900D R20C/1600D +TSRA FEW008 SCT013CB FEW015TCU 24/23 Q1010 BECMG FM0920 TL0930 3000 TSRA BECMG FM1000 TL1020 6000 NSW'

> Unparsed groups in body 'BECMG FM1920 TL1940 6000 NSW' while processing 'METAR WSSS 311900Z 28009KT 210V320 1800 +TSRA FEW010 FEW014CB BKN015TCU 25/24 Q1011 BECMG TL1920 4000 TSRA BECMG FM1920 TL1940 6000 NSW'

> Unparsed groups in body 'BECMG FM1955 TL2010 6000 NSW' while processing 'METAR WSSS 311930Z VRB05KT 1800 +TSRA FEW008 FEW014CB SCT015TCU 25/24 Q1011 BECMG FM1940 TL1955 4000 TSRA BECMG FM1955 TL2010 6000 NSW'

> Unparsed groups in body 'BECMG FM2020 TL2040 6000 NSW' while processing 'METAR WSSS 312000Z VRB04KT 2000 +TSRA FEW010 FEW014CB SCT040 BKN140 24/24 Q1011 BECMG TL2020 4000 -TSRA BECMG FM2020 TL2040 6000 NSW'

Discussion:

Patch:
diff --git a/metar/Metar.py b/metar/Metar.py
index 9ac23db..6487d2a 100644
--- a/metar/Metar.py
+++ b/metar/Metar.py
@@ -1045,7 +1045,7 @@ class Metar(object):
         (WINDSHEAR_RE, _handleWindShear, True),
         (COLOR_RE, _handleColor, True),
         (RUNWAYSTATE_RE, _handleRunwayState, True),
-        (TREND_RE, _handleTrend, False),
+        (TREND_RE, _handleTrend, True),
         (REMARK_RE, _startRemarks, False),
     ]
 


Test patch:
diff --git a/test/test_metar.py b/test/test_metar.py
index 3770baf..0ef2fdd 100644
--- a/test/test_metar.py
+++ b/test/test_metar.py
@@ -39,6 +39,20 @@ def test_module():
     assert hasattr(metar, "__version__")
 
 
+def test_issue114_multiplebecominggroups():
+    """multiple BECMG (becoming) groups should be possible"""
+    code = (
+        "METAR WSSS 280900Z 26009KT 180V350 0600 R20R/1900D R20C/1600D +TSRA FEW008 SCT013CB FEW015TCU 24/23 Q1010 "
+        "BECMG FM0920 TL0930 3000 TSRA "
+        "BECMG FM1000 TL1020 6000 NSW"
+    )
+
+    metar = Metar.Metar(code)
+    assert metar.decode_completed
+    assert len(metar._trend_groups) == 10
+    assert metar.trend() == "BECMG FM0920 TL0930 3000 TSRA BECMG FM1000 TL1020 6000 NSW"
+
+
 @pytest.mark.parametrize("trailstr", ["", "=", "=  "])
 def test_issue84_trimequals(trailstr):
     """A trailing = in METAR should not trip up the ingest."""