PlotImageSubtractionCutoutsTask¶
- class lsst.analysis.ap.PlotImageSubtractionCutoutsTask(*, output_path, **kwargs)¶
Bases:
Task
Generate template/science/difference image cutouts of DiaSources and an optional manifest for upload to a Zooniverse project.
- Parameters:
- output_path
str
The path to write the output to; manifest goes here, while the images themselves go into
output_path/images/
.
- output_path
Methods Summary
Empty (clear) the metadata for this Task and all sub-Tasks.
generate_image
(science, template, ...[, ...])Get a 3-part cutout image to save to disk, for a single source.
Get metadata for all tasks.
Get the task name as a hierarchical name including parent task names.
getName
()Get the name of the task.
Get a dictionary of all tasks as a shallow copy.
makeField
(doc)Make a
lsst.pex.config.ConfigurableField
for this task.makeSubtask
(name, **keyArgs)Create a subtask as a new instance as the
name
attribute of this task.run
(data, butler[, njobs])Generate cutout images and a manifest for upload to Zooniverse from a collection of DiaSources.
timer
(name[, logLevel])Context manager to log performance data for an arbitrary block of code.
write_images
(data, butler[, njobs])Make the 3-part cutout images for each requested source and write them to disk.
write_manifest
(sources)Save a Zooniverse manifest attaching image URLs to source ids.
Methods Documentation
- generate_image(science, template, difference, center, scale, dia_source_id=None, save_as_numpy=False, source=None, footprint=None)¶
Get a 3-part cutout image to save to disk, for a single source.
- Parameters:
- science
lsst.afw.image.ExposureF
Science exposure to include in the cutout.
- template
lsst.afw.image.ExposureF
Matched template exposure to include in the cutout.
- difference
lsst.afw.image.ExposureF
Matched science minus template exposure to include in the cutout.
- center
lsst.geom.SpherePoint
Center of the source to be cut out of each image.
- scale
float
Pixel scale in arcseconds.
- dia_source_id
int
, optional DiaSourceId to use in the filename, if saving to disk.
- save_as_numpy
bool
, optional Save the raw cutout images in numpy format.
- source
numpy.record
, optional DiaSource record for this cutout, to add metadata to the image.
- footprint
lsst.afw.detection.Footprint
, optional Detected source footprint; if specified, extract a square surrounding the footprint bbox, otherwise use
config.size
.
- science
- Returns:
- image:
io.BytesIO
The generated image, to be output to a file or displayed on screen.
- image:
- getFullMetadata() TaskMetadata ¶
Get metadata for all tasks.
- Returns:
- metadata
TaskMetadata
The keys are the full task name. Values are metadata for the top-level task and all subtasks, sub-subtasks, etc.
- metadata
Notes
The returned metadata includes timing information (if
@timer.timeMethod
is used) and any metadata set by the task. The name of each item consists of the full task name with.
replaced by:
, followed by.
and the name of the item, e.g.:topLevelTaskName:subtaskName:subsubtaskName.itemName
using
:
in the full task name disambiguates the rare situation that a task has a subtask and a metadata item with the same name.
- getFullName() str ¶
Get the task name as a hierarchical name including parent task names.
- Returns:
- fullName
str
The full name consists of the name of the parent task and each subtask separated by periods. For example:
The full name of top-level task “top” is simply “top”.
The full name of subtask “sub” of top-level task “top” is “top.sub”.
The full name of subtask “sub2” of subtask “sub” of top-level task “top” is “top.sub.sub2”.
- fullName
- getName() str ¶
Get the name of the task.
- Returns:
- taskName
str
Name of the task.
- taskName
See also
getFullName
Get the full name of the task.
- getTaskDict() dict[str, weakref.ReferenceType[lsst.pipe.base.task.Task]] ¶
Get a dictionary of all tasks as a shallow copy.
- Returns:
- taskDict
dict
Dictionary containing full task name: task object for the top-level task and all subtasks, sub-subtasks, etc.
- taskDict
- classmethod makeField(doc: str) ConfigurableField ¶
Make a
lsst.pex.config.ConfigurableField
for this task.- Parameters:
- doc
str
Help text for the field.
- doc
- Returns:
- configurableField
lsst.pex.config.ConfigurableField
A
ConfigurableField
for this task.
- configurableField
Examples
Provides a convenient way to specify this task is a subtask of another task.
Here is an example of use:
class OtherTaskConfig(lsst.pex.config.Config): aSubtask = ATaskClass.makeField("brief description of task")
- makeSubtask(name: str, **keyArgs: Any) None ¶
Create a subtask as a new instance as the
name
attribute of this task.- Parameters:
- name
str
Brief name of the subtask.
- **keyArgs
Extra keyword arguments used to construct the task. The following arguments are automatically provided and cannot be overridden:
config
.parentTask
.
- name
Notes
The subtask must be defined by
Task.config.name
, an instance ofConfigurableField
orRegistryField
.
- run(data, butler, njobs=0)¶
Generate cutout images and a manifest for upload to Zooniverse from a collection of DiaSources.
- Parameters:
- data
pandas.DataFrame
The DiaSources to extract cutouts for. Must contain at least these fields:
ra, dec, diaSourceId, detector, visit, instrument
.- butler
lsst.daf.butler.Butler
The butler connection to use to load the data; create it with the collections you wish to load images from.
- njobs
int
, optional Number of multiprocessing jobs to make cutouts with; default of 0 means don’t use multiprocessing at all.
- data
- Returns:
- timer(name: str, logLevel: int = 10) Iterator[None] ¶
Context manager to log performance data for an arbitrary block of code.
- Parameters:
See also
lsst.utils.timer.logInfo
Implementation function.
Examples
Creating a timer context:
with self.timer("someCodeToTime"): pass # code to time
- write_images(data, butler, njobs=0)¶
Make the 3-part cutout images for each requested source and write them to disk.
Creates
images/
andnumpy/
subdirectories if they do not already exist; images are written there as PNG and npy files.- Parameters:
- data
pandas.DataFrame
The DiaSources to extract cutouts for. Must contain at least these fields:
ra, dec, diaSourceId, detector, visit, instrument
.- butler
lsst.daf.butler.Butler
The butler connection to use to load the data; create it with the collections you wish to load images from.
- njobs
int
, optional Number of multiprocessing jobs to make cutouts with; default of 0 means don’t use multiprocessing at all.
- data
- Returns:
- sources
list
DiaSourceIds that had cutouts made.
- sources