Skip to content

Commit 3ca7fb1

Browse files
committed
Fix plotting for cases when spectral_snratio is not defined
1 parent e0865f5 commit 3ca7fb1

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

sourcespec/ssp_build_spectra.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ def _check_spectral_sn_ratio(config, spec, specnoise):
516516
weight = _build_weight_from_noise(config, spec, specnoise)
517517
# if no noise window is available, snratio is not computed
518518
if weight.snratio is None:
519+
spec.stats.spectral_snratio = None
519520
return
520521
if config.spectral_sn_freq_range is not None:
521522
sn_fmin, sn_fmax = config.spectral_sn_freq_range

sourcespec/ssp_plot_spectra.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ def _add_legend(config, plot_params, spec_st, specnoise_st):
438438

439439
def _snratio_text(spec, ax, color, path_effects):
440440
global snratio_text_ypos
441+
if spec.stats.spectral_snratio is None:
442+
return
441443
snratio_text = f'S/N: {spec.stats.spectral_snratio:.1f}'
442444
ax.text(
443445
0.95, snratio_text_ypos, snratio_text, ha='right', va='top',

0 commit comments

Comments
 (0)