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

Change doc of used field to calib_photometryUsed. Add reserved and c… #119

Merged
merged 1 commit into from May 10, 2017

Conversation

pgee2000
Copy link
Contributor

…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.

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.

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.

@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

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

wonky indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@@ -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 = []
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

reserveList = random.sample(res.matches,
int((self.config.reserveFraction)*len(res.matches)))

for cand in reserveList:
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

res.matches.remove(cand)

if reserveList and self.reservedKey is not None:
for cand in reserveList:
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, candidate or reserved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

assert(cat.get("calib_photometryUsed").sum() <= candidates)

# set the reserve fraction, and see if the right proportion are reserved.
self.config.doWriteOutput = True
Copy link
Contributor

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.

@pgee2000 pgee2000 force-pushed the tickets/DM-9050 branch 2 times, most recently from 3edf773 to acdf3a4 Compare May 8, 2017 16:58
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.

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.

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:
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

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")
Copy link
Contributor

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"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

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")
Copy link
Contributor

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"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

self.config.reserveFraction = .3
task.run(exposure=self.exposure, sourceCat=cat)
reserved = cat.get("calib_photometryReserved").sum()
assert(reserved == int(.3 * candidates))
Copy link
Contributor

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))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

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))
Copy link
Contributor

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))

# 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)
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

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)
Copy link
Contributor

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)

Copy link
Contributor

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?

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 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.

Copy link
Contributor

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.

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")
Copy link
Contributor

Choose a reason for hiding this comment

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

"was a possible"

@pgee2000 pgee2000 force-pushed the tickets/DM-9050 branch 2 times, most recently from 3b583c8 to d8371bf Compare May 10, 2017 01:18
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
@pgee2000 pgee2000 merged commit d8371bf into master May 10, 2017
@ktlim ktlim deleted the tickets/DM-9050 branch August 25, 2018 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants