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
Rewrite np.percentile section to handle units for AstroPy 3, 4. #116
Conversation
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.
Looks great. Nice clarification as well.
|
||
# In AstroPy 3, numpy.percentitle of an array with quantities | ||
# (incorrectly) returns a unitless number | ||
# In AstroPy 4, numpy.percentitle of an array with Quantities |
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.
I think it's Astropy4+numpy >=1.17.
# In AstroPy 3, numpy.percentitle of an array with quantities | ||
# (incorrectly) returns a unitless number | ||
# In AstroPy 4, numpy.percentitle of an array with Quantities | ||
# correct returns a number with the same units as the input array. |
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.
correct -> correctly
# 1. Extract the array in marcsec and convert to a value. | ||
# 2. Calculate the numpy.percentitle of this unitless array | ||
# 3. Multiply that result by u.marcsec to get the right units. | ||
rmsDistMas = amx.extras['rmsDistMas'].quantity.to(u.marcsec).value, |
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.
There's a comma at the end of this line that should not be there.
I also needed to apply this patch: diff --git a/python/lsst/validate/drp/calcsrd/pa2.py b/python/lsst/validate/drp/calcsrd/pa2.py
index 6dd6c0a..8b98c47 100644
--- a/python/lsst/validate/drp/calcsrd/pa2.py
+++ b/python/lsst/validate/drp/calcsrd/pa2.py
@@ -59,5 +59,5 @@ def measurePA2(metric, pa1, pf1_thresh):
magDiffs = pa1.extras['magDiff'].quantity[0, :]
pf1Percentile = 100.*u.percent - pf1_thresh
- return Measurement(metric, np.percentile(np.abs(magDiffs), pf1Percentile.value) * magDiffs.unit,
+ return Measurement(metric, np.percentile(np.abs(magDiffs.value), pf1Percentile.value) * magDiffs.unit,
extras=datums) |
The one other use of I think that one is fine as is. |
e6d0cd3
to
b33ae6f
Compare
No description provided.