|
def | run (self, args) |
|
def | parseAndRun (cls) |
|
def | ingest (self, infile, outfile, mode="move", dryrun=False) |
|
def | isBadFile (self, filename, badFileList) |
|
def | isBadId (self, info, badIdList) |
|
def | expandFiles (self, fileNameList) |
| Expand a set of filenames and globs, returning a list of filenames. More...
|
|
def | runFile (self, infile, registry, args) |
| Examine and ingest a single file. More...
|
|
def | emptyMetadata (self) |
|
def | getSchemaCatalogs (self) |
|
def | getAllSchemaCatalogs (self) |
|
def | getFullMetadata (self) |
|
def | getFullName (self) |
|
def | getName (self) |
|
def | getTaskDict (self) |
|
def | makeSubtask (self, name, keyArgs) |
|
def | timer (self, name, logLevel=Log.DEBUG) |
|
def | makeField (cls, doc) |
|
def | __reduce__ (self) |
|
Task that generates registry for calibration images
Definition at line 29 of file ingestDefects.py.
◆ __reduce__()
def lsst.pipe.base.task.Task.__reduce__ |
( |
|
self | ) |
|
|
inherited |
Pickler.
Definition at line 373 of file task.py.
373 def __reduce__(self):
376 return self.__class__, (self.config, self._name, self._parentTask,
None)
◆ emptyMetadata()
def lsst.pipe.base.task.Task.emptyMetadata |
( |
|
self | ) |
|
|
inherited |
Empty (clear) the metadata for this Task and all sub-Tasks.
Definition at line 153 of file task.py.
153 def emptyMetadata(self):
154 """Empty (clear) the metadata for this Task and all sub-Tasks. 156 for subtask
in self._taskDict.values():
Class for storing ordered metadata with comments.
◆ expandFiles()
def lsst.pipe.tasks.ingest.IngestTask.expandFiles |
( |
|
self, |
|
|
|
fileNameList |
|
) |
| |
|
inherited |
Expand a set of filenames and globs, returning a list of filenames.
- Parameters
-
fileNameList | A list of files and glob patterns |
N.b. globs obey Posix semantics, so a pattern that matches nothing is returned unchanged
Definition at line 499 of file ingest.py.
499 def expandFiles(self, fileNameList):
500 """!Expand a set of filenames and globs, returning a list of filenames 502 @param fileNameList A list of files and glob patterns 504 N.b. globs obey Posix semantics, so a pattern that matches nothing is returned unchanged 507 for globPattern
in fileNameList:
508 files = glob(globPattern)
511 self.log.
warn(
"%s doesn't match any file" % globPattern)
514 filenameList.extend(files)
◆ getAllSchemaCatalogs()
def lsst.pipe.base.task.Task.getAllSchemaCatalogs |
( |
|
self | ) |
|
|
inherited |
Get schema catalogs for all tasks in the hierarchy, combining the results into a single dict.
Returns
-------
schemacatalogs : `dict`
Keys are butler dataset type, values are a empty catalog (an instance of the appropriate
lsst.afw.table Catalog type) for all tasks in the hierarchy, from the top-level task down
through all subtasks.
Notes
-----
This method may be called on any task in the hierarchy; it will return the same answer, regardless.
The default implementation should always suffice. If your subtask uses schemas the override
`Task.getSchemaCatalogs`, not this method.
Definition at line 188 of file task.py.
188 def getAllSchemaCatalogs(self):
189 """Get schema catalogs for all tasks in the hierarchy, combining the results into a single dict. 193 schemacatalogs : `dict` 194 Keys are butler dataset type, values are a empty catalog (an instance of the appropriate 195 lsst.afw.table Catalog type) for all tasks in the hierarchy, from the top-level task down 196 through all subtasks. 200 This method may be called on any task in the hierarchy; it will return the same answer, regardless. 202 The default implementation should always suffice. If your subtask uses schemas the override 203 `Task.getSchemaCatalogs`, not this method. 205 schemaDict = self.getSchemaCatalogs()
206 for subtask
in self._taskDict.values():
207 schemaDict.update(subtask.getSchemaCatalogs())
◆ getFullMetadata()
def lsst.pipe.base.task.Task.getFullMetadata |
( |
|
self | ) |
|
|
inherited |
Get metadata for all tasks.
Returns
-------
metadata : `lsst.daf.base.PropertySet`
The `~lsst.daf.base.PropertySet` keys are the full task name. Values are metadata
for the top-level task and all subtasks, sub-subtasks, etc..
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.
Definition at line 210 of file task.py.
210 def getFullMetadata(self):
211 """Get metadata for all tasks. 215 metadata : `lsst.daf.base.PropertySet` 216 The `~lsst.daf.base.PropertySet` keys are the full task name. Values are metadata 217 for the top-level task and all subtasks, sub-subtasks, etc.. 221 The returned metadata includes timing information (if ``@timer.timeMethod`` is used) 222 and any metadata set by the task. The name of each item consists of the full task name 223 with ``.`` replaced by ``:``, followed by ``.`` and the name of the item, e.g.:: 225 topLevelTaskName:subtaskName:subsubtaskName.itemName 227 using ``:`` in the full task name disambiguates the rare situation that a task has a subtask 228 and a metadata item with the same name. 231 for fullName, task
in self.getTaskDict().
items():
232 fullMetadata.set(fullName.replace(
".",
":"), task.metadata)
std::vector< SchemaItem< Flag > > * items
Class for storing generic metadata.
◆ getFullName()
def lsst.pipe.base.task.Task.getFullName |
( |
|
self | ) |
|
|
inherited |
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".
Definition at line 235 of file task.py.
235 def getFullName(self):
236 """Get the task name as a hierarchical name including parent task names. 241 The full name consists of the name of the parent task and each subtask separated by periods. 244 - The full name of top-level task "top" is simply "top". 245 - The full name of subtask "sub" of top-level task "top" is "top.sub". 246 - The full name of subtask "sub2" of subtask "sub" of top-level task "top" is "top.sub.sub2". 248 return self._fullName
◆ getName()
def lsst.pipe.base.task.Task.getName |
( |
|
self | ) |
|
|
inherited |
Get the name of the task.
Returns
-------
taskName : `str`
Name of the task.
See also
--------
getFullName
Definition at line 250 of file task.py.
251 """Get the name of the task.
◆ getSchemaCatalogs()
def lsst.pipe.base.task.Task.getSchemaCatalogs |
( |
|
self | ) |
|
|
inherited |
Get the schemas generated by this task.
Returns
-------
schemaCatalogs : `dict`
Keys are butler dataset type, values are an empty catalog (an instance of the appropriate
`lsst.afw.table` Catalog type) for this task.
Notes
-----
.. warning::
Subclasses that use schemas must override this method. The default implemenation returns
an empty dict.
This method may be called at any time after the Task is constructed, which means that all task
schemas should be computed at construction time, *not* when data is actually processed. This
reflects the philosophy that the schema should not depend on the data.
Returning catalogs rather than just schemas allows us to save e.g. slots for SourceCatalog as well.
See also
--------
Task.getAllSchemaCatalogs
Definition at line 159 of file task.py.
159 def getSchemaCatalogs(self):
160 """Get the schemas generated by this task. 164 schemaCatalogs : `dict` 165 Keys are butler dataset type, values are an empty catalog (an instance of the appropriate 166 `lsst.afw.table` Catalog type) for this task. 173 Subclasses that use schemas must override this method. The default implemenation returns 176 This method may be called at any time after the Task is constructed, which means that all task 177 schemas should be computed at construction time, *not* when data is actually processed. This 178 reflects the philosophy that the schema should not depend on the data. 180 Returning catalogs rather than just schemas allows us to save e.g. slots for SourceCatalog as well. 184 Task.getAllSchemaCatalogs
◆ getTaskDict()
def lsst.pipe.base.task.Task.getTaskDict |
( |
|
self | ) |
|
|
inherited |
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..
Definition at line 264 of file task.py.
265 """Get a dictionary of all tasks as a shallow copy. 270 Dictionary containing full task name: task object for the top-level task and all subtasks, 273 return self._taskDict.copy()
def getTaskDict(config, taskDict=None, baseName="")
◆ ingest()
def lsst.pipe.tasks.ingest.IngestTask.ingest |
( |
|
self, |
|
|
|
infile, |
|
|
|
outfile, |
|
|
|
mode = "move" , |
|
|
|
dryrun = False |
|
) |
| |
|
inherited |
Ingest a file into the image repository.
@param infile Name of input file
@param outfile Name of output file (file in repository)
@param mode Mode of ingest (copy/link/move/skip)
@param dryrun Only report what would occur?
@param Success boolean
Definition at line 427 of file ingest.py.
427 def ingest(self, infile, outfile, mode="move", dryrun=False):
428 """Ingest a file into the image repository. 430 @param infile Name of input file 431 @param outfile Name of output file (file in repository) 432 @param mode Mode of ingest (copy/link/move/skip) 433 @param dryrun Only report what would occur? 434 @param Success boolean 439 self.log.
info(
"Would %s from %s to %s" % (mode, infile, outfile))
442 outdir = os.path.dirname(outfile)
443 if not os.path.isdir(outdir):
448 if not os.path.isdir(outdir):
450 if os.path.lexists(outfile):
451 if self.config.clobber:
454 raise RuntimeError(
"File %s already exists; consider --config clobber=True" % outfile)
458 shutil.copyfile(infile, outfile)
460 os.symlink(os.path.abspath(infile), outfile)
463 shutil.move(infile, outfile)
465 raise AssertionError(
"Unknown mode: %s" % mode)
466 self.log.
info(
"%s --<%s>--> %s" % (infile, mode, outfile))
467 except Exception
as e:
468 self.log.
warn(
"Failed to %s %s to %s: %s" % (mode, infile, outfile, e))
469 if not self.config.allowError:
def assertCanCopy(fromPath, toPath)
◆ isBadFile()
def lsst.pipe.tasks.ingest.IngestTask.isBadFile |
( |
|
self, |
|
|
|
filename, |
|
|
|
badFileList |
|
) |
| |
|
inherited |
Return whether the file qualifies as bad
We match against the list of bad file patterns.
Definition at line 474 of file ingest.py.
474 def isBadFile(self, filename, badFileList):
475 """Return whether the file qualifies as bad 477 We match against the list of bad file patterns. 479 filename = os.path.basename(filename)
482 for badFile
in badFileList:
483 if fnmatch(filename, badFile):
◆ isBadId()
def lsst.pipe.tasks.ingest.IngestTask.isBadId |
( |
|
self, |
|
|
|
info, |
|
|
|
badIdList |
|
) |
| |
|
inherited |
Return whether the file information qualifies as bad
We match against the list of bad data identifiers.
Definition at line 487 of file ingest.py.
487 def isBadId(self, info, badIdList):
488 """Return whether the file information qualifies as bad 490 We match against the list of bad data identifiers. 494 for badId
in badIdList:
495 if all(info[key] == value
for key, value
in badId.items()):
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
◆ makeField()
def lsst.pipe.base.task.Task.makeField |
( |
|
cls, |
|
|
|
doc |
|
) |
| |
|
inherited |
Make a `lsst.pex.config.ConfigurableField` for this task.
Parameters
----------
doc : `str`
Help text for the field.
Returns
-------
configurableField : `lsst.pex.config.ConfigurableField`
A `~ConfigurableField` for this task.
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("a brief description of what this task does")
Definition at line 329 of file task.py.
329 def makeField(cls, doc):
330 """Make a `lsst.pex.config.ConfigurableField` for this task. 335 Help text for the field. 339 configurableField : `lsst.pex.config.ConfigurableField` 340 A `~ConfigurableField` for this task. 344 Provides a convenient way to specify this task is a subtask of another task. 346 Here is an example of use:: 348 class OtherTaskConfig(lsst.pex.config.Config) 349 aSubtask = ATaskClass.makeField("a brief description of what this task does") 351 return ConfigurableField(doc=doc, target=cls)
◆ makeSubtask()
def lsst.pipe.base.task.Task.makeSubtask |
( |
|
self, |
|
|
|
name, |
|
|
|
keyArgs |
|
) |
| |
|
inherited |
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".
Notes
-----
The subtask must be defined by ``Task.config.name``, an instance of pex_config ConfigurableField
or RegistryField.
Definition at line 275 of file task.py.
275 def makeSubtask(self, name, **keyArgs):
276 """Create a subtask as a new instance as the ``name`` attribute of this task. 281 Brief name of the subtask. 283 Extra keyword arguments used to construct the task. The following arguments are automatically 284 provided and cannot be overridden: 291 The subtask must be defined by ``Task.config.name``, an instance of pex_config ConfigurableField 294 taskField = getattr(self.config, name,
None)
295 if taskField
is None:
296 raise KeyError(
"%s's config does not have field %r" % (self.getFullName(), name))
297 subtask = taskField.apply(name=name, parentTask=self, **keyArgs)
298 setattr(self, name, subtask)
◆ parseAndRun()
def lsst.pipe.tasks.ingest.IngestTask.parseAndRun |
( |
|
cls | ) |
|
|
inherited |
Parse the command-line arguments and run the Task
Definition at line 419 of file ingest.py.
419 def parseAndRun(cls):
420 """Parse the command-line arguments and run the Task""" 421 config = cls.ConfigClass()
422 parser = cls.ArgumentParser(name=cls._DefaultName)
423 args = parser.parse_args(config)
424 task =
cls(config=args.config)
◆ run()
def lsst.pipe.tasks.ingestDefects.IngestDefectsTask.run |
( |
|
self, |
|
|
|
args |
|
) |
| |
Ingest all defect files and add them to the registry
Definition at line 35 of file ingestDefects.py.
36 """Ingest all defect files and add them to the registry""" 39 camera = args.butler.get(
'camera')
40 temp_dir = tempfile.mkdtemp()
45 file_name = f
'defects_{d}_{s.isoformat()}.fits' 46 full_file_name = os.path.join(temp_dir, file_name)
47 self.log.
info(
'%i defects written for sensor: %s and calibDate: %s' %
48 (len(defects[d][s]), d, s.isoformat()))
49 defects[d][s].writeFits(full_file_name)
50 file_names.append(full_file_name)
51 args.files = file_names
54 IngestCalibsTask.run(self, args)
56 shutil.rmtree(temp_dir)
57 def read_all_defects(root, camera)
def run(self, skyInfo, tempExpRefList, imageScalerList, weightList, altMaskList=None, mask=None, supplementaryData=None)
◆ runFile()
def lsst.pipe.tasks.ingest.IngestTask.runFile |
( |
|
self, |
|
|
|
infile, |
|
|
|
registry, |
|
|
|
args |
|
) |
| |
|
inherited |
Examine and ingest a single file.
- Parameters
-
infile | File to process |
args | Parsed command-line arguments |
- Returns
- parsed information from FITS HDUs or None
Definition at line 518 of file ingest.py.
518 def runFile(self, infile, registry, args):
519 """!Examine and ingest a single file 521 @param infile: File to process 522 @param args: Parsed command-line arguments 523 @return parsed information from FITS HDUs or None 525 if self.isBadFile(infile, args.badFile):
526 self.log.
info(
"Skipping declared bad file %s" % infile)
529 fileInfo, hduInfoList = self.parse.
getInfo(infile)
530 except Exception
as e:
531 if not self.config.allowError:
533 self.log.
warn(
"Error parsing %s (%s); skipping" % (infile, e))
535 if self.isBadId(fileInfo, args.badId.idList):
536 self.log.
info(
"Skipping declared bad file %s: %s" % (infile, fileInfo))
538 if registry
is not None and self.register.check(registry, fileInfo):
539 if args.ignoreIngested:
541 self.log.
warn(
"%s: already ingested: %s" % (infile, fileInfo))
542 outfile = self.parse.getDestination(args.butler, fileInfo, infile)
543 if not self.ingest(infile, outfile, mode=args.mode, dryrun=args.dryrun):
◆ timer()
def lsst.pipe.base.task.Task.timer |
( |
|
self, |
|
|
|
name, |
|
|
|
logLevel = Log.DEBUG |
|
) |
| |
|
inherited |
Context manager to log performance data for an arbitrary block of code.
Parameters
----------
name : `str`
Name of code being timed; data will be logged using item name: ``Start`` and ``End``.
logLevel
A `lsst.log` level constant.
Examples
--------
Creating a timer context::
with self.timer("someCodeToTime"):
pass # code to time
See also
--------
timer.logInfo
Definition at line 301 of file task.py.
301 def timer(self, name, logLevel=Log.DEBUG):
302 """Context manager to log performance data for an arbitrary block of code. 307 Name of code being timed; data will be logged using item name: ``Start`` and ``End``. 309 A `lsst.log` level constant. 313 Creating a timer context:: 315 with self.timer("someCodeToTime"): 322 logInfo(obj=self, prefix=name +
"Start", logLevel=logLevel)
326 logInfo(obj=self, prefix=name +
"End", logLevel=logLevel)
def logInfo(obj, prefix, logLevel=Log.DEBUG)
◆ ArgumentParser
lsst.pipe.tasks.ingestDefects.IngestDefectsTask.ArgumentParser |
|
static |
◆ config
lsst.pipe.base.task.Task.config |
|
inherited |
◆ ConfigClass
lsst.pipe.tasks.ingestDefects.IngestDefectsTask.ConfigClass |
|
static |
◆ log
lsst.pipe.base.task.Task.log |
|
inherited |
◆ metadata
lsst.pipe.base.task.Task.metadata |
|
inherited |
The documentation for this class was generated from the following file:
- /j/snowflake/release/lsstsw/stack/Linux64/pipe_tasks/19.0.0+3/python/lsst/pipe/tasks/ingestDefects.py