Skip to content

Commit

Permalink
Fix regex to work with Sentinel-2 Band 8A (#393)
Browse files Browse the repository at this point in the history
* Fix regex to work with Sentinel-2 Band8A

Regex was only finding numerical bands (e.g. Band 01, 02, ..., 10, 12), but not Band 8A.

* Update test_sentinel to include Band 8A

* Simplify regex

Co-Authored-By: Adam J. Stewart <ajstewart426@gmail.com>

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
  • Loading branch information
weiji14 and adamjstewart authored Feb 12, 2022
1 parent 9e0e30a commit 019dc24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Binary file not shown.
14 changes: 13 additions & 1 deletion tests/datasets/test_sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@ class TestSentinel2:
@pytest.fixture
def dataset(self) -> Sentinel2:
root = os.path.join("tests", "data", "sentinel2")
bands = ["B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08", "B09", "B11"]
bands = [
"B01",
"B02",
"B03",
"B04",
"B05",
"B06",
"B07",
"B08",
"B8A",
"B09",
"B11",
]
transforms = nn.Identity() # type: ignore[attr-defined]
return Sentinel2(root, bands=bands, transforms=transforms)

Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Sentinel2(Sentinel):
filename_regex = r"""
^T(?P<tile>\d{2}[A-Z]{3})
_(?P<date>\d{8}T\d{6})
_(?P<band>B\d{2})
_(?P<band>B[018][\dA])
_(?P<resolution>\d{2}m)
\..*$
"""
Expand Down

0 comments on commit 019dc24

Please sign in to comment.