Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Minor fix in plot_maxcappi #1639

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions pyart/graph/max_cappi.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,32 @@ def get_coord_or_attr(ds, coord_name, attr_name):
labelbottom=False,
)

# Retrieve instrument name
instrument_name = ds.attrs.get("instrument_name", "N/A")[:4]
# Initialize an empty list to store the processed radar names
full_title = []

# Check if radar_name is a list (or list-like) or a simple string
if isinstance(ds.attrs["radar_name"], list):
# Iterate over each radar name in the list
for name in ds.attrs["radar_name"]:
# Decode if it's a byte string and take the first 4 characters
if isinstance(name, bytes):
site_title = name.decode("utf-8")[:4]
else:
site_title = name[:4]
full_title.append(site_title)
else:
# Handle the case where radar_name is a single string
site_title = ds.attrs["radar_name"][:4]
full_title.append(site_title)

# Join the processed radar names into a single string with commas separating them
formatted_title = ", ".join(full_title)

# Center-align text in the corner box
plt.text(
0.5,
0.90,
f"Site: {instrument_name}",
f"{formatted_title}",
size=13,
weight="bold",
ha="center",
Expand Down