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-16704: Add fgcmcal-tract mode to fgcmcal #16

Merged
merged 6 commits into from Aug 30, 2019
Merged

Conversation

erykoff
Copy link
Contributor

@erykoff erykoff commented Aug 26, 2019

Add new task to run fgcm on a single tract, including new convergence criteria when run in this mode.

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.
@erykoff
Copy link
Contributor Author

erykoff commented Aug 26, 2019

Note that much of the code that changed was moving previous single-use methods into utilities.py so that they could be shared with the new fgcmCalibrateTract command-line task.

Copy link

@isullivan isullivan left a 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")

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?

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

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

Choose a reason for hiding this comment

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

lists

srcCcds = []

for dataRef in dataRefs:
visit = dataRef.dataId[self.config.visitDataRefName]

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"?

Copy link
Contributor Author

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

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.

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

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

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

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`

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

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)

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.

Copy link

@isullivan isullivan left a 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:

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

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.

Copy link
Contributor Author

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.
@erykoff erykoff merged commit fa3b3a3 into master Aug 30, 2019
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