Skip to content

Commit

Permalink
Fix plotting for cases when spectral_snratio is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodsf committed Mar 30, 2023
1 parent ed5e251 commit a9d989e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions sourcespec/ssp_build_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ def _check_spectral_sn_ratio(config, spec, specnoise):
weight = _build_weight_from_noise(config, spec, specnoise)
# if no noise window is available, snratio is not computed
if weight.snratio is None:
spec.stats.spectral_snratio = None
return
if config.spectral_sn_freq_range is not None:
sn_fmin, sn_fmax = config.spectral_sn_freq_range
Expand Down
2 changes: 2 additions & 0 deletions sourcespec/ssp_plot_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ def _add_legend(config, plot_params, spec_st, specnoise_st):

def _snratio_text(spec, ax, color, path_effects):
global snratio_text_ypos
if spec.stats.spectral_snratio is None:
return
snratio_text = f'S/N: {spec.stats.spectral_snratio:.1f}'
ax.text(
0.95, snratio_text_ypos, snratio_text, ha='right', va='top',
Expand Down

0 comments on commit a9d989e

Please sign in to comment.