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-16704: Add fgcmcal-tract mode to fgcmcal #16
Conversation
This entails a significant refactoring of methods which were formerly private to make them accessible in the new "utilities.py" file.
Units of output reference catalog are now nJy, as per RFC-549 and RFC-575.
Also fixed bug where atmosphere wasn't being fit.
Note that much of the code that changed was moving previous single-use methods into |
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.
Looks good overall. Please make sure to spell out the full package names in docstrings, even if they are imported with an abbreviation (such as import numpy as np
). Also, when referencing Tasks or parameters in docstrings, it is helpful to put the names in double backticks. Both conventions are helpful for building links for our documentation.
|
||
# Sort the visits for searching/indexing | ||
srcVisits.sort() | ||
|
||
if len(srcVisits) == 0: | ||
self.log.fatal("Found 0 visits to calibrate") | ||
raise RuntimeError("No visits to calibrate") |
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.
Aren't these two errors and messages redundant?
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 think that log.fatal
raises an exception to kick out, though.
butler: `lsst.daf.persistence.Butler` | ||
nCcd: `int` | ||
Number of CCDs in the camera | ||
dataRefs: `list` of `lsst.dat.persistence.ButlerDataRef` |
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.
typo: "dat"
|
||
Returns | ||
------- | ||
(srcVisits, srcCcds): `tuple` of `lists`s |
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.
list
s
srcCcds = [] | ||
|
||
for dataRef in dataRefs: | ||
visit = dataRef.dataId[self.config.visitDataRefName] |
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'm very surprised this is configurable. Are there cases where visitDataRefName is not "visit"?
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.
DECam for example, natively uses "expnum". And in general, it could be anything.
visit = dataRef.dataId[self.config.visitDataRefName] | ||
|
||
if visit in srcVisits: | ||
continue |
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.
Doesn't this mean you will miss some srcCcds
? A comment would help.
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 believe you have a found a flaw in my logic, though it's the other way around. The idea is that this should be run on complete visits, but (when not run in "entire repo" mode) that should be up to the user to specify complete visits on the command line. This ignores that, and therefore bad ccds (such as HSC infamous ccd 9) would get through. I will rework the logic and make clearer comments, and will probably ask you to take a look when it's ready.
tract: `int` | ||
Tract number | ||
visitCat: `lsst.afw.table.BaseCatalog` | ||
FGCM visitCat from fgcmBuildStarsTask |
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.
Here and below, please put e.g. fgcmBuildStarsTask in double backticks in docstrings
@@ -374,26 +426,24 @@ def _computeReferenceOffsets(self, butler): | |||
Parameters | |||
---------- | |||
butler: `lsst.daf.persistence.Butler` | |||
FIX THIS |
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 the text says...
badStarKey: `afwTable.Key` | ||
Key for the field with bad stars | ||
b: `int` | ||
Index of the band in the star catalog | ||
band: `str` | ||
Name of band for reference catalog | ||
stars: `afwTable.SimpleCatalog` | ||
stdCat: `afwTable.SimpleCatalog` | ||
FGCM standard stars | ||
selected: `np.array(dtype=np.bool)` |
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.
Here and elsewhere, spell out numpy in docstrings.
stars for one pixel in one band | ||
|
||
Parameters | ||
---------- | ||
sourceMapper: `afwTable.SchemaMapper` | ||
Mapper to go from stars to calibratable catalog | ||
Mapper to go from stdCat to calibratable catalog | ||
badStarKey: `afwTable.Key` |
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.
Spell out lsst.afw.table.Key
tests/fgcmcalTestBase.py
Outdated
self.assertFloatsAlmostEqual(offsets[0], zpOffsets[0], atol=1e-6) | ||
self.assertFloatsAlmostEqual(offsets[1], zpOffsets[1], atol=1e-6) | ||
# self.assertFloatsAlmostEqual(offsets[0], zpOffsets[0], atol=1e-6) | ||
# self.assertFloatsAlmostEqual(offsets[1], zpOffsets[1], atol=1e-6) |
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.
Delete the commented-out code.
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 couple of questions about the new code, but it looks simpler than before overall.
|
||
scanAllCcds = False | ||
if len(dataRefs) == 0: | ||
if not self.config.checkAllCcds: |
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'm confused about scanAllCcds
vs checkAllCcds
. It looks like scanAllCcds
is True
only if checkAllCcds
is False
, but it looks like it is only checking the reference CCD in that case. Should the line scanAllCcds = True
be moved to the else:
statement below?
continue | ||
# If we need to scan all ccds, do it here | ||
if scanAllCcds: | ||
dataId = dataRef.dataId |
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.
Do you need to make a copy of dataRef.dataId
? I worry that you're changing elements of dataId
below, and that could cause bugs later if dataRef
is also changing.
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.
Good catch.
Also overhauled the way dataRefs are chosen to ensure consistency.
33c027e
to
671949b
Compare
Add new task to run
fgcm
on a single tract, including new convergence criteria when run in this mode.