24 from lsst.daf.butler
import Butler
25 from lsst.pipe.base.configOverrides
import ConfigOverrides
29 def ingestRaws(repo, output_run, config=None, config_file=None, directory=None, file=None, transfer="auto",
30 ingest_task="lsst.obs.base.RawIngestTask"):
31 """Ingests raw frames into the butler registry
36 URI to the repository.
38 The path to the location, the run, where datasets should be put.
39 config : `dict` [`str`, `str`] or `None`
40 Key-vaule pairs to apply as overrides to the ingest config.
41 config_file : `str` or `None`
42 Path to a config file that contains overrides to the ingest config.
43 directory : `str` or `None`
44 Path to the directory containing the raws to ingest.
45 file : `str` or `None`
46 Path to a file containing raws to ingest.
47 transfer : `str` or None
48 The external data transfer type, by default "auto".
50 The fully qualified class name of the ingest task to use by default
51 lsst.obs.base.RawIngestTask.
56 Raised if operations on configuration object fail.
58 butler = Butler(repo, writeable=
True)
59 TaskClass = doImport(ingest_task)
60 ingestConfig = TaskClass.ConfigClass()
61 ingestConfig.transfer = transfer
62 configOverrides = ConfigOverrides()
63 if config_file
is not None:
64 configOverrides.addFileOverride(config_file)
65 if config
is not None:
66 for name, value
in config:
67 configOverrides.addValueOverride(name, value)
68 configOverrides.applyTo(ingestConfig)
69 ingester = TaskClass(config=ingestConfig, butler=butler)
70 files = [file]
if file
is not None else []
71 if directory
is not None:
72 suffixes = (
".fits",
".fits.gz",
".fits.fz")
74 [os.path.join(directory, f)
for f
in os.listdir(directory)
if f.lower().endswith(suffixes)])
75 ingester.run(files, run=output_run)