Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 10, 2024
2 parents 6dc516b + fc665c2 commit 1019075
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pipelines/meteorologia/radar/mendanha/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
radar_2d = remap_data(radar, RADAR_PRODUCT_LIST, grid_shape, grid_limits)

# Create visualizations
formatted_time, filename_time = get_and_format_time(radar_files)
formatted_time, filename_time = get_and_format_time(radar)
cbar_title = get_colorbar_title(RADAR_PRODUCT_LIST[0])
fig = create_visualization_no_background(
radar_2d, radar_product=RADAR_PRODUCT_LIST[0], cbar_title=cbar_title, title=formatted_time
Expand Down
5 changes: 2 additions & 3 deletions pipelines/meteorologia/radar/mendanha/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,10 @@ def combine_radar_files(radar_files: list) -> pyart.core.Radar:


@task(nout=2, max_retries=3, retry_delay=timedelta(seconds=3))
def get_and_format_time(radar_files: list) -> Union[str, str]:
def get_and_format_time(radar: pyart.core.Radar) -> Union[str, str]:
"""
Get time from first file and convert it to São Paulo timezone
Get time from radar file and convert it to São Paulo timezone
"""
radar = pyart.aux_io.read_odim_h5(radar_files[0])
utc_time_str = radar.time["units"].split(" ")[-1]
utc_time = pendulum.parse(utc_time_str, tz="UTC")
br_time = utc_time.in_timezone("America/Sao_Paulo")
Expand Down
6 changes: 4 additions & 2 deletions pipelines/meteorologia/radar/mendanha/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
import shutil
from datetime import datetime
from pathlib import Path
from typing import Union

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


def open_radar_file(file_path) -> Union[pyart.core.Radar, None]:
def open_radar_file(file_path: Union[str, Path]) -> Union[pyart.core.Radar, None]:
"""
Open radar file with h5 extension.
Expand All @@ -38,14 +39,15 @@ def open_radar_file(file_path) -> Union[pyart.core.Radar, None]:
Parameters
----------
file_path : str
file_path : Union[str, Path]
Path to the file.
Returns
-------
radar : pyart.core.Radar
Radar object.
"""
file_path = str(file_path)
if file_path.endswith(".gz"):
uncompressed_file_path = file_path[:-3]
with gzip.open(file_path, "rb") as f_in:
Expand Down

0 comments on commit 1019075

Please sign in to comment.