Skip to content

Commit

Permalink
FIX: Minor fix in plot_maxcappi (#1639)
Browse files Browse the repository at this point in the history
* FIX: Minor fix in plot_maxcappi

* Update pyart/graph/max_cappi.py

Co-authored-by: Zach Sherman <[email protected]>

* FIX: Remove un-necessary commented lines

---------

Co-authored-by: Zach Sherman <[email protected]>
  • Loading branch information
syedhamidali and zssherman authored Sep 3, 2024
1 parent 151e69e commit 361b546
Showing 1 changed file with 21 additions and 3 deletions.
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

0 comments on commit 361b546

Please sign in to comment.