Skip to content

Commit 505bd03

Browse files
committed
Upgrade dependency for testing, fix nexrad S3 archive, cloud option not mandatory
1 parent e4072fa commit 505bd03

7 files changed

Lines changed: 19 additions & 14 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ classifiers = [
2525
"Programming Language :: Python",
2626
"Programming Language :: Python :: 3",
2727
"Programming Language :: Python :: 3 :: Only",
28-
"Programming Language :: Python :: 3.10",
2928
"Programming Language :: Python :: 3.11",
3029
"Programming Language :: Python :: 3.12",
3130
"Programming Language :: Python :: 3.13",
@@ -46,7 +45,7 @@ dependencies = [
4645
"pandas",
4746
"tqdm",
4847
]
49-
requires-python = ">=3.10"
48+
requires-python = ">=3.11"
5049
dynamic = ["version"]
5150

5251
[tool.setuptools]
@@ -60,6 +59,7 @@ write_to = "radar_api/_version.py"
6059

6160
[project.optional-dependencies]
6261
dev = ["pre-commit", "loghub",
62+
"xarray", "xradar",
6363
"black[jupyter]", "blackdoc", "codespell", "ruff",
6464
"pytest", "pytest-cov", "pytest-mock", "pytest-check", "pytest-sugar",
6565
"pytest-watcher", "deepdiff",

radar_api/etc/network/NEXRAD.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
network: "NEXRAD"
22
description: "NOAA NEXRAD radar network"
33
public_data: True
4-
cloud_directory_pattern: "s3://noaa-nexrad-level2/{time:%Y}/{time:%m}/{time:%d}/{radar:s}"
4+
cloud_directory_pattern: "s3://unidata-nexrad-level2/{time:%Y}/{time:%m}/{time:%d}/{radar:s}"
55
local_directory_pattern: "{base_dir}/NEXRAD/{time:%Y}/{time:%m}/{time:%d}/{time:%H}/{radar:s}"
66
filename_patterns:
77
- "{radar_acronym:4s}{start_time:%Y%m%d_%H%M%S}_V0{version:1s}"

radar_api/io.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ def get_directory_pattern(protocol, network):
228228
directory_pattern = get_network_info(network)["cloud_directory_pattern"]
229229
else:
230230
directory_pattern = get_network_info(network)["local_directory_pattern"]
231+
if directory_pattern is None:
232+
raise NotImplementedError(f"protocol {protocol} is not implemented for {network}.")
231233
return directory_pattern
232234

233235

radar_api/search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_pattern_shortest_time_component(directory_pattern):
5656
if any(s in directory_pattern for s in ["{time:%m}", "{time:%b}", "{time:%B}"]):
5757
return "MS"
5858
if any(s in directory_pattern for s in ["{time:%Y}", "{time:%y}"]):
59-
return "Y" # Y-DEC
59+
return "YE" # Y-DEC
6060
raise NotImplementedError
6161

6262

@@ -67,7 +67,7 @@ def get_list_timesteps(start_time, end_time, freq):
6767
end = pd.to_datetime(end_time)
6868

6969
# Round start_time and end_time to the frequency resolution
70-
# "Y" --> set month and days to 01 and zero out hour, minute, second
70+
# "YE" --> set month and days to 01 and zero out hour, minute, second
7171
# "MS" --> set day to 01 and zero out hour, minute, second
7272
# "D" -> zero out hour, minute, second
7373
# "h" -> zero out minute, second
@@ -87,7 +87,7 @@ def get_list_timesteps(start_time, end_time, freq):
8787
new_start_year = start.year
8888
start = pd.to_datetime(datetime.datetime(new_start_year, new_start_month, 1))
8989
end = pd.to_datetime(datetime.datetime(end.year, end.month, 1))
90-
elif freq == "Y": # Y-DEC
90+
elif freq == "YE": # Y-DEC
9191
start = pd.to_datetime(datetime.datetime(start.year - 1, 1, 1))
9292
end = pd.to_datetime(datetime.datetime(end.year, 12, 31))
9393
else:

radar_api/tests/test_io.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ def test_get_network_filename_patterns(network):
175175
@pytest.mark.parametrize("network", NETWORKS)
176176
def test_get_directory_pattern_cloud(network):
177177
"""Test get_directory_pattern for a cloud protocol (e.g. s3)."""
178-
pattern = get_directory_pattern(protocol="s3", network=network)
178+
try:
179+
pattern = get_directory_pattern(protocol="s3", network=network)
180+
except NotImplementedError:
181+
pytest.skip(f"protocol s3 is not implemented for network {network}")
179182
assert isinstance(pattern, str)
180183

181184

radar_api/tests/test_readers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
def test_get_simplecache_file():
4444
"""Test file simple caching with fsspec."""
45-
filepath = "s3://noaa-nexrad-level2/2023/01/01/KABR/KABR20230101_000142_V06"
45+
filepath = "s3://unidata-nexrad-level2/2023/01/01/KABR/KABR20230101_000142_V06"
4646
file = get_simplecache_file(filepath)
4747
assert isinstance(file, str)
4848

radar_api/tests/test_search.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_year_component(self):
6969
"""Test get_pattern_shortest_time_component returns 'Y' for pattern with {time:%Y}."""
7070
pattern = "some_path/{time:%Y}"
7171
freq = get_pattern_shortest_time_component(pattern)
72-
assert freq == "Y"
72+
assert freq == "YE"
7373

7474
def test_not_implemented(self):
7575
"""Test get_pattern_shortest_time_component raises NotImplementedError if unknown format."""
@@ -145,7 +145,7 @@ def test_freq_y(self):
145145
"""Test get_list_timesteps with freq='Y' (yearly)."""
146146
start_time = "2024-06-10"
147147
end_time = "2026-02-01"
148-
times = get_list_timesteps(start_time, end_time, freq="Y")
148+
times = get_list_timesteps(start_time, end_time, freq="YE")
149149
# freq='Y' (YE-DEC) means shift start year back by 1 => 2023,
150150
assert list(times) == [
151151
pd.Timestamp("2023-12-31"),
@@ -170,7 +170,7 @@ def test_directories_s3_day(self):
170170
protocol = "s3"
171171
base_dir = None
172172

173-
# directory_pattern for protocol="s3" is 's3://noaa-nexrad-level2/{time:%Y}/{time:%m}/{time:%d}/{radar:s}'
173+
# directory_pattern for protocol="s3" is 's3://unidata-nexrad-level2/{time:%Y}/{time:%m}/{time:%d}/{radar:s}'
174174
# => The last time component is {time:%d} => freq='D'
175175
# => We'll generate times for 2023-06-30, 2023-07-01, 2023-07-02
176176

@@ -184,9 +184,9 @@ def test_directories_s3_day(self):
184184
)
185185
expected = [
186186
# Because the function does start_time - 1 day, then floors to day ...
187-
"s3://noaa-nexrad-level2/2023/06/30/KFSD",
188-
"s3://noaa-nexrad-level2/2023/07/01/KFSD",
189-
"s3://noaa-nexrad-level2/2023/07/02/KFSD",
187+
"s3://unidata-nexrad-level2/2023/06/30/KFSD",
188+
"s3://unidata-nexrad-level2/2023/07/01/KFSD",
189+
"s3://unidata-nexrad-level2/2023/07/02/KFSD",
190190
]
191191
assert paths == expected
192192

0 commit comments

Comments
 (0)