-
Notifications
You must be signed in to change notification settings - Fork 38
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
HLA-1419: Removal of warnings for photometry_utils.py log of zero of negative number #1956
Changes from all commits
90ceefc
10a3a36
79c5a5e
cf3df9a
6f930ab
73011e2
bc0032f
1b8e2f7
7d1ad98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,9 @@ def iraf_style_photometry(phot_apertures, bg_apertures, data, photflam, photplam | |
if math.isclose(photflam, 0.0, abs_tol=constants.TOLERANCE): | ||
mag_err = mag | ||
else: | ||
mag_err = 1.0857 * flux_error / flux | ||
# ignores warnings from log10 of zeros and negative values | ||
with np.errstate(divide='ignore', invalid='ignore'): | ||
mag_err = 1.0857 * flux_error / flux | ||
# Set magnitude errors to infinity if flux is negative | ||
mag_err[np.logical_not(flux>0)]=np.inf | ||
|
||
|
@@ -235,9 +237,13 @@ def convert_flux_to_abmag(in_flux, photflam, photplam): | |
f_lambda = in_flux * photflam | ||
|
||
# Convert f_lambda to STMAG | ||
stmag = -2.5 * np.log10(f_lambda) - 21.10 | ||
# ignores warnings from log10 of zeros and negative values | ||
with np.errstate(divide='ignore', invalid='ignore'): | ||
stmag = -2.5 * np.log10(f_lambda) - 21.10 | ||
|
||
# Convert STMAG to ABMAG | ||
abmag = stmag - 5.0 * np.log10(photplam) + 18.6921 | ||
# ignores warnings from log10 of zeros and negative values | ||
with np.errstate(divide='ignore', invalid='ignore'): | ||
abmag = stmag - 5.0 * np.log10(photplam) + 18.6921 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines 241 and 246 introduce benign changes which eliminate lots of messages in the logs without changing the current computations. In this sense, the changes are fine. However, the Jira ticket was meant to investigate how these computations can be better handled starting from the routine which calls compute_flux_to_abmag. Should the block of code starting on Line 231 be expanded to encompass handling the flux array? If issues are handled in the initial block of code we never drop down into the log10 computations. In the test dataset was photplam zero or negative? It is a pivot wavelength, so I am curious. |
||
|
||
return abmag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the flux here is the troublesome variable as there is no log computation. What is the value of mag_err here after the divide by zero?