Coverage for python / lsst / obs / lsst / script / ingestAuxCalibs.py: 12%
43 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-30 09:16 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-30 09:16 +0000
1# This file is part of obs_lsst.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21from lsst.daf.butler import Butler
22from lsst.pipe.base.configOverrides import ConfigOverrides
23from lsst.pipe.base import Instrument
24from .. import PhotodiodeIngestTask, PhotodiodeIngestConfig
25from .._ingestAuxCalibs import (ShutterMotionOpenIngestConfig, ShutterMotionCloseIngestConfig,
26 ShutterMotionOpenIngestTask, ShutterMotionCloseIngestTask,
27 DEFAULT_SHUTTER_OPEN_REGEX, DEFAULT_SHUTTER_CLOSE_REGEX)
30def ingestPhotodiode(repo, instrument, locations, regex, output_run, config=None, config_file=None,
31 transfer="copy", track_file_attrs=True):
32 """Ingests photodiode data into the butler registry.
34 Parameters
35 ----------
36 repo : `str`
37 URI to the repository.
38 instrument : `str`
39 The name or fully-qualified class name of an instrument.
40 locations : `list` [`str`]
41 Files to ingest and directories to search for files that match
42 ``regex`` to ingest.
43 regex : `str`
44 Regex string used to find files in directories listed in locations.
45 output_run : `str`
46 The path to the location, the run, where datasets should be put.
47 config : `dict` [`str`, `str`] or `None`
48 Key-value pairs to apply as overrides to the ingest config.
49 config_file : `str` or `None`
50 Path to a config file that contains overrides to the ingest config.
51 transfer : `str` or None
52 The external data transfer type, by default "copy".
53 track_file_attrs : `bool`, optional
54 Control whether file attributes such as the size or checksum should
55 be tracked by the datastore. Whether this parameter is honored
56 depends on the specific datastore implentation.
58 Raises
59 ------
60 Exception
61 Raised if operations on configuration object fail.
62 """
63 with Butler.from_config(repo, writeable=True) as butler:
64 instr = Instrument.from_string(instrument, butler.registry)
66 # We'll reuse `config`, so get the overrides stored first.
67 configOverrides = ConfigOverrides()
68 if config_file is not None:
69 configOverrides.addFileOverride(config_file)
70 if config is not None:
71 for name, value in config.items():
72 configOverrides.addValueOverride(name, value)
74 config = PhotodiodeIngestConfig()
75 config.transfer = transfer
76 configOverrides.applyTo(config)
78 task = PhotodiodeIngestTask(butler=butler, instrument=instr, config=config)
79 task.run(locations, run=output_run, file_filter=regex,
80 track_file_attrs=track_file_attrs)
83def ingestShutterMotion(repo, instrument, locations, regex, output_run, config=None, config_file=None,
84 transfer="copy", track_file_attrs=True):
85 """Ingests shutter motion profiles into the butler registry.
87 Parameters
88 ----------
89 repo : `str`
90 URI to the repository.
91 instrument : `str`
92 The name or fully-qualified class name of an instrument.
93 locations : `list` [`str`]
94 Files to ingest and directories to search for files that match
95 ``regex`` to ingest.
96 regex : `str`
97 Regex string used to find files in directories listed in locations.
98 output_run : `str`
99 The path to the location, the run, where datasets should be put.
100 config : `dict` [`str`, `str`] or `None`
101 Key-value pairs to apply as overrides to the ingest config.
102 config_file : `str` or `None`
103 Path to a config file that contains overrides to the ingest config.
104 transfer : `str` or None
105 The external data transfer type, by default "copy".
106 track_file_attrs : `bool`, optional
107 Control whether file attributes such as the size or checksum should
108 be tracked by the datastore. Whether this parameter is honored
109 depends on the specific datastore implentation.
111 Raises
112 ------
113 Exception
114 Raised if operations on configuration object fail.
115 """
116 with Butler.from_config(repo, writeable=True) as butler:
117 instr = Instrument.from_string(instrument, butler.registry)
118 if regex is None:
119 # This is the case we want.
120 openRegex = DEFAULT_SHUTTER_OPEN_REGEX
121 closeRegex = DEFAULT_SHUTTER_CLOSE_REGEX
122 else:
123 openRegex = regex
124 closeRegex = regex
126 # Store the overrides first:
127 configOverrides = ConfigOverrides()
128 if config_file is not None:
129 configOverrides.addFileOverride(config_file)
130 if config is not None:
131 for name, value in config.items():
132 configOverrides.addValueOverride(name, value)
134 configOpen = ShutterMotionOpenIngestConfig()
135 configOpen.transfer = transfer
136 configOverrides.applyTo(configOpen)
138 task = ShutterMotionOpenIngestTask(butler=butler, instrument=instr, config=configOpen)
139 task.run(locations, run=output_run, file_filter=openRegex,
140 track_file_attrs=track_file_attrs)
142 configClose = ShutterMotionCloseIngestConfig()
143 configClose.transfer = transfer
144 configOverrides.applyTo(configClose)
145 task = ShutterMotionCloseIngestTask(butler=butler, instrument=instr, config=configClose)
146 task.run(locations, run=output_run, file_filter=closeRegex,
147 track_file_attrs=track_file_attrs)