Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore 'divide by zero' warning in error calculations #363

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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