Skip to content

Commit

Permalink
Minor comment rewrites.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmwv committed Feb 11, 2020
1 parent 7d829db commit b33ae6f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions python/lsst/validate/drp/calcsrd/adx.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ def measureADx(metric, amx, afx_spec):
# We subtract AFx from 100. So AFx = 10 becomes threshold = 90.
threshold = 100 - afx_spec.threshold.value

# In AstroPy 3, numpy.percentitle of an array with quantities
# 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.
# In AstroPy 4 + numpy >= 1.17,
# numpy.percentitle of an array with Quantities
# correctly returns a number with the same units as the input array.
# To be compatible with both Astropy 3.2 and Astropy 4, we:
# 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,
rmsDistMas = amx.extras['rmsDistMas'].quantity.to(u.marcsec).value
afxAtPercentile = np.percentile(rmsDistMas, threshold)
afxAtPercentile *= u.marcsec
quantity = afxAtPercentile - amx.quantity
Expand Down

0 comments on commit b33ae6f

Please sign in to comment.