-
Notifications
You must be signed in to change notification settings - Fork 7
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
Working integration test for CFHT data. #14
Changes from 1 commit
94c04fd
f8994ec
1238345
0b478a6
bef3ff1
be8c48a
7cf737f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,18 +45,31 @@ def getTargetList(parsedCmd, **kwargs): | |
for ref in parsedCmd.id.refList: | ||
refListDict.setdefault(ref.dataId["tract"], []).append(ref) | ||
# we call run() once with each tract | ||
return [(refListDict[tract], | ||
tract | ||
) for tract in sorted(refListDict.keys())] | ||
return [(refListDict[tract],) for tract in sorted(refListDict.keys())] | ||
|
||
def __call__(self, args): | ||
""" | ||
@param args Arguments for Task.run() | ||
|
||
@return | ||
- None if self.doReturnResults is False | ||
- A pipe.base.Struct containing these fields if self.doReturnResults is True: | ||
- dataRef: the provided data references, with update post-fit WCS's. | ||
""" | ||
task = self.TaskClass(config=self.config, log=self.log) | ||
task.run(*args) | ||
result = task.run(*args) | ||
if self.doReturnResults: | ||
return pipeBase.Struct(result = result) | ||
|
||
|
||
class JointcalConfig(pexConfig.Config): | ||
"""Config for jointcalTask""" | ||
|
||
coaddName = pexConfig.Field( | ||
doc = "Type of coadd", | ||
dtype = str, | ||
default = "deep" | ||
) | ||
posError = pexConfig.Field( | ||
doc = "Constant term for error on position (in pixel unit)", | ||
dtype = float, | ||
|
@@ -77,6 +90,7 @@ class JointcalConfig(pexConfig.Config): | |
doc = "How to select sources for cross-matching", | ||
default = "astrometry" | ||
) | ||
# TODO: CmdLineTask has a profile thing built-in: can we tie in to that? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should absolutely use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but how does one manage turning on/off profiling in general? I want to be able to enable profiling when timing various things, but I don't want it on by default. Is there a standard approach to that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have the lsstDebug trick to handle fine-grained turning on of debugging, and something similar could work for profiling. In fact, people aren't thrilled about the mechanism that lsstDebug uses, but the replacement for lsstDebug should be able to handle profiling too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've dealt with this by adding a "--profile_jointcal" cmdline argument which can be the used with the context manager. I want to be able to profile individual parts of jointcal separately, since I know most of the effort is going into the actual math but there are likely other things that could be sped up independently. |
||
profile = pexConfig.Field( | ||
doc = "Profile jointcal, including the catalog creation step.", | ||
dtype = bool, | ||
|
@@ -98,10 +112,7 @@ class JointcalTask(pipeBase.CmdLineTask): | |
RunnerClass = JointcalRunner | ||
_DefaultName = "jointcal" | ||
|
||
def __init__(self, schema, *args, **kwargs): | ||
""" | ||
@param schema source catalog schema for all the catalogs we will work with. | ||
""" | ||
def __init__(self, *args, **kwargs): | ||
pipeBase.CmdLineTask.__init__(self, *args, **kwargs) | ||
self.makeSubtask("sourceSelector") | ||
|
||
|
@@ -123,7 +134,17 @@ def _makeArgumentParser(cls): | |
return parser | ||
|
||
def _build_ccdImage(self, dataRef, associations, jointcalControl): | ||
"""Extract the necessary things from this dataRef to add a new ccdImage.""" | ||
""" | ||
Extract the necessary things from this dataRef to add a new ccdImage. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need a leading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
|
||
@param dataRef (ButlerDataRef) dataRef to extract info from. | ||
@param associations (jointcal.Associations) object to add the info to, to | ||
construct a new CcdImage | ||
@param jointcalControl (jointcal.JointcalControl) control object for | ||
associations management | ||
|
||
@return (afw.image.TanWcs) the TAN WCS of this image | ||
""" | ||
src = dataRef.get("src", immediate=True) | ||
md = dataRef.get("calexp_md", immediate=True) | ||
tanwcs = afwImage.TanWcs.cast(afwImage.makeWcs(md)) | ||
|
@@ -135,7 +156,8 @@ def _build_ccdImage(self, dataRef, associations, jointcalControl): | |
|
||
goodSrc = self.sourceSelector.selectSources(src) | ||
|
||
# TODO: NOTE: Leaving the old catalog and comparison code in while we | ||
# ------------------ | ||
# TODO: Leaving the old catalog and comparison code in while we | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code should not be left commented out. I know you have philosophical disagreements, but I think you should submit to the way things are done until you have explicit approval to change them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just submitted an RFC. I'll note that I couldn't find any explicit statement about this in the python coding standards. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did add a note about the conditions under which the code would be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've now wrapped this code in |
||
# sort out the old/new star selector differences. | ||
|
||
# configSel = StarSelectorConfig() | ||
|
@@ -148,7 +170,15 @@ def _build_ccdImage(self, dataRef, associations, jointcalControl): | |
# print("new, old, shared:", len(stars1), len(stars2), len(aa)) | ||
# # import ipdb; ipdb.set_trace() | ||
|
||
# TODO: NOTE: End of old source selector debugging block. | ||
# print("%d stars selected in visit %d - ccd %d"%(len(stars2), | ||
# dataRef.dataId["visit"], | ||
# dataRef.dataId["ccd"])) | ||
# associations.AddImage(stars2, tanwcs, md, bbox, filt, calib, | ||
# dataRef.dataId['visit'], dataRef.dataId['ccd'], | ||
# dataRef.getButler().get("camera").getName(), | ||
# jointcalControl) | ||
# TODO: End of old source selector debugging block. | ||
# ------------------ | ||
|
||
if len(goodSrc.sourceCat) == 0: | ||
print("no stars selected in ", dataRef.dataId["visit"], dataRef.dataId["ccd"]) | ||
|
@@ -161,13 +191,16 @@ def _build_ccdImage(self, dataRef, associations, jointcalControl): | |
dataRef.dataId['visit'], dataRef.dataId['ccd'], | ||
dataRef.getButler().get("camera").getName(), | ||
jointcalControl) | ||
return tanwcs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a blank There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
|
||
@pipeBase.timeMethod | ||
def run(self, dataRefs): | ||
""" | ||
!Jointly calibrate the astrometry and photometry across a set of images. | ||
|
||
@param dataRefs list of data references. | ||
@param dataRefs list of data references. | ||
|
||
@return (pipe.base.Struct) dataRefs that were fit (with updated WCSs) and old WCSs. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should state the names of each element of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Done. |
||
""" | ||
if len(dataRefs) == 0: | ||
raise ValueError('Need a list of data references!') | ||
|
@@ -189,8 +222,9 @@ def run(self, dataRefs): | |
prof = pstats.Stats('jointcal_load_catalog.prof') | ||
prof.strip_dirs().sort_stats('cumtime').print_stats(20) | ||
else: | ||
old_wcss = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair points. I've updated it to oldWcsList, including in the return struct. |
||
for dataRef in dataRefs: | ||
self._build_ccdImage(dataRef, associations, jointcalControl) | ||
old_wcss.append(self._build_ccdImage(dataRef, associations, jointcalControl)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer a listcomp (clearer, often shorter, more pythonic):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... I added the return of the old WCSes as a convenience for testing (and in case they get altered by future versions of jointcal). We may want to eventually not save the old WCSes, but the list comprehension line isn't too long, so I'll go with it. |
||
|
||
matchCut = 3.0 | ||
# TODO: this should not print "trying to invert a singular transformation:" | ||
|
@@ -299,6 +333,8 @@ def run(self, dataRefs): | |
self.log.warn('Failed to write updated Wcs: ' + str(e)) | ||
break | ||
|
||
return pipeBase.Struct(dataRefs=dataRefs, old_wcss=old_wcss) | ||
|
||
|
||
# TODO: Leaving StarSelector[Config] here for reference. | ||
# TODO: We can remove them once we're happy with astrometryStarSelector. | ||
|
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.
No spaces around
=
if it's all on one line (e.g., see line 59).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.
Fixed.