Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# This file is part of obs_base. 

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/>. 

21 

22import os 

23 

24from lsst.daf.butler import Butler 

25from lsst.pipe.base.configOverrides import ConfigOverrides 

26from lsst.utils import doImport 

27 

28 

29def 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 

32 

33 Parameters 

34 ---------- 

35 repo : `str` 

36 URI to the repository. 

37 output_run : `str` 

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". 

49 ingest_task : `str` 

50 The fully qualified class name of the ingest task to use by default 

51 lsst.obs.base.RawIngestTask. 

52 

53 Raises 

54 ------ 

55 `Exception` is raised if operations on configuration object fail. 

56 """ 

57 butler = Butler(repo, run=output_run) 

58 TaskClass = doImport(ingest_task) 

59 ingestConfig = TaskClass.ConfigClass() 

60 ingestConfig.transfer = transfer 

61 configOverrides = ConfigOverrides() 

62 if config_file is not None: 

63 configOverrides.addFileOverride(config_file) 

64 if config is not None: 

65 for name, value in config: 

66 configOverrides.addValueOverride(name, value) 

67 configOverrides.applyTo(ingestConfig) 

68 ingester = TaskClass(config=ingestConfig, butler=butler) 

69 files = [file] if file is not None else [] 

70 if directory is not None: 

71 files.extend( 

72 [os.path.join(directory, f) for f in os.listdir(directory) if f.lower().endswith("fits")]) 

73 ingester.run(files)