Skip to content

Commit 8718bdd

Browse files
committed
Use nanmin/nanmax instead of min/max
1 parent a6ce13b commit 8718bdd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sourcespec/ssp_build_spectra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def _build_weight_from_ratio(spec, specnoise, smooth_width_decades):
495495
weight.data = np.log10(weight.data)
496496
# Weight spectrum is smoothed once more
497497
_smooth_spectrum(weight, smooth_width_decades)
498-
weight.data /= np.max(weight.data)
498+
weight.data /= np.nanmax(weight.data)
499499
# slightly taper weight at low frequencies, to avoid overestimating
500500
# weight at low frequencies, in cases where noise is underestimated
501501
cosine_taper(
@@ -522,7 +522,7 @@ def _build_weight_from_noise(config, spec, specnoise):
522522
spec, specnoise, config.spectral_smooth_width_decades)
523523
# interpolate to log-frequencies
524524
weight.make_logspaced_from_linear()
525-
weight.data_logspaced /= np.max(weight.data_logspaced)
525+
weight.data_logspaced /= np.nanmax(weight.data_logspaced)
526526
# Make sure weight is positive
527527
weight.data_logspaced[weight.data_logspaced <= 0] = 0.001
528528
return weight

sourcespec/ssp_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
# MISC ------------------------------------------------------------------------
2626
def spec_minmax(amp, freq, amp_minmax=None, freq_minmax=None):
2727
"""Get minimum and maximum values of spectral amplitude and frequency."""
28-
amp_min = amp.min()
29-
amp_max = amp.max()
28+
amp_min = np.nanmin(amp)
29+
amp_max = np.nanmax(amp)
3030
if amp_minmax is None:
3131
amp_minmax = [amp_min, amp_max]
3232
else:

0 commit comments

Comments
 (0)