Skip to content

Commit

Permalink
Merge pull request #363 from nasa-fornax/raen/spectra_generator/warnings
Browse files Browse the repository at this point in the history
Ignore 'divide by zero' warning in error calculations
  • Loading branch information
bsipocz authored Dec 11, 2024
2 parents 53f71e2 + 5dd5a84 commit 83ab5ea
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions spectroscopy/code_src/desi_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,21 @@ def DESIBOSS_get_spec(sample_table, search_radius_arcsec):
idx_closest = sel[np.where(result_tab["separation"][sel] == np.nanmin(
result_tab["separation"][sel]))[0][0]]

# Inverse variances may be zero, resulting in infinite error.
# We'll leave these in and ignore the "divide by zero" warning.
with np.errstate(divide='ignore'):
err = np.sqrt(1/specs[idx_closest].uncertainty.quantity)

# create MultiIndex Object
dfsingle = pd.DataFrame(dict(wave=[specs[idx_closest].spectral_axis],
flux=[specs[idx_closest].flux],
err=[
np.sqrt(1/specs[idx_closest].uncertainty.quantity)],
label=[stab["label"]],
objectid=[stab["objectid"]],
mission=[dr],
instrument=[dr],
filter=["optical"],
)).set_index(["objectid", "label", "filter", "mission"])
err=[err],
label=[stab["label"]],
objectid=[stab["objectid"]],
mission=[dr],
instrument=[dr],
filter=["optical"],
)).set_index(["objectid", "label", "filter", "mission"])
df_spec.append(dfsingle)

return df_spec

0 comments on commit 83ab5ea

Please sign in to comment.