Skip to content

Commit

Permalink
FIX: Minor fix in plot_maxcappi
Browse files Browse the repository at this point in the history
  • Loading branch information
syedhamidali committed Aug 30, 2024
1 parent 4321501 commit 922b775
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions pyart/graph/max_cappi.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,33 @@ def get_coord_or_attr(ds, coord_name, attr_name):
)

# Retrieve instrument name
instrument_name = ds.attrs.get("instrument_name", "N/A")[:4]
# 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

0 comments on commit 922b775

Please sign in to comment.