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

Tickets/DM-8645: Implement new matcherSourceSelector object for use in matchOptimisticB code #56

Merged
merged 1 commit into from Jan 18, 2017

Conversation

morriscb
Copy link
Contributor

Implemented new matcherSourceSelctor for use in meas_astrom with matchOptimisticB.

@parejkoj
Copy link
Contributor

Where's the unittest? It doesn't appear to have come along with these changes.

Copy link
Contributor

@parejkoj parejkoj left a comment

Choose a reason for hiding this comment

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

Several comments about cleaning up the docstrings, a concern about not checking the "bad" flags, and you need to add the unittests. Also, please rebase flatten several of these commits together.

Separately, I think we can probably make astrometrySourceSelector a child class of matcherSourceSelector (they share quite a few methods).

"""
!Select sources that are useful for astrometry.

Good astrometry sources have high signal/noise, are non-blended, and
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to change this docstring, since it's still verbatim the one from astrometrySourceSelector. Might be worth being more explicit about the differences between this and astrometrySS (in both of their docstrings). Also please take out all the preceding ! and reformat things as numpydoc, instead of doxygen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As stated in the other comment I'm not aware of the new docstring standard. This is copied verbatim from astrometrySourceSelector. I can re-do it if absolutely necessary. I have already edited the doc strings and will push the changes shortly.


def selectSources(self, sourceCat, matches=None):
"""
!Return a catalog of sources: a subset of sourceCat.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please reformat this as numpydoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was was as is and is straight from the astrometrySourceSelector. Not sure how to make it a numpydoc and if we would need to change the base class as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I guess we'll hold off on reformatting as numpydoc (I did astrometrySS before that RFC had been fully settled). New python code is allowed (an I believe recommended) to use numpydoc instead of doxygen.

self._getSchemaKeys(sourceCat.schema)

if sourceCat.isContiguous():
good = self._isUsable_vector(sourceCat)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you still want to remove things with the "bad" flag here. Do you really want cosmics, interpolated pixels and stuff on the edge of a chip?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do want interpolated pixels and edge of chip things. Which specific bad flag tests for cosmics? I can add that if we want. I'm mostly just following the tests verbatim from the old SourceInfo class in matchOptimisticB.py which does not test for those things.

Copy link
Contributor

Choose a reason for hiding this comment

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

The base class I think already defines all the ones you want in the badFlags config parameter. Cosmics are crCenter, I think.

I really do think you should consider what the "correct" source selection criteria are, instead of just reproducing SourceInfo: there's really no guarantee it was fully thought out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't this more of a new ticket then? As in implementing the source selector framework first and then testing a new selection criteria later? Wouldn't that make it easier to track the changes to the code? Or am I over thinking this?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a fair point. File the ticket(s) about figuring out what "correct" source selection for matcherSS would mean, and link them from 8645.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This issue has been filed as a ticket here: https://jira.lsstcorp.org/browse/DM-8987

@morriscb
Copy link
Contributor Author

Added unittest for matcherSourceSelector to the ticket after it was erroneously not added. Have not yet modified the doc strings as these are the same as currently implemented in the base source selector and astrometrySourceSelector. Perhaps we should open a new ticket to modify all of these?

Also I have not yet added in isBad flags as none of these flags were used in the original SourceInfo for matchOptimisticB which matcherSourceSelector is based on. Can add these in if completely necessary.

Copy link
Contributor

@parejkoj parejkoj left a comment

Choose a reason for hiding this comment

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

More concerns about badFlags in the tests

import lsst.utils.tests


badFlags = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Should have a comment here describing what these flags are for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey here's the current text I've written. Let me know if this is what you want and I'll commit it.

"

badFlags are flags that, if the bad flag is set the objecct should be

imediately thrown out. This is as opposed to combinations of flags

signifying good or bad data. Such flags should then be a part of the

isGood test

"

Copy link
Contributor

Choose a reason for hiding this comment

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

Such bold, much wow...

That's probably fine? Though those bad flags aren't used by matcherSS right now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is correct. Again, this is so that it is identical to the SourceInfo test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forget what we decided, was I going to put this test in to matcherSourceSelector or into BaseSourceSelector?

Copy link
Contributor

Choose a reason for hiding this comment

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

This block is being removed from testMatcherSS, and there is no "testBaseSS" (can't be: its abstract). So, the above text could go into testAstrometrySS.

schema.addField(flag, type="Flag")

self.src = afwTable.SourceCatalog(schema)
self.sourceSelector = sourceSelector.sourceSelectorRegistry['matcher']()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here you can just construct the matcherSourceSelector directly (unless I'm missing something). On the other hand, this does test that you correctly put it in the registry, so...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can leave it as is if that a necessary test, that is checking to see that it is properly registered. Again, if we change this we will should also modify the tests for astrometrySourceSelector as it is doing a similar thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

All fair points.

self.assertIn(x, result.sourceCat['id'])

def testSelectSources_bad(self):
for i, flag in enumerate(badFlags):
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't matcherSourceSelector ignore badFlags? So how does this test pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of the badFlags are redundant with tests preformed in the isGood test. This is true of the astrometrySelector as well. This is why the is badFlag test still passes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Its not redundancy that I'm worried about: if the flag is set and the test expects a failure, how can this test pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it will still fail isGood which it is awesome testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we talked about it: you can delete the _bad test, since you're not using bad flags at all. The two slot flags are really part of testing the negation of isGood (I realized now that testAstrometrySS does this in an unfortunate way). Once you figure out whether matcherSS needs bad flags, you can add a test back in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also I believe we wanted to remove this test. Is this the case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes: see my comment just above.

matcherSourceSelector.py impliments the isUsable criteria from SourceInfo in matchOptimistB.py. It is mostly a clone of astrometrySourceSelector.py with less stringent tests.
@morriscb morriscb changed the title Tickets/dm 8645 Tickets/DM-8645 {{Implement new matcherSourceSelector object for use in matchOptimisticB code}} Jan 18, 2017
@morriscb morriscb changed the title Tickets/DM-8645 {{Implement new matcherSourceSelector object for use in matchOptimisticB code}} Tickets/DM-8645: {{Implement new matcherSourceSelector object for use in matchOptimisticB code}} Jan 18, 2017
@morriscb morriscb changed the title Tickets/DM-8645: {{Implement new matcherSourceSelector object for use in matchOptimisticB code}} Tickets/DM-8645: Implement new matcherSourceSelector object for use in matchOptimisticB code Jan 18, 2017
@morriscb morriscb merged commit 81a41ee into master Jan 18, 2017
@ktlim ktlim deleted the tickets/DM-8645 branch August 25, 2018 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants