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 rsr plotting to allow for similar (overlapping) bands #240

Merged
merged 3 commits into from
Dec 18, 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
34 changes: 19 additions & 15 deletions bin/composite_rsr_plot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016-2022 Pytroll developers
# Copyright (c) 2016-2022, 2024 Pytroll developers
#
#
# This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -103,6 +103,11 @@ def get_arguments():
help="The wavelength range for the plot",
default=[None, None], type=float)

parser.add_argument("--exclude_bandnames", nargs='*',
default=[],
required=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required is not necessary here. The default is False. Actually type=str is also not necessary as str is the default type.

help="Sensor band names to exclude from the plot", type=str)

return parser.parse_args()


Expand Down Expand Up @@ -139,6 +144,8 @@ def get_arguments():
elif args.wavelength:
req_wvl = args.wavelength

excluded_bandnames = args.exclude_bandnames

figscale = 1.0
if wvlmin:
figscale = (wvlmax - wvlmin) / 4.
Expand Down Expand Up @@ -184,24 +191,21 @@ def get_arguments():

else:
wvlx = wvlmin
prev_band = None
prev_bands = []
while wvlx < wvlmax:
bands = rsr.get_bandname_from_wavelength(wvlx, wavel_res, multiple_bands=True)

if isinstance(bands, list):
b__ = bands[0]
for b in bands[1:]:
LOG.warning("Skipping band %s", str(b))
else:
b__ = bands

wvlx = wvlx + wavel_res / 5.
if not b__:
if not bands:
continue
if b__ != prev_band:
plt = plot_band(plt, b__, rsr,
platform_name_in_legend=(not no_platform_name_in_legend))
prev_band = b__

if not isinstance(bands, list):
bands = [bands]

for b__ in bands:
if b__ not in excluded_bandnames and b__ not in prev_bands:
plt = plot_band(plt, b__, rsr,
platform_name_in_legend=(not no_platform_name_in_legend))
prev_bands.append(b__)

if not something2plot:
LOG.error("Nothing to plot!")
Expand Down
Loading