From 3e94cee959f17d99ba59fdd9a6a6c52a96c4d035 Mon Sep 17 00:00:00 2001 From: "Karl D. Gordon" Date: Wed, 26 Jan 2022 11:21:39 -0500 Subject: [PATCH] usability updates --- measure_extinction/plotting/plot_ext.py | 2 +- measure_extinction/plotting/plot_spec.py | 6 +++++- measure_extinction/stardata.py | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/measure_extinction/plotting/plot_ext.py b/measure_extinction/plotting/plot_ext.py index b9ddc54..f18e521 100755 --- a/measure_extinction/plotting/plot_ext.py +++ b/measure_extinction/plotting/plot_ext.py @@ -707,7 +707,7 @@ def plot_extinction( fig, ax = plt.subplots(figsize=(10, 7)) # read in extinction curve data for this star - if "_ext.fits" not in starpair: + if ".fits" not in starpair: fname = "%s%s_ext.fits" % (path, starpair.lower()) else: fname = starpair diff --git a/measure_extinction/plotting/plot_spec.py b/measure_extinction/plotting/plot_spec.py index b726ad1..298a11c 100755 --- a/measure_extinction/plotting/plot_spec.py +++ b/measure_extinction/plotting/plot_spec.py @@ -398,7 +398,11 @@ def plot_spectrum( fig, ax = plt.subplots(figsize=(13, 10)) # read in and plot all bands and spectra for this star - starobs = StarData("%s.dat" % star, path=path, use_corfac=True, deredden=deredden) + if ".dat" not in star: + fname = f"{star}.dat" + else: + fname = star + starobs = StarData(fname, path=path, use_corfac=True, deredden=deredden) if norm_range is not None: norm_range = norm_range * u.micron # rebin spectra if desired diff --git a/measure_extinction/stardata.py b/measure_extinction/stardata.py index 698e42e..d4ebf6f 100644 --- a/measure_extinction/stardata.py +++ b/measure_extinction/stardata.py @@ -842,10 +842,14 @@ def rebin_constres(self, waverange, resolution): # rebin using a weighted average owaves = self.waves.to(u.micron).value for k in range(n_waves): + # check for zero uncs includes to avoid divide by zero + # errors when the flux uncertainty of a real measurement + # is zero for any reason (indxs,) = np.where( (owaves >= full_wave_min[k]) & (owaves < full_wave_max[k]) & (self.npts > 0.0) + & (self.uncs > 0.0) ) if len(indxs) > 0: weights = 1.0 / np.square(self.uncs[indxs].value)