Coverage for python/lsst/obs/lsst/script/ingestPhotodiode.py: 21%

18 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-03-05 02:56 -0800

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 

25 

26 

27def ingestPhotodiode(repo, instrument, locations, regex, output_run, config=None, config_file=None, 

28 transfer="copy", track_file_attrs=True): 

29 """Ingests photodiode data into the butler registry. 

30 

31 Parameters 

32 ---------- 

33 repo : `str` 

34 URI to the repository. 

35 instrument : `str` 

36 The name or fully-qualified class name of an instrument. 

37 locations : `list` [`str`] 

38 Files to ingest and directories to search for files that match 

39 ``regex`` to ingest. 

40 regex : `str` 

41 Regex string used to find files in directories listed in locations. 

42 output_run : `str` 

43 The path to the location, the run, where datasets should be put. 

44 config : `dict` [`str`, `str`] or `None` 

45 Key-value pairs to apply as overrides to the ingest config. 

46 config_file : `str` or `None` 

47 Path to a config file that contains overrides to the ingest config. 

48 transfer : `str` or None 

49 The external data transfer type, by default "copy". 

50 track_file_attrs : `bool`, optional 

51 Control whether file attributes such as the size or checksum should 

52 be tracked by the datastore. Whether this parameter is honored 

53 depends on the specific datastore implentation. 

54 

55 Raises 

56 ------ 

57 Exception 

58 Raised if operations on configuration object fail. 

59 """ 

60 butler = Butler(repo, writeable=True) 

61 instr = Instrument.from_string(instrument, butler.registry) 

62 

63 config = PhotodiodeIngestConfig() 

64 config.transfer = transfer 

65 configOverrides = ConfigOverrides() 

66 if config_file is not None: 

67 configOverrides.addFileOverride(config_file) 

68 if config is not None: 

69 for name, value in config.items(): 

70 configOverrides.addValueOverride(name, value) 

71 configOverrides.applyTo(config) 

72 

73 task = PhotodiodeIngestTask(butler=butler, instrument=instr, config=config) 

74 task.run(locations, run=output_run, file_filter=regex, 

75 track_file_attrs=track_file_attrs)