Skip to content

Commit 1019075

Browse files
authored
Merge branch 'main' into pre-commit-ci-update-config
2 parents 6dc516b + fc665c2 commit 1019075

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

pipelines/meteorologia/radar/mendanha/flows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
radar_2d = remap_data(radar, RADAR_PRODUCT_LIST, grid_shape, grid_limits)
111111

112112
# Create visualizations
113-
formatted_time, filename_time = get_and_format_time(radar_files)
113+
formatted_time, filename_time = get_and_format_time(radar)
114114
cbar_title = get_colorbar_title(RADAR_PRODUCT_LIST[0])
115115
fig = create_visualization_no_background(
116116
radar_2d, radar_product=RADAR_PRODUCT_LIST[0], cbar_title=cbar_title, title=formatted_time

pipelines/meteorologia/radar/mendanha/tasks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,10 @@ def combine_radar_files(radar_files: list) -> pyart.core.Radar:
168168

169169

170170
@task(nout=2, max_retries=3, retry_delay=timedelta(seconds=3))
171-
def get_and_format_time(radar_files: list) -> Union[str, str]:
171+
def get_and_format_time(radar: pyart.core.Radar) -> Union[str, str]:
172172
"""
173-
Get time from first file and convert it to São Paulo timezone
173+
Get time from radar file and convert it to São Paulo timezone
174174
"""
175-
radar = pyart.aux_io.read_odim_h5(radar_files[0])
176175
utc_time_str = radar.time["units"].split(" ")[-1]
177176
utc_time = pendulum.parse(utc_time_str, tz="UTC")
178177
br_time = utc_time.in_timezone("America/Sao_Paulo")

pipelines/meteorologia/radar/mendanha/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import re
1111
import shutil
1212
from datetime import datetime
13+
from pathlib import Path
1314
from typing import Union
1415

1516
import matplotlib.colors as mcolors
@@ -29,7 +30,7 @@ def extract_timestamp(filename) -> datetime:
2930
)
3031

3132

32-
def open_radar_file(file_path) -> Union[pyart.core.Radar, None]:
33+
def open_radar_file(file_path: Union[str, Path]) -> Union[pyart.core.Radar, None]:
3334
"""
3435
Open radar file with h5 extension.
3536
@@ -38,14 +39,15 @@ def open_radar_file(file_path) -> Union[pyart.core.Radar, None]:
3839
3940
Parameters
4041
----------
41-
file_path : str
42+
file_path : Union[str, Path]
4243
Path to the file.
4344
4445
Returns
4546
-------
4647
radar : pyart.core.Radar
4748
Radar object.
4849
"""
50+
file_path = str(file_path)
4951
if file_path.endswith(".gz"):
5052
uncompressed_file_path = file_path[:-3]
5153
with gzip.open(file_path, "rb") as f_in:

0 commit comments

Comments
 (0)