Skip to content

Commit 189b60b

Browse files
authored
Add NEMO regex (#169)
1 parent f96d708 commit 189b60b

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

cf_xarray/accessor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@
116116

117117
#: regular expressions for guess_coord_axis
118118
regex = {
119-
"time": "(time|min|hour|day|week|month|year)[0-9]*",
119+
"time": "\\bt\\b|(time|min|hour|day|week|month|year)[0-9]*",
120120
"vertical": (
121-
"(lv_|bottom_top|sigma|h(ei)?ght|altitude|depth|isobaric|pres|"
122-
"isotherm)[a-z_]*[0-9]*"
121+
"(z|nav_lev|gdep|lv_|bottom_top|sigma|h(ei)?ght|altitude|depth|"
122+
"isobaric|pres|isotherm)[a-z_]*[0-9]*"
123123
),
124124
"Y": "y",
125-
"latitude": "y?lat[a-z0-9]*",
125+
"latitude": "y?(nav_lat|lat|gphi)[a-z0-9]*",
126126
"X": "x",
127-
"longitude": "x?lon[a-z0-9]*",
127+
"longitude": "x?(nav_lon|lon|glam)[a-z0-9]*",
128128
}
129129
regex["Z"] = regex["vertical"]
130130
regex["T"] = regex["time"]

cf_xarray/tests/test_accessor.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,13 @@ def test_docstring():
629629

630630

631631
def _make_names(prefixes):
632-
suffixes = ["", "a", "_a", "0", "_0"]
632+
suffixes = ["", "a", "_a", "0", "_0", "a_0a"]
633633
return [
634634
f"{prefix}{suffix}" for prefix, suffix in itertools.product(prefixes, suffixes)
635635
]
636636

637637

638-
_TIME_NAMES = _make_names(
638+
_TIME_NAMES = ["t"] + _make_names(
639639
[
640640
"time",
641641
"min",
@@ -648,6 +648,7 @@ def _make_names(prefixes):
648648
)
649649
_VERTICAL_NAMES = _make_names(
650650
[
651+
"z",
651652
"lv_1",
652653
"bottom_top",
653654
"sigma",
@@ -659,13 +660,15 @@ def _make_names(prefixes):
659660
"isobaric",
660661
"pressure",
661662
"isotherm",
663+
"gdep",
664+
"nav_lev",
662665
]
663666
)
664667
_X_NAMES = _make_names(["x"])
665668
_Y_NAMES = _make_names(["y"])
666669
_Z_NAMES = _VERTICAL_NAMES
667-
_LATITUDE_NAMES = _make_names(["lat", "latitude"])
668-
_LONGITUDE_NAMES = _make_names(["lon", "longitude"])
670+
_LATITUDE_NAMES = _make_names(["lat", "latitude", "gphi", "nav_lat"])
671+
_LONGITUDE_NAMES = _make_names(["lon", "longitude", "glam", "nav_lon"])
669672

670673

671674
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)