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

tickets/DM-15104 #211

Merged
merged 1 commit into from
Aug 10, 2018
Merged

tickets/DM-15104 #211

merged 1 commit into from
Aug 10, 2018

Conversation

fred3m
Copy link
Contributor

@fred3m fred3m commented Aug 8, 2018

No description provided.

@fred3m fred3m force-pushed the tickets/DM-15104 branch 2 times, most recently from 7ed033a to 4e4d594 Compare August 8, 2018 19:36
@fred3m fred3m changed the title Tickets/dm 15104 tickets/DM-15104 Aug 8, 2018
butler = dataRefList[0].getButler()
else:
raise RuntimeError("Neither parsedCmd or args specified")
return self.TaskClass(config=self.config, log=self.log, butler=butler)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like you could just use MergeSourcesRunner instead of writing your own, if you made psfCache a config parameter (which might be a good idea anyway, rather than making it special - though I can see how you might want that, given that it's not an option that should change the outputs).

Even if you do want to keep psfCache as a special command-line argument, I'm hoping you could inherit from MergeSourcesRunner and eliminate most of this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is psfCache? I just added it because it's something that MeasureMergedCoaddSources had, but I don't necessarily know what it does, and if it's worth keeping.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I bet I know, but my knowledge of the details is sufficiently limited that we should ask @PaulPrice.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's the lsst::utils::Cache embedded in lsst::afw::detection::Psf that caches the most recent PSF image computations. Changing the capacity of the cache influences the job runtime and memory usage.



class DeblendCoaddSourcesRunner(TaskRunner):
"""Get the psfCache setting into DeblendCoaddSourcesTask"""
Copy link
Contributor

Choose a reason for hiding this comment

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

This doc does not make sense to me, so it probably needs more explanation

"""Get the psfCache setting into DeblendCoaddSourcesTask"""
@staticmethod
def getTargetList(parsedCmd, **kwargs):
"""!
Copy link
Contributor

Choose a reason for hiding this comment

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

I wont exactly hold something up over this, but I though the policy was that all new docs written would be in numpy doc format

coaddName = Field(dtype=str, default="deep", doc="Name of coadd")


class DeblendCoaddSourcesRunner(TaskRunner):
Copy link
Contributor

Choose a reason for hiding this comment

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

Really you should probably just use the MergeSourcesRunner task if there isn't any differences between the two. Worst case if you wanted a runner with the new name, just inherit from MergeSourcesRunner with the desired name and pass as the body



class DeblendCoaddSourcesTask(CmdLineTask):
"""DeblendCoaddSourcesTask
Copy link
Contributor

Choose a reason for hiding this comment

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

No real point in having the first line be the same name as the class, as the class name will be displayed in the documentation. Maybe have a short description of class instead

exposure.getPsf().setCacheCapacity(psfCache)
sources = self.readSources(patchRef)
self.singleBandDeblend.run(exposure, sources)
self.write(patchRef, sources)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking ahead to changes coming really soon, can you refactor the reading data to its own function that run calls? It should be a trivial change, but will make pipeline task conversion easier.

Copy link
Contributor

Choose a reason for hiding this comment

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

I dont know how difficult that will be trying to keep scarlet in mind, if it is too much it is ok, just take a look if you will

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 think that this is a non-trivial change and someone who better understands PipelineTask is better equipped to decided how to split this up, if it can be done in a way that is consistent with other tasks.

dataRef.put(flux_sources, self.config.coaddName + "Coadd_deblendedFlux")
# Only the multiband deblender has the option to output the
# template model catalog, which can optionally
if template_sources is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

if self.config.inputCatalog.startswith("deblended"):
self.deblended = True
else:
self.deblended = False
Copy link
Contributor

Choose a reason for hiding this comment

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

this block can simply be:
self.deblended = self.config.inputCatalog.startswith("deblended")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed.

@@ -1123,7 +1368,7 @@ def readSources(self, dataRef):
We also need to add columns to hold the measurements we're about to make
so we can measure in-place.
"""
merged = dataRef.get(self.config.coaddName + "Coadd_mergeDet", immediate=True)
merged = dataRef.get(self.config.coaddName + self.inputCatalog, immediate=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 will produce different dataset names, is that ok? There is no Coadd_ part of the string in your new version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is expected. Measurements can now be run on one of three different catalogs: the flux conserved deblender output Coadd_deblendedFlux, the scarlet model output Coadd_deblendedModel or the merged catalog (if no deblender is run) Coadd_mergeDet.

exposure = patchRef.get(self.config.coaddName + "Coadd_calexp", immediate=True)
filters.append(patchRef.dataId["filter"])
exposures.append(exposure)
# The input sources are the same for all bands, since it is a merged catalog
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this will always be a merged catalog? what happens when it is not one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same way MeasureMergedCoaddSourcesTask was executed, so the input is always a merged catalog (see https://github.com/lsst/pipe_tasks/blob/tickets/DM-15104/python/lsst/pipe/tasks/multiBand.py#L1019).

self.write(patchRefList[n], fluxCatalogs[n], templateCatalogs[n])
filters = []
exposures = []
for patchRef in patchRefList:
Copy link
Contributor

Choose a reason for hiding this comment

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

see comment on previous commit about splitting out reading

Remove deblending from MeasureMergedCoaddSourcesTask
into it's own task, and support the multiband deblender
scarlet.
@fred3m fred3m merged commit c30114d into master Aug 10, 2018
@ktlim ktlim deleted the tickets/DM-15104 branch August 25, 2018 06:45
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.

4 participants