LSSTApplications  17.0+10,17.0+52,17.0+91,18.0.0+11,18.0.0+16,18.0.0+38,18.0.0+4,18.0.0-2-ge43143a+8,18.1.0-1-g0001055+4,18.1.0-1-g1349e88+13,18.1.0-1-g2505f39+10,18.1.0-1-g380d4d4+13,18.1.0-1-g5315e5e,18.1.0-1-g5e4b7ea+4,18.1.0-1-g7e8fceb,18.1.0-1-g85f8cd4+10,18.1.0-1-g9a6769a+4,18.1.0-1-ga1a4c1a+9,18.1.0-1-gd55f500+5,18.1.0-1-ge10677a+10,18.1.0-11-gb2589d7b,18.1.0-13-g451e75588+2,18.1.0-13-gbfe7f7f+4,18.1.0-14-g2e73c10+1,18.1.0-2-g31c43f9+10,18.1.0-2-g919ecaf,18.1.0-2-g9c63283+13,18.1.0-2-gdf0b915+13,18.1.0-2-gfefb8b5+2,18.1.0-3-g52aa583+4,18.1.0-3-g8f4a2b1+4,18.1.0-3-g9cb968e+12,18.1.0-3-gab23065,18.1.0-4-g7bbbad0+4,18.1.0-5-g510c42a+12,18.1.0-5-gaeab27e+13,18.1.0-6-gc4bdb98+2,18.1.0-6-gdda7f3e+15,18.1.0-9-g9613d271+1,w.2019.34
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask Class Reference
Inheritance diagram for lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask:
lsst.pipe.tasks.dcrMultiBand.DeblendDcrCoaddSourcesTask

Public Member Functions

def __init__ (self, butler=None, schema=None, peakSchema=None, kwargs)
 
def getSchemaCatalogs (self)
 
def runDataRef (self, patchRefList, psfCache=100)
 
def readSources (self, dataRef)
 
def write (self, dataRef, flux_sources, template_sources=None)
 
def writeMetadata (self, dataRefList)
 
def getExposureId (self, dataRef)
 

Public Attributes

 schemaMapper
 
 schema
 

Static Public Attributes

 ConfigClass = DeblendCoaddSourcesConfig
 
 RunnerClass = DeblendCoaddSourcesRunner
 
 makeIdFactory = _makeMakeIdFactory("MergedCoaddId")
 

Detailed Description

Deblend the sources in a merged catalog

Deblend sources from master catalog in each coadd.
This can either be done separately in each band using the HSC-SDSS deblender
(`DeblendCoaddSourcesTask.config.simultaneous==False`)
or use SCARLET to simultaneously fit the blend in all bands
(`DeblendCoaddSourcesTask.config.simultaneous==True`).
The task will set its own `self.schema` atribute to the `Schema` of the
output deblended catalog.
This will include all fields from the input `Schema`, as well as additional fields
from the deblender.

`pipe.tasks.multiband.DeblendCoaddSourcesTask Description
---------------------------------------------------------
`

Parameters
----------
butler: `Butler`
    Butler used to read the input schemas from disk or
    construct the reference catalog loader, if `schema` or `peakSchema` or
schema: `Schema`
    The schema of the merged detection catalog as an input to this task.
peakSchema: `Schema`
    The schema of the `PeakRecord`s in the `Footprint`s in the merged detection catalog

Definition at line 396 of file multiBand.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.__init__ (   self,
  butler = None,
  schema = None,
  peakSchema = None,
  kwargs 
)

Definition at line 437 of file multiBand.py.

437  def __init__(self, butler=None, schema=None, peakSchema=None, **kwargs):
438  CmdLineTask.__init__(self, **kwargs)
439  if schema is None:
440  assert butler is not None, "Neither butler nor schema is defined"
441  schema = butler.get(self.config.coaddName + "Coadd_mergeDet_schema", immediate=True).schema
442  self.schemaMapper = afwTable.SchemaMapper(schema)
443  self.schemaMapper.addMinimalSchema(schema)
444  self.schema = self.schemaMapper.getOutputSchema()
445  if peakSchema is None:
446  assert butler is not None, "Neither butler nor peakSchema is defined"
447  peakSchema = butler.get(self.config.coaddName + "Coadd_peak_schema", immediate=True).schema
448 
449  if self.config.simultaneous:
450  self.makeSubtask("multiBandDeblend", schema=self.schema, peakSchema=peakSchema)
451  else:
452  self.makeSubtask("singleBandDeblend", schema=self.schema, peakSchema=peakSchema)
453 
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
def __init__(self, minimum, dataRange, Q)

Member Function Documentation

◆ getExposureId()

def lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.getExposureId (   self,
  dataRef 
)
Get the ExposureId from a data reference

Definition at line 582 of file multiBand.py.

582  def getExposureId(self, dataRef):
583  """Get the ExposureId from a data reference
584  """
585  return int(dataRef.get(self.config.coaddName + "CoaddId"))
586 
587 

◆ getSchemaCatalogs()

def lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.getSchemaCatalogs (   self)
Return a dict of empty catalogs for each catalog dataset produced by this task.

Returns
-------
result: dict
    Dictionary of empty catalogs, with catalog names as keys.

Definition at line 454 of file multiBand.py.

454  def getSchemaCatalogs(self):
455  """Return a dict of empty catalogs for each catalog dataset produced by this task.
456 
457  Returns
458  -------
459  result: dict
460  Dictionary of empty catalogs, with catalog names as keys.
461  """
462  catalog = afwTable.SourceCatalog(self.schema)
463  return {self.config.coaddName + "Coadd_deblendedFlux": catalog,
464  self.config.coaddName + "Coadd_deblendedModel": catalog}
465 

◆ readSources()

def lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.readSources (   self,
  dataRef 
)
Read merged catalog

Read the catalog of merged detections and create a catalog
in a single band.

Parameters
----------
dataRef: data reference
    Data reference for catalog of merged detections

Returns
-------
sources: `SourceCatalog`
    List of sources in merged catalog

We also need to add columns to hold the measurements we're about to make
so we can measure in-place.

Definition at line 509 of file multiBand.py.

509  def readSources(self, dataRef):
510  """Read merged catalog
511 
512  Read the catalog of merged detections and create a catalog
513  in a single band.
514 
515  Parameters
516  ----------
517  dataRef: data reference
518  Data reference for catalog of merged detections
519 
520  Returns
521  -------
522  sources: `SourceCatalog`
523  List of sources in merged catalog
524 
525  We also need to add columns to hold the measurements we're about to make
526  so we can measure in-place.
527  """
528  merged = dataRef.get(self.config.coaddName + "Coadd_mergeDet", immediate=True)
529  self.log.info("Read %d detections: %s" % (len(merged), dataRef.dataId))
530  idFactory = self.makeIdFactory(dataRef)
531  for s in merged:
532  idFactory.notify(s.getId())
533  table = afwTable.SourceTable.make(self.schema, idFactory)
534  sources = afwTable.SourceCatalog(table)
535  sources.extend(merged, self.schemaMapper)
536  return sources
537 

◆ runDataRef()

def lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.runDataRef (   self,
  patchRefList,
  psfCache = 100 
)
Deblend the patch

Deblend each source simultaneously or separately
(depending on `DeblendCoaddSourcesTask.config.simultaneous`).
Set `is-primary` and related flags.
Propagate flags from individual visits.
Write the deblended sources out.

Parameters
----------
patchRefList: list
    List of data references for each filter

Definition at line 466 of file multiBand.py.

466  def runDataRef(self, patchRefList, psfCache=100):
467  """Deblend the patch
468 
469  Deblend each source simultaneously or separately
470  (depending on `DeblendCoaddSourcesTask.config.simultaneous`).
471  Set `is-primary` and related flags.
472  Propagate flags from individual visits.
473  Write the deblended sources out.
474 
475  Parameters
476  ----------
477  patchRefList: list
478  List of data references for each filter
479  """
480 
481  if self.config.hasFakes:
482  coaddType = "fakes_" + self.config.coaddName
483  else:
484  coaddType = self.config.coaddName
485 
486  if self.config.simultaneous:
487  # Use SCARLET to simultaneously deblend across filters
488  filters = []
489  exposures = []
490  for patchRef in patchRefList:
491  exposure = patchRef.get(coaddType + "Coadd_calexp", immediate=True)
492  filters.append(patchRef.dataId["filter"])
493  exposures.append(exposure)
494  # The input sources are the same for all bands, since it is a merged catalog
495  sources = self.readSources(patchRef)
496  exposure = afwImage.MultibandExposure.fromExposures(filters, exposures)
497  fluxCatalogs, templateCatalogs = self.multiBandDeblend.run(exposure, sources)
498  for n in range(len(patchRefList)):
499  self.write(patchRefList[n], fluxCatalogs[filters[n]], templateCatalogs[filters[n]])
500  else:
501  # Use the singeband deblender to deblend each band separately
502  for patchRef in patchRefList:
503  exposure = patchRef.get(coaddType + "Coadd_calexp", immediate=True)
504  exposure.getPsf().setCacheCapacity(psfCache)
505  sources = self.readSources(patchRef)
506  self.singleBandDeblend.run(exposure, sources)
507  self.write(patchRef, sources)
508 

◆ write()

def lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.write (   self,
  dataRef,
  flux_sources,
  template_sources = None 
)
Write the source catalog(s)

Parameters
----------
dataRef: Data Reference
    Reference to the output catalog.
flux_sources: `SourceCatalog`
    Flux conserved sources to write to file.
    If using the single band deblender, this is the catalog
    generated.
template_sources: `SourceCatalog`
    Source catalog using the multiband template models
    as footprints.

Definition at line 538 of file multiBand.py.

538  def write(self, dataRef, flux_sources, template_sources=None):
539  """Write the source catalog(s)
540 
541  Parameters
542  ----------
543  dataRef: Data Reference
544  Reference to the output catalog.
545  flux_sources: `SourceCatalog`
546  Flux conserved sources to write to file.
547  If using the single band deblender, this is the catalog
548  generated.
549  template_sources: `SourceCatalog`
550  Source catalog using the multiband template models
551  as footprints.
552  """
553  # The multiband deblender does not have to conserve flux,
554  # so only write the flux conserved catalog if it exists
555  if flux_sources is not None:
556  assert not self.config.simultaneous or self.config.multiBandDeblend.conserveFlux
557  dataRef.put(flux_sources, self.config.coaddName + "Coadd_deblendedFlux")
558  # Only the multiband deblender has the option to output the
559  # template model catalog, which can optionally be used
560  # in MeasureMergedCoaddSources
561  if template_sources is not None:
562  assert self.config.multiBandDeblend.saveTemplates
563  dataRef.put(template_sources, self.config.coaddName + "Coadd_deblendedModel")
564  self.log.info("Wrote %d sources: %s" % (len(flux_sources), dataRef.dataId))
565 

◆ writeMetadata()

def lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.writeMetadata (   self,
  dataRefList 
)
Write the metadata produced from processing the data.
Parameters
----------
dataRefList
    List of Butler data references used to write the metadata.
    The metadata is written to dataset type `CmdLineTask._getMetadataName`.

Definition at line 566 of file multiBand.py.

566  def writeMetadata(self, dataRefList):
567  """Write the metadata produced from processing the data.
568  Parameters
569  ----------
570  dataRefList
571  List of Butler data references used to write the metadata.
572  The metadata is written to dataset type `CmdLineTask._getMetadataName`.
573  """
574  for dataRef in dataRefList:
575  try:
576  metadataName = self._getMetadataName()
577  if metadataName is not None:
578  dataRef.put(self.getFullMetadata(), metadataName)
579  except Exception as e:
580  self.log.warn("Could not persist metadata for dataId=%s: %s", dataRef.dataId, e)
581 

Member Data Documentation

◆ ConfigClass

lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.ConfigClass = DeblendCoaddSourcesConfig
static

Definition at line 423 of file multiBand.py.

◆ makeIdFactory

lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.makeIdFactory = _makeMakeIdFactory("MergedCoaddId")
static

Definition at line 426 of file multiBand.py.

◆ RunnerClass

lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.RunnerClass = DeblendCoaddSourcesRunner
static

Definition at line 424 of file multiBand.py.

◆ schema

lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.schema

Definition at line 444 of file multiBand.py.

◆ schemaMapper

lsst.pipe.tasks.multiBand.DeblendCoaddSourcesTask.schemaMapper

Definition at line 442 of file multiBand.py.


The documentation for this class was generated from the following file: