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 error checking colormap in geoviewer.py #510

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions bin/geoviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,16 @@ def main(test_args: Sequence[str] = None) -> None:
vmax = None

# color map
# Get the list of existing color maps, including reversed maps
mpl_cmap_list = list(plt.cm.datad.keys())
mpl_cmap_list.extend([cmap + "_r" for cmap in mpl_cmap_list])

if args.cmap == "default":
cmap = plt.rcParams["image.cmap"]
elif args.cmap in plt.cm.datad.keys():
elif args.cmap in mpl_cmap_list:
cmap = args.cmap
else:
raise ValueError("Wrong cmap, must be in: {}".format(",".join(str(elem) for elem in plt.cm.datad.keys())))
raise ValueError("Wrong cmap, must be in: {}".format(",".join(str(elem) for elem in mpl_cmap_list)))

# Figsize
if args.figsize == "default":
Expand Down
1 change: 1 addition & 0 deletions tests/test_geoviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
(
(),
("-cmap", "Reds"),
("-cmap", "Reds_r"),
("-vmin", "-10", "-vmax", "10"),
("-vmin", "5%", "-vmax", "95%"),
("-band", "1"),
Expand Down
Loading