lsst.pipe.tasks g85f8d04a89+8cd9ef0b15
Loading...
Searching...
No Matches
Classes | Functions | Variables
lsst.pipe.tasks.assembleChi2Coadd Namespace Reference

Classes

class  AssembleChi2CoaddConnections
 

Functions

int calculateKernelSize (float sigma, float nSigmaForKernel=7)
 
afwImage.Image convolveImage (afwImage.Image image, Psf psf)
 

Variables

 log = logging.getLogger(__name__)
 
int http ://pan-starrs.ifa.hawaii.edu/project/people/kaiser/imageprocessing/im%2B%2B.pdf
 
 mMask :
 
 result :
 
 inputCoadds :
 
 exposure :
 
 idFactory :
 
 expId :
 

Function Documentation

◆ calculateKernelSize()

int lsst.pipe.tasks.assembleChi2Coadd.calculateKernelSize ( float  sigma,
float   nSigmaForKernel = 7 
)
Calculate the size of the smoothing kernel.

Parameters
----------
sigma:
    Gaussian sigma of smoothing kernel.
nSigmaForKernel:
    The multiple of `sigma` to use to set the size of the kernel.
    Note that that is the full width of the kernel bounding box
    (so a value of 7 means 3.5 sigma on either side of center).
    The value will be rounded up to the nearest odd integer.

Returns
-------
size:
    Size of the smoothing kernel.

Definition at line 41 of file assembleChi2Coadd.py.

◆ convolveImage()

afwImage.Image lsst.pipe.tasks.assembleChi2Coadd.convolveImage ( afwImage.Image  image,
Psf  psf 
)
Convolve an image with a psf

This methodm and the docstring, is based off the method in
`~lsst.meas.algorithms.detection.SourceDetectionTask`.

We convolve the image with a Gaussian approximation to the PSF,
because this is separable and therefore fast. It's technically a
correlation rather than a convolution, but since we use a symmetric
Gaussian there's no difference.

Parameters
----------
image:
    The image to convovle.
psf:
    The PSF to convolve the `image` with.

Returns
-------
convolved:
    The result of convolving `image` with the `psf`.

Definition at line 62 of file assembleChi2Coadd.py.

Variable Documentation

◆ expId

lsst.pipe.tasks.assembleChi2Coadd.expId :

Definition at line 315 of file assembleChi2Coadd.py.

◆ exposure

lsst.pipe.tasks.assembleChi2Coadd.exposure :
convControl = afwMath.ConvolutionControl()
convControl.setDoNormalize(False)
convControl.setDoCopyEdge(False)

# Set a reference exposure to use for creating the new coadd.
# It doesn't matter which exposure we use, since we just need the
# bounding box information and Factory to create a new expsure with
# the same dtype.
refExp = inputCoadds[0]
bbox = refExp.getBBox()

image = refExp.image.Factory(bbox)
variance_list = []
# Convovle the image in each band and weight by the median variance
for calexp in inputCoadds:
    convolved = convolveImage(calexp.image, calexp.getPsf())
    _variance = np.median(calexp.variance.array)
    convolved.array[:] /= _variance
    image += convolved
    variance_list.append(_variance)

variance = refExp.variance.Factory(bbox)
if self.config.outputPixelatedVariance:
    # Write the per pixel variance to the output coadd
    variance.array[:] = np.sum([1/coadd.variance for coadd in inputCoadds], axis=0)
else:
    # Use a flat variance in each band
    variance.array[:] = np.sum(1/np.array(variance_list))
# Combine the masks planes to calculate the mask plae of the new coadd
mask = self.combinedMasks([coadd.mask for coadd in inputCoadds])
# Create the exposure
maskedImage = refExp.maskedImage.Factory(image, mask=mask, variance=variance)
chi2coadd = refExp.Factory(maskedImage, exposureInfo=refExp.getInfo())
chi2coadd.info.setFilter(None)
return pipeBase.Struct(chi2Coadd=chi2coadd)


class DetectChi2SourcesConnections(
pipeBase.PipelineTaskConnections,
dimensions=("tract", "patch", "skymap"),
defaultTemplates={
"inputCoaddName": "deepChi2",
"outputCoaddName": "deepChi2"
}
):
detectionSchema = cT.InitOutput(
doc="Schema of the detection catalog",
name="{outputCoaddName}Coadd_det_schema",
storageClass="SourceCatalog",
)
exposure = cT.Input(
doc="Exposure on which detections are to be performed",
name="{inputCoaddName}Coadd_calexp",
storageClass="ExposureF",
dimensions=("tract", "patch", "skymap"),
)
outputSources = cT.Output(
doc="Detected sources catalog",
name="{outputCoaddName}Coadd_det",
storageClass="SourceCatalog",
dimensions=("tract", "patch", "skymap"),
)


class DetectChi2SourcesConfig(pipeBase.PipelineTaskConfig, pipelineConnections=DetectChi2SourcesConnections):
detection = pexConfig.ConfigurableField(
target=SourceDetectionTask,
doc="Detect sources in chi2 coadd"
)

idGenerator = SkyMapIdGeneratorConfig.make_field()

def setDefaults(self):
super().setDefaults()
self.detection.reEstimateBackground = False
self.detection.thresholdValue = 3


class DetectChi2SourcesTask(pipeBase.PipelineTask):
_DefaultName = "detectChi2Sources"
ConfigClass = DetectChi2SourcesConfig

def __init__(self, schema=None, **kwargs):
# N.B. Super is used here to handle the multiple inheritance of PipelineTasks, the init tree
# call structure has been reviewed carefully to be sure super will work as intended.
super().__init__(**kwargs)
if schema is None:
    schema = afwTable.SourceTable.makeMinimalSchema()
self.schema = schema
self.makeSubtask("detection", schema=self.schema)
self.detectionSchema = afwTable.SourceCatalog(self.schema)

def runQuantum(self, butlerQC, inputRefs, outputRefs):
inputs = butlerQC.get(inputRefs)
idGenerator = self.config.idGenerator.apply(butlerQC.quantum.dataId)
inputs["idFactory"] = idGenerator.make_table_id_factory()
inputs["expId"] = idGenerator.catalog_id
outputs = self.run(**inputs)
butlerQC.put(outputs, outputRefs)

def run(self, exposure: afwImage.Exposure, idFactory: afwTable.IdFactory, expId: int) -> pipeBase.Struct:

Definition at line 310 of file assembleChi2Coadd.py.

◆ http

int lsst.pipe.tasks.assembleChi2Coadd.http ://pan-starrs.ifa.hawaii.edu/project/people/kaiser/imageprocessing/im%2B%2B.pdf

Definition at line 149 of file assembleChi2Coadd.py.

◆ idFactory

lsst.pipe.tasks.assembleChi2Coadd.idFactory :

Definition at line 313 of file assembleChi2Coadd.py.

◆ inputCoadds

lsst.pipe.tasks.assembleChi2Coadd.inputCoadds :
refMask = masks[0]
bbox = refMask.getBBox()
mask = refMask.array
for _mask in masks[1:]:
    if self.config.useUnionForMask:
        mask = mask | _mask.array
    else:
        mask = mask & _mask.array
result = refMask.Factory(bbox)
result.array[:] = mask
return result

@utils.inheritDoc(pipeBase.PipelineTask)
def runQuantum(self, butlerQC, inputRefs, outputRefs):
inputs = butlerQC.get(inputRefs)
outputs = self.run(**inputs)
butlerQC.put(outputs, outputRefs)

def run(self, inputCoadds: list[afwImage.Exposure]) -> pipeBase.Struct:

Definition at line 197 of file assembleChi2Coadd.py.

◆ log

lsst.pipe.tasks.assembleChi2Coadd.log = logging.getLogger(__name__)

Definition at line 38 of file assembleChi2Coadd.py.

◆ mMask

lsst.pipe.tasks.assembleChi2Coadd.mMask :
ConfigClass = AssembleChi2CoaddConfig
_DefaultName = "assembleChi2Coadd"

def __init__(self, initInputs, **kwargs):
    super().__init__(initInputs=initInputs, **kwargs)

def combinedMasks(self, masks: list[afwImage.MaskX]) -> afwImage.MaskX:

Definition at line 166 of file assembleChi2Coadd.py.

◆ result

lsst.pipe.tasks.assembleChi2Coadd.result :

Definition at line 171 of file assembleChi2Coadd.py.