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 click 

23 

24from lsst.daf.butler.cli.opt import (repo_argument, config_option, config_file_option, locations_argument, 

25 regex_option, run_option, transfer_option) 

26from lsst.daf.butler.cli.utils import (cli_handle_exception, split_commas, typeStrAcceptsMultiple) 

27from ..opt import instrument_argument, instrument_option 

28from ... import script 

29 

30 

31# regular expression that can be used to find supported fits file extensions. 

32fits_re = r"\.fit[s]?\b" 

33 

34 

35@click.command(short_help="Convert a gen2 repo to gen3.") 

36@repo_argument(required=True, 

37 help="REPO is the URI or path to the gen3 repository. Will be created if it does not already " 

38 "exist") 

39@click.option("--gen2root", required=True, 

40 help="Root path of the gen 2 repo to be converted.") 

41@click.option("--skymap-name", 

42 help="Name of the new gen3 skymap (e.g. 'discrete/ci_hsc').") 

43@click.option("--skymap-config", 

44 help="Path to skymap config file defining the new gen3 skymap.") 

45@click.option("--calibs", 

46 help="Path to the gen 2 calibration repo. It can be absolute or relative to gen2root.") 

47@click.option("--reruns", multiple=True, callback=split_commas, metavar=typeStrAcceptsMultiple, 

48 help="List of gen 2 reruns to convert.") 

49@transfer_option(help="Mode to use to transfer files into the new repository.") 

50@config_file_option(help="Path to a `ConvertRepoConfig` override to be included after the Instrument config " 

51 "overrides are applied.") 

52def convert(*args, **kwargs): 

53 """Convert a Butler gen 2 repository into a gen 3 repository.""" 

54 cli_handle_exception(script.convert, *args, **kwargs) 

55 

56 

57@click.command(short_help="Define visits from exposures.") 

58@repo_argument(required=True) 

59@config_file_option(help="Path to a pex_config override to be included after the Instrument config overrides " 

60 "are applied.") 

61@click.option("--collections", 

62 help="The collections to be searched (in order) when reading datasets.", 

63 multiple=True, 

64 callback=split_commas, 

65 metavar=typeStrAcceptsMultiple) 

66@instrument_option(required=True) 

67def define_visits(*args, **kwargs): 

68 """Define visits from exposures in the butler registry.""" 

69 cli_handle_exception(script.defineVisits, *args, **kwargs) 

70 

71 

72@click.command(short_help="Ingest raw frames.") 

73@repo_argument(required=True) 

74@locations_argument(help="LOCATIONS specifies files to ingest and/or locations to search for files.", 

75 required=True) 

76@regex_option(default=fits_re, 

77 help="Regex string used to find files in directories listed in LOCATIONS. " 

78 "Searches for fits files by default.") 

79@config_option(metavar="TEXT=TEXT", multiple=True) 

80@config_file_option(type=click.Path(exists=True, writable=False, file_okay=True, dir_okay=False)) 

81@run_option(required=False) 

82@transfer_option() 

83@click.option("--ingest-task", default="lsst.obs.base.RawIngestTask", help="The fully qualified class name " 

84 "of the ingest task to use.") 

85def ingest_raws(*args, **kwargs): 

86 """Ingest raw frames into from a directory into the butler registry""" 

87 cli_handle_exception(script.ingestRaws, *args, **kwargs) 

88 

89 

90@click.command(short_help="Add an instrument to the repository") 

91@repo_argument(required=True) 

92@instrument_argument(required=True, nargs=-1, help="The fully-qualified name of an Instrument subclass.") 

93def register_instrument(*args, **kwargs): 

94 """Add an instrument to the data repository. 

95 """ 

96 cli_handle_exception(script.registerInstrument, *args, **kwargs) 

97 

98 

99@click.command(short_help="Add an instrument's curated calibrations.") 

100@repo_argument(required=True) 

101@instrument_option(required=True) 

102@run_option(required=False) 

103def write_curated_calibrations(*args, **kwargs): 

104 """Add an instrument's curated calibrations to the data repository. 

105 """ 

106 cli_handle_exception(script.writeCuratedCalibrations, *args, **kwargs)