nebius/SWE-bench-extra huggingface dataset:
Repository: python-metar/python-metar

Issue:
Unparsed groups in body 'R/SNOCLO'
The [Manual on Codes](https://library.wmo.int/doc_num.php?explnum_id=10235) states

> The state of the runway group shall be replaced by the abbreviation R/SNOCLO when the aerodrome is closed due to extreme deposit of snow. 

Note that there is no runway designator, just the letter "R". However, the runway state regex for parsing the record requires a runway number. This leads to the mentioned error.

Test record:
> METAR EDDC 032220Z 31005KT 5000 -SN BKN008 M01/M01 Q1020 R/SNOCLO 

Comments:

Patch:
diff --git a/metar/Metar.py b/metar/Metar.py
index 5ef2d76..e5d113d 100644
--- a/metar/Metar.py
+++ b/metar/Metar.py
@@ -109,12 +109,13 @@ COLOR_RE = re.compile(
     re.VERBOSE,
 )
 RUNWAYSTATE_RE = re.compile(
-    r"""((?P<name>\d\d) | R(?P<namenew>\d\d)(RR?|LL?|C)?/?)
+    r"""((?P<snoclo>R/SNOCLO) |
+        ((?P<name>\d\d) | R(?P<namenew>\d\d)(RR?|LL?|C)?/?)
         ((?P<special> SNOCLO|CLRD(\d\d|//)) |
         (?P<deposit>(\d|/))
         (?P<extent>(\d|/))
         (?P<depth>(\d\d|//))
-        (?P<friction>(\d\d|//)))\s+""",
+        (?P<friction>(\d\d|//))))\s+""",
     re.VERBOSE,
 )
 TREND_RE = re.compile(r"^(?P<trend>TEMPO|BECMG|FCST|NOSIG)\s+")


Test patch:
diff --git a/test/test_metar.py b/test/test_metar.py
index 00bd05f..d6818a1 100644
--- a/test/test_metar.py
+++ b/test/test_metar.py
@@ -556,6 +556,11 @@ def test_290_ranway_state():
     assert report("09SNOCLO").remarks() == ""
     assert report("09CLRD//").remarks() == ""
 
+    assert report("R/SNOCLO").remarks() == ""
+    assert report("R09/CLRD//").remarks() == ""
+
+    assert report("R01R/SNOCLO ").remarks() == ""
+
 
 def test_300_parseTrend():
     """Check parsing of trend forecasts."""
Repository: python-metar/python-metar

Issue:
Unparsed groups in body 'AUTO'
I've found some METARS that cannot be parsed because they have 'COR AUTO' immediately following the report time. For instance:

```
>>> from metar.Metar import Metar
>>> Metar('''METAR KADW 252356Z COR AUTO 10008KT 10SM CLR 19/11 A2986
           RMK AO2 SLP117 T01880111 10230 20188 50004 $ COR
           0007=''')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jhaiduce/Development/python-metar/metar/Metar.py", line 499, in __init__
    raise ParserError(message)
metar.Metar.ParserError: Unparsed groups in body 'AUTO' while processing 'METAR KADW 252356Z COR AUTO 10008KT 10SM CLR 19/11 A2986
           RMK AO2 SLP117 T01880111 10230 20188 50004 $ COR
           0007='
```


Comments:

Patch:
diff --git a/metar/Datatypes.py b/metar/Datatypes.py
index c1ba23f..201f624 100644
--- a/metar/Datatypes.py
+++ b/metar/Datatypes.py
@@ -480,8 +480,8 @@ class position(object):
         long1 = self.longitude
         lat2 = position2.latitude
         long2 = position2.longitude
-        a = sin(0.5(lat2 - lat1)) + cos(lat1) * cos(lat2) * sin(
-            0.5 * (long2 - long1) ** 2
+        a = (sin(0.5(lat2 - lat1))) ** 2 + cos(lat1) * cos(lat2) * (sin(
+            0.5 * (long2 - long1)) ** 2
         )
         c = 2.0 * atan(sqrt(a) * sqrt(1.0 - a))
         d = distance(earth_radius * c, "M")
diff --git a/metar/Metar.py b/metar/Metar.py
index 9ac23db..bbe3e6e 100644
--- a/metar/Metar.py
+++ b/metar/Metar.py
@@ -43,7 +43,7 @@ TIME_RE = re.compile(
         (?P<min>\d\d)Z?\s+""",
     re.VERBOSE,
 )
-MODIFIER_RE = re.compile(r"^(?P<mod>AUTO|FINO|NIL|TEST|CORR?|RTD|CC[A-G])\s+")
+MODIFIER_RE = re.compile(r"^(?P<mod>AUTO|COR AUTO|FINO|NIL|TEST|CORR?|RTD|CC[A-G])\s+")
 WIND_RE = re.compile(
     r"""^(?P<dir>[\dO]{3}|[0O]|///|MMM|VRB)
         (?P<speed>P?[\dO]{2,3}|[/M]{2,3})


Test patch:
diff --git a/test/test_metar.py b/test/test_metar.py
index 3770baf..08824e6 100644
--- a/test/test_metar.py
+++ b/test/test_metar.py
@@ -602,3 +602,14 @@ def test_not_strict_mode():
     assert report.station_id == "K9L2"
     assert report.vis.value() == 10
     assert report.sky_conditions() == "clear"
+
+
+def test_cor_auto_mod():
+    """Test parsing of a COR AUTO Metar."""
+    code = (
+        "METAR KADW 252356Z COR AUTO 10008KT 10SM CLR 19/11 A2986 "
+        "RMK AO2 SLP117 T01880111 10230 20188 50004 $ COR 0007="
+    )
+    m = Metar.Metar(code, year=2019)
+
+    assert m.mod == 'COR AUTO'
Repository: python-metar/python-metar

Issue:
Unparsed group '09008KT 7SM' when wind is listed after sky groups.
The following METAR produces a ParserError:

METAR KCOF 281855Z FEW029TCU FEW040 SCT250 09008KT 7SM 32/25 A3008 RMK VIRGA E TCU NE AND DSNT ALQDS SLP186

Backtrace:

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jhaiduce/Development/python-metar/metar/Metar.py", line 499, in __init__
    raise ParserError(message)
metar.Metar.ParserError: Unparsed groups in body '09008KT 7SM' while processing 'METAR KCOF 281855Z FEW029TCU FEW040 SCT250 09008KT 7SM 32/25 A3008 RMK VIRGA E TCU NE AND DSNT ALQDS SLP186'
```

Comments:

Patch:
diff --git a/metar/Metar.py b/metar/Metar.py
index 8da571d..e3cf432 100644
--- a/metar/Metar.py
+++ b/metar/Metar.py
@@ -1050,6 +1050,8 @@ class Metar(object):
         (RUNWAY_RE, _handleRunway, True),
         (WEATHER_RE, _handleWeather, True),
         (SKY_RE, _handleSky, True),
+        (WIND_RE, _handleWind, False),
+        (VISIBILITY_RE, _handleVisibility, True),
         (TEMP_RE, _handleTemp, False),
         (PRESS_RE, _handlePressure, True),
         (RECENT_RE, _handleRecent, True),


Test patch:
diff --git a/test/test_metar.py b/test/test_metar.py
index 9bafe17..19996a7 100644
--- a/test/test_metar.py
+++ b/test/test_metar.py
@@ -654,6 +654,19 @@ def test_cor_auto_mod():
 
     assert m.mod == 'COR AUTO'
 
+def test_wind_after_sky():
+    """
+    Test parsing of a METAR that lists wind after the sky groups
+    """
+
+    code = (
+        "METAR KCOF 281855Z FEW029TCU FEW040 SCT250 09008KT 7SM 32/25 A3008 "
+        "RMK VIRGA E TCU NE AND DSNT ALQDS SLP186"
+    )
+    m = Metar.Metar(code, year=2007)
+
+    assert m.wind_dir.value() == 90
+    assert m.wind_speed.value() == 8
 
 def test_issue136_temperature():
     raisesParserError("METAR EDDM 022150Z 26006KT CAVOK 201/16")
Repository: python-metar/python-metar

Issue:
Unparsed group 'SLP162' when SLP group placed ahead of remarks group.
The following METAR produces a ParserError:

METAR KCOF 191855Z 18015G22KT 7SM FEW049 SCT300 28/18 A3001 SLP162 RMK WND DATA ESTMD

Traceback:
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jhaiduce/Development/python-metar/metar/Metar.py", line 499, in __init__
    raise ParserError(message)
metar.Metar.ParserError: Unparsed groups in body 'SLP162' while processing 'METAR KCOF 191855Z 18015G22KT 7SM FEW049 SCT300 28/18 A3001 SLP162 RMK WND DATA ESTMD'
```

Comments:

Patch:
diff --git a/metar/Metar.py b/metar/Metar.py
index e3cf432..e9d59ba 100644
--- a/metar/Metar.py
+++ b/metar/Metar.py
@@ -1054,6 +1054,7 @@ class Metar(object):
         (VISIBILITY_RE, _handleVisibility, True),
         (TEMP_RE, _handleTemp, False),
         (PRESS_RE, _handlePressure, True),
+        (SEALVL_PRESS_RE, _handleSealvlPressRemark, False),
         (RECENT_RE, _handleRecent, True),
         (WINDSHEAR_RE, _handleWindShear, True),
         (COLOR_RE, _handleColor, True),


Test patch:
diff --git a/test/test_metar.py b/test/test_metar.py
index 19996a7..1252f1c 100644
--- a/test/test_metar.py
+++ b/test/test_metar.py
@@ -654,6 +654,19 @@ def test_cor_auto_mod():
 
     assert m.mod == 'COR AUTO'
 
+def test_slp_outside_remarks():
+    """
+    Test parsing of a METAR that lists sea level pressure after the altimeter
+    setting instead of in the remarks.
+    """
+
+    code = (
+        "METAR KCOF 191855Z 18015G22KT 7SM FEW049 SCT300 28/18 A3001 SLP162 "
+        "RMK WND DATA ESTMD"
+    )
+    m = Metar.Metar(code, year=2007)
+    m.press_sea_level.value() == 1016.2
+
 def test_wind_after_sky():
     """
     Test parsing of a METAR that lists wind after the sky groups
Repository: python-metar/python-metar

Issue:
Parser allows invalid format of temperature group
The regex for the temperature group allows an arbitrary number (but at least 1) of digits, both for temperature and dewpoint:
https://github.com/python-metar/python-metar/blob/96f6b98ce685b37c7d5e438fa2d5e2648e56d0b0/metar/Metar.py#L87-L90

However, the [Manual on Codes](https://library.wmo.int/doc_num.php?explnum_id=10235) gives the format of the temperature group as T'T'/T'<sub>d</sub>T'<sub>d</sub> in 15.11, calling for exactly 2 digits.

Consequently, the following report should raise an error instead of parsing a temperature of 201°C (which clearly is a typo in this context considering the reports before/after this one).
> METAR EDDM 022150Z 26006KT CAVOK 201/16 Q1018 NOSIG


Comments:

Patch:
diff --git a/metar/Metar.py b/metar/Metar.py
index cf6026f..8da571d 100644
--- a/metar/Metar.py
+++ b/metar/Metar.py
@@ -85,8 +85,8 @@ SKY_RE = re.compile(
     re.VERBOSE,
 )
 TEMP_RE = re.compile(
-    r"""^(?P<temp>(M|-)?\d+|//|XX|MM)/
-        (?P<dewpt>(M|-)?\d+|//|XX|MM)?\s+""",
+    r"""^(?P<temp>(M|-)?\d{1,2}|//|XX|MM)/
+        (?P<dewpt>(M|-)?\d{1,2}|//|XX|MM)?\s+""",
     re.VERBOSE,
 )
 PRESS_RE = re.compile(


Test patch:
diff --git a/test/test_metar.py b/test/test_metar.py
index ed43504..9bafe17 100644
--- a/test/test_metar.py
+++ b/test/test_metar.py
@@ -653,3 +653,7 @@ def test_cor_auto_mod():
     m = Metar.Metar(code, year=2019)
 
     assert m.mod == 'COR AUTO'
+
+
+def test_issue136_temperature():
+    raisesParserError("METAR EDDM 022150Z 26006KT CAVOK 201/16")
Repository: python-metar/python-metar

Issue:
Spacing issue
sky: overcastcumulonimbus at 1000 feet

should read

sky: overcast^cumulonimbus at 1000 feet

Comments:

Patch:
diff --git a/metar/Metar.py b/metar/Metar.py
index 338e172..c089afb 100755
--- a/metar/Metar.py
+++ b/metar/Metar.py
@@ -1216,12 +1216,14 @@ class Metar(object):
                   what = "clouds"
               else: 
                   what = ""
+              label = "%s %s" % (SKY_COVER[cover], what)
+              # HACK here to account for 'empty' entries with above format
+              label = " ".join(label.strip().split())
               if cover == "VV":
-                  text_list.append("%s%s, vertical visibility to %s" % 
-                          (SKY_COVER[cover],what,str(height)))
+                  label += ", vertical visibility to %s" % (str(height), )
               else:
-                  text_list.append("%s%s at %s" % 
-                          (SKY_COVER[cover],what,str(height)))
+                  label += " at %s" % (str(height), )
+              text_list.append(label)
       return sep.join(text_list)
           
   def trend( self ):


Test patch:
diff --git a/test/test_metar.py b/test/test_metar.py
index e6c8fee..990b7b0 100644
--- a/test/test_metar.py
+++ b/test/test_metar.py
@@ -457,6 +457,9 @@ class MetarTest(unittest.TestCase):
     self.assertEqual( report('SCT030').sky_conditions(), 'scattered clouds at 3000 feet' )
     self.assertEqual( report('BKN001').sky_conditions(), 'broken clouds at 100 feet' )
     self.assertEqual( report('OVC008').sky_conditions(), 'overcast at 800 feet' )
+    self.assertEqual(
+      report('OVC010CB').sky_conditions(), 'overcast cumulonimbus at 1000 feet'
+    )
     self.assertEqual( report('SCT020TCU').sky_conditions(), 'scattered towering cumulus at 2000 feet' )
     self.assertEqual( report('BKN015CB').sky_conditions(), 'broken cumulonimbus at 1500 feet' )
     self.assertEqual( report('FEW030').sky_conditions(), 'a few clouds at 3000 feet' )
Repository: python-metar/python-metar

Issue:
Allow `ParserErrors` to not raise
If you're like me and get most of your METAR codes from FAA's ASOS program, you get a *lot* of parser errors.

The `MetarParser` subclass in [cloudside](https://github.com/Geosyntec/cloudside/blob/master/cloudside/station.py#L149) gets around this by simply logging the error and moving on. 

It'd be nice to have this as an *option* upstream.

Comments:

Patch:
diff --git a/metar/Metar.py b/metar/Metar.py
index b682d2c..766c485 100755
--- a/metar/Metar.py
+++ b/metar/Metar.py
@@ -324,13 +324,11 @@ class Metar(object):
         provided, then the month and year are guessed from the current date.
       utcdelta : int or datetime.timedelta, optional
         An int of hours or a timedelta object used to specify the timezone.
-      strict : bool (default is True) or str {'raise', 'warn', 'log'}
-        When unparsed or unparseable groups exist in a METAR code, a
-        ``ParserError`` will be raised. Setting this to False will suppress that
-        behavior and will use the standard library's logging module to record
-        all supressed errors. One can then detect if decoding is complete by
-        checking the :attr:`decode_completed` attribute.
-
+      strict : bool (default is True)
+        This option determines if a ``ParserError`` is raised when
+        unparsable groups are found or an unexpected exception is encountered.
+        Setting this to `False` will prevent exceptions from being raised and
+        only generate warning messages.
       """
 
       self.code = metarcode              # original METAR code
@@ -439,9 +437,13 @@ class Metar(object):
 
       except Exception as err:
           message = (
-              "%s failed while processing '%s'\n\t%s" % (handler.__name__, code, "\n\t".join(err.args))
+              ("%s failed while processing '%s'\n\t%s"
+               ) % (handler.__name__, code, "\n\t".join(err.args))
           )
-          raise ParserError(message)
+          if strict:
+              raise ParserError(message)
+          else:
+              warnings.warn(message, RuntimeWarning)
 
       if self._unparsed_groups:
           code = ' '.join(self._unparsed_groups)


Test patch:
diff --git a/test/test_metar.py b/test/test_metar.py
index d358061..269cf02 100644
--- a/test/test_metar.py
+++ b/test/test_metar.py
@@ -267,6 +267,13 @@ class MetarTest(unittest.TestCase):
     self.assertEqual( report("MMMMMGMMKT").wind(), "missing" )
     self.assertEqual( report("MMMMMG01KT").wind(), "missing" )
 
+  def test_issue51_strict(self):
+    """Check that setting strict=False prevents a ParserError"""
+    with warnings.catch_warnings(record=True) as w:
+        report = Metar.Metar(sta_time+"90010KT", strict=False)
+    assert len(w) == 1
+    assert report.wind_speed is None
+
   def test_142_parseWind_illegal(self):
     """Check rejection of illegal wind groups."""
     self.raisesParserError( sta_time+"90010KT" )
Repository: python-metar/python-metar

Issue:
AC code should be added to CLOUD_TYPE
Hi,

in this METAR `METAR LOXZ 141420Z 08006KT 20KM VCSH FEW025SC SCT040SC BKN090AC 21/14 Q1015 BECMG SCT090` parsing is ok but when we want the string representation we got an error 
```
line 1161, in sky_conditions
    what = CLOUD_TYPE[cloud]
KeyError: 'AC'
```  

AC for Alto Cumulus should be added.


Comments:

Patch:
diff --git a/metar/Metar.py b/metar/Metar.py
index d5836e3..7cbcaac 100755
--- a/metar/Metar.py
+++ b/metar/Metar.py
@@ -209,15 +209,25 @@ SKY_COVER = { "SKC":"clear",
               "///":"",
               "VV":"indefinite ceiling" }
 
-CLOUD_TYPE = { "TCU":"towering cumulus",
-               "CU":"cumulus",
-               "CB":"cumulonimbus",
-               "SC":"stratocumulus",
-               "CBMAM":"cumulonimbus mammatus",
-               "ACC":"altocumulus castellanus",
-               "SCSL":"standing lenticular stratocumulus",
-               "CCSL":"standing lenticular cirrocumulus",
-               "ACSL":"standing lenticular altocumulus" }
+
+CLOUD_TYPE = {
+    "AC": "altocumulus",
+    "ACC": "altocumulus castellanus",
+    "ACSL": "standing lenticular altocumulus",
+    "AS": "altostratus",
+    "CB": "cumulonimbus",
+    "CBMAM": "cumulonimbus mammatus",
+    "CCSL": "standing lenticular cirrocumulus",
+    "CC": "cirrocumulus",
+    "CI": "cirrus",
+    "CS": "cirrostratus",
+    "CU": "cumulus",
+    "NS": "nimbostratus",
+    "SC": "stratocumulus",
+    "ST": "stratus",
+    "SCSL": "standing lenticular stratocumulus",
+    "TCU": "towering cumulus",
+}
 
 ## translation of the present-weather codes into english
 
@@ -1243,7 +1253,9 @@ class Metar(object):
                 text_list.append(SKY_COVER[cover])
             else:
                 if cloud:
-                    what = CLOUD_TYPE[cloud]
+                    what = CLOUD_TYPE.get(
+                        cloud, "unknown CLOUD_TYPE of %s" % (cloud, )
+                    )
                 elif SKY_COVER[cover].endswith(" "):
                     what = "clouds"
                 else:


Test patch:
diff --git a/test/test_metar.py b/test/test_metar.py
index 5630e1b..5482a03 100644
--- a/test/test_metar.py
+++ b/test/test_metar.py
@@ -17,6 +17,19 @@ class MetarTest(unittest.TestCase):
     def raisesParserError(self, code):
         self.assertRaises(Metar.ParserError, Metar.Metar, code )
 
+    def test_issue64_cloudkeyerror(self):
+        """Lookup on CLOUD_TYPE should not keyerror."""
+        report = Metar.Metar(
+          "METAR LOXZ 141420Z 08006KT 20KM VCSH FEW025SC SCT040SC BKN090AC "
+          "21/14 Q1015 BECMG SCT090"
+        )
+        res = report.sky_conditions()
+        ans = (
+            "a few stratocumulus at 2500 feet; scattered stratocumulus at "
+            "4000 feet; broken altocumulus at 9000 feet"
+        )
+        self.assertEqual(res, ans)
+
     def test_issue40_runwayunits(self):
         """Check reported units on runway visual range."""
         report = Metar.Metar(