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

DM-34168: Use only deblended primary sources for TEx metrics #130

Merged
merged 2 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion python/lsst/faro/utils/tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,17 @@ def calculateTEx(data: List[CalibratedCatalog], config):
)

# Filtering should be pulled out into a separate function for standard quality selections
# and only use sources that are single sources.
# This is the same as `isPrimary`, except that it also includes
# sources that are outside of the inner tract/patch regions.
snrMin = 50
selection = (
(catalog["base_ClassificationExtendedness_value"] < 0.5)
& (
(catalog["slot_PsfFlux_instFlux"] / catalog["slot_PsfFlux_instFluxErr"])
> snrMin
)
& (catalog["deblend_nChild"] == 0)
& catalog["detect_isDeblendedSource"]
)

nMinSources = 50
Expand Down
3 changes: 2 additions & 1 deletion tests/test_ellipKPM.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import yaml
import os
import logging
import numpy as np

from lsst.afw.table import SimpleCatalog
from lsst.faro.measurement import TExTask
Expand Down Expand Up @@ -74,7 +75,7 @@ def test_te1(self):
result = task.run('TE1', {'i': [CalibratedCatalog(catalog), ]})
log.debug('result: ', result)
log.debug('expected: ', expected)
self.assertAlmostEqual(result.measurement, expected, places=10)
np.testing.assert_almost_equal(result.measurement.quantity, expected.quantity, decimal=5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason to switch to numpy testing here? I would have thought it made sense for arrays, but that doesn't seem to be the case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, you could add the reason in the body of the commit message? https://developer.lsst.io/work/flow.html?highlight=commit#writing-commit-message-body-content

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. FYI it's because assertAlmostEqual doesn't actually work for lsst.verify.measurement.Measurementobjects (since it doesn't have subtraction defined). Unfortunately assertAlmostEqual doesn't work with astropy.quantity.Quantity values either, so I had to both extract the quantity and use numpy's almost equal. 😞



if __name__ == "__main__":
Expand Down