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
Change doc of used field to calib_photometryUsed. Add reserved and c… #119
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.
A few minor changes, but my bigger concern is the lack of a unittest of these new features. I think that's a requirement before we can merge this.
python/lsst/pipe/tasks/photoCal.py
Outdated
@@ -294,10 +306,16 @@ def __init__(self, refObjLoader, schema=None, **kwds): | |||
self.scatterPlot = None | |||
self.fig = None | |||
if self.config.doWriteOutput: | |||
self.outputField = schema.addField("photocal_photometricStandard", type="Flag", | |||
self.usedKey = schema.addField("calib_photometryUsed", type="Flag", | |||
doc="set if source was used in photometric calibration") |
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.
wonky indentation
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.
Ok
python/lsst/pipe/tasks/photoCal.py
Outdated
@@ -648,21 +670,42 @@ def run(self, exposure, sourceCat): | |||
frame = None | |||
|
|||
res = self.loadAndMatch(exposure, sourceCat) | |||
|
|||
#from res.matches, reserve a fraction of the population and mark the sources as reserved | |||
reserveList = [] |
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.
move reserveList
inside the if
, since we don't need it unless we're reserving things.
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.
OK
python/lsst/pipe/tasks/photoCal.py
Outdated
reserveList = random.sample(res.matches, | ||
int((self.config.reserveFraction)*len(res.matches))) | ||
|
||
for cand in reserveList: |
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'd rather that iterator be candidate
or reserved
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.
OK
python/lsst/pipe/tasks/photoCal.py
Outdated
res.matches.remove(cand) | ||
|
||
if reserveList and self.reservedKey is not None: | ||
for cand in reserveList: |
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.
Again, candidate
or reserved
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.
OK
tests/testPhotoCal.py
Outdated
assert(cat.get("calib_photometryUsed").sum() <= candidates) | ||
|
||
# set the reserve fraction, and see if the right proportion are reserved. | ||
self.config.doWriteOutput = True |
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.
This usage here strongly suggests that doWriteOutput
is the wrong name for that option. If you don't want to change it on this ticket, please file another ticket to change it in the future.
3edf773
to
acdf3a4
Compare
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.
See comments.
In addition, please either set your editor up to use a linter inline (ask on #software-dev on slack for help setting it up), or run flake8 before pushing.
python/lsst/pipe/tasks/photoCal.py
Outdated
if self.config.doWriteOutput: | ||
self.outputField = schema.addField("photocal_photometricStandard", type="Flag", | ||
doc="set if source was used in photometric calibration") | ||
if not schema is None: |
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 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.
OK
python/lsst/pipe/tasks/photoCal.py
Outdated
self.usedKey = schema.addField("calib_photometryUsed", type="Flag", | ||
doc="set if source was used in photometric calibration") | ||
self.candidateKey = schema.addField("calib_photometryCandidate", type="Flag", | ||
doc="set if source was used in photometric calibration") |
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.
Maybe doc should be: "set if source was a possible candidate for photometric calibration"
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.
OK
python/lsst/pipe/tasks/photoCal.py
Outdated
self.candidateKey = schema.addField("calib_photometryCandidate", type="Flag", | ||
doc="set if source was used in photometric calibration") | ||
self.reservedKey = schema.addField("calib_photometryReserved", type="Flag", | ||
doc="set if source was reserved in photometric calibration") |
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.
maybe reword doc: "set if source was reserved, and thus not used, in photometric calibration"
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.
OK
tests/testPhotoCal.py
Outdated
self.config.reserveFraction = .3 | ||
task.run(exposure=self.exposure, sourceCat=cat) | ||
reserved = cat.get("calib_photometryReserved").sum() | ||
assert(reserved == int(.3 * candidates)) |
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.
Please use self.assertEqual(reserved, int(.3*candidates))
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.
OK
tests/testPhotoCal.py
Outdated
task.run(exposure=self.exposure, sourceCat=cat) | ||
reserved = cat.get("calib_photometryReserved").sum() | ||
assert(reserved == int(.3 * candidates)) | ||
assert(cat.get("calib_photometryUsed").sum() <= (candidates - reserved)) |
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.
As above, self.assertLessEqual(cat.get(...).sum(), (candidates - reserved))
tests/testPhotoCal.py
Outdated
# test that by default, no stars are reserved and used < candidates | ||
task.run(exposure=self.exposure, sourceCat=cat) | ||
candidates = cat.get("calib_photometryCandidate").sum() | ||
assert(cat.get("calib_photometryReserved").sum() == 0) |
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.
self.assertEqual(cat.get..., 0)
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.
OK
tests/testPhotoCal.py
Outdated
task.run(exposure=self.exposure, sourceCat=cat) | ||
candidates = cat.get("calib_photometryCandidate").sum() | ||
assert(cat.get("calib_photometryReserved").sum() == 0) | ||
assert(cat.get("calib_photometryUsed").sum() <= candidates) |
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.
self.assertLessEqual(cat.get().sum(), candidates)
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.
Though actually, I'd think you'd be able to know exactly how many objects are selected for used
here: can't you test with that number, so we can know if it ever changes?
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 don't understand how I could know this value except by running the calibration and noting the number. But that's circular.
Also, I think this is just a test that the flag writing mechanism works. To test whether the number is correct seems or changes over time seems like it is a different problem.
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.
Running the test once to get the "current" value and then testing on that value is a reasonable approach, but I agree that it's probably better as a separate test. Probably best done as part of SQUASH, actually, once that's up and running.
python/lsst/pipe/tasks/photoCal.py
Outdated
self.usedKey = schema.addField("calib_photometryUsed", type="Flag", | ||
doc="set if source was used in photometric calibration") | ||
self.candidateKey = schema.addField("calib_photometryCandidate", type="Flag", | ||
doc="set if source was used in photometric calibration") | ||
doc="set if source was as possible candidate in photometric calibration") |
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.
"was a possible"
3b583c8
to
d8371bf
Compare
Flag marks sources using calib_photometryUsed flag: changed from photometryStandard. Add feature to reserve a fraction of candidates selected from the initial match. Mark those calib_photometryReserved. Mark the remainder of the candidates calib_photometryCandidate. Unit test added to testPhotoCal.py
…andidate flags.
Flag marks sources used in final calibration, name changed from photometryStandard.
Added the ability to reserve a fraction of candidates selected from the initial match.
Mark those calib_photometryReserved.
Mark the remainder of the candidates calib_photometryCandidate.