LSST Applications  21.0.0+75b29a8a7f,21.0.0+e70536a077,21.0.0-1-ga51b5d4+62c747d40b,21.0.0-10-gbfb87ad6+3307648ee3,21.0.0-15-gedb9d5423+47cba9fc36,21.0.0-2-g103fe59+fdf0863a2a,21.0.0-2-g1367e85+d38a93257c,21.0.0-2-g45278ab+e70536a077,21.0.0-2-g5242d73+d38a93257c,21.0.0-2-g7f82c8f+e682ffb718,21.0.0-2-g8dde007+d179fbfa6a,21.0.0-2-g8f08a60+9402881886,21.0.0-2-ga326454+e682ffb718,21.0.0-2-ga63a54e+08647d4b1b,21.0.0-2-gde069b7+26c92b3210,21.0.0-2-gecfae73+0445ed2f95,21.0.0-2-gfc62afb+d38a93257c,21.0.0-27-gbbd0d29+ae871e0f33,21.0.0-28-g5fc5e037+feb0e9397b,21.0.0-3-g21c7a62+f4b9c0ff5c,21.0.0-3-g357aad2+57b0bddf0b,21.0.0-3-g4be5c26+d38a93257c,21.0.0-3-g65f322c+3f454acf5d,21.0.0-3-g7d9da8d+75b29a8a7f,21.0.0-3-gaa929c8+9e4ef6332c,21.0.0-3-ge02ed75+4b120a55c4,21.0.0-4-g3300ddd+e70536a077,21.0.0-4-g591bb35+4b120a55c4,21.0.0-4-gc004bbf+4911b9cd27,21.0.0-4-gccdca77+f94adcd104,21.0.0-4-ge8fba5a+2b3a696ff9,21.0.0-5-gb155db7+2c5429117a,21.0.0-5-gdf36809+637e4641ee,21.0.0-6-g00874e7+c9fd7f7160,21.0.0-6-g4e60332+4b120a55c4,21.0.0-7-gc8ca178+40eb9cf840,21.0.0-8-gfbe0b4b+9e4ef6332c,21.0.0-9-g2fd488a+d83b7cd606,w.2021.05
LSST Data Management Base Package
commands.py
Go to the documentation of this file.
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 
22 import click
23 
24 from lsst.daf.butler.cli.opt import (repo_argument,
25  config_option,
26  config_file_option,
27  locations_argument,
28  options_file_option,
29  processes_option,
30  regex_option,
31  run_option,
32  transfer_option
33  )
34 from lsst.daf.butler.cli.utils import (
35  ButlerCommand,
36  split_commas,
37  typeStrAcceptsMultiple
38 )
39 from ..opt import instrument_argument
40 from ... import script
41 
42 
43 # regular expression that can be used to find supported fits file extensions.
44 fits_re = r"\.fit[s]?\b"
45 
46 
47 @click.command(short_help="Convert a gen2 repo to gen3.", cls=ButlerCommand)
48 @repo_argument(required=True, help="REPO is the URI or path to the gen3 repository. Will be created if it does not already " "exist")
49 @click.option("--gen2root", required=True, help="Root path of the gen 2 repo to be converted.")
50 @click.option("--skymap-name", help="Name of the new gen3 skymap (e.g. 'discrete/ci_hsc').")
51 @click.option("--skymap-config", help="Path to skymap config file defining the new gen3 skymap.")
52 @click.option("--calibs", help="Path to the gen 2 calibration repo. It can be absolute or relative to gen2root.")
53 @click.option("--reruns", multiple=True, callback=split_commas, metavar=typeStrAcceptsMultiple, help=("List of rerun paths to convert. Output collection names will be " "guessed, which can fail if the Gen2 repository paths do not follow a " "recognized convention. In this case, the command-line interface cannot " "be used."))
54 @transfer_option(help="Mode to use to transfer files into the new repository.")
55 @processes_option()
56 @config_file_option(help="Path to a `ConvertRepoConfig` override to be included after the Instrument config " "overrides are applied.")
57 @options_file_option()
58 def convert(*args, **kwargs):
59  """Convert one or more Butler gen 2 repositories into a gen 3 repository.
60 
61  This is a highly simplified interface that should only be used to convert
62  suites of gen 2 repositories that contain at most one calibration repo and
63  has no chained reruns. Custom scripts that call ConvertRepoTask should be
64  used on more complex suites of repositories.
65  """
66  script.convert(*args, **kwargs)
67 
68 
69 @click.command(short_help="Define visits from exposures.", cls=ButlerCommand)
70 @repo_argument(required=True)
71 @instrument_argument(required=True)
72 @config_file_option(help="Path to a pex_config override to be included after the Instrument config overrides " "are applied.")
73 @click.option("--collections", help="The collections to be searched (in order) when reading datasets.",
74  multiple=True,
75  callback=split_commas,
76  metavar=typeStrAcceptsMultiple)
77 @processes_option()
78 @options_file_option()
79 def define_visits(*args, **kwargs):
80  """Define visits from exposures in the butler registry."""
81  script.defineVisits(*args, **kwargs)
82 
83 
84 @click.command(short_help="Ingest raw frames.", cls=ButlerCommand)
85 @repo_argument(required=True)
86 @locations_argument(help="LOCATIONS specifies files to ingest and/or locations to search for files.", required=True)
87 @regex_option(default=fits_re, help="Regex string used to find files in directories listed in LOCATIONS. " "Searches for fits files by default.")
88 @config_option(metavar="TEXT=TEXT", multiple=True)
89 @config_file_option(type=click.Path(exists=True, writable=False, file_okay=True, dir_okay=False))
90 @run_option(required=False)
91 @transfer_option()
92 @processes_option()
93 @click.option("--ingest-task", default="lsst.obs.base.RawIngestTask", help="The fully qualified class name " "of the ingest task to use.")
94 @options_file_option()
95 def ingest_raws(*args, **kwargs):
96  """Ingest raw frames into from a directory into the butler registry"""
97  script.ingestRaws(*args, **kwargs)
98 
99 
100 @click.command(short_help="Add an instrument to the repository", cls=ButlerCommand)
101 @repo_argument(required=True)
102 @instrument_argument(required=True, nargs=-1, help="The fully-qualified name of an Instrument subclass.")
103 def register_instrument(*args, **kwargs):
104  """Add an instrument to the data repository.
105  """
106  script.registerInstrument(*args, **kwargs)
107 
108 
109 @click.command(short_help="Add an instrument's curated calibrations.", cls=ButlerCommand)
110 @repo_argument(required=True)
111 @instrument_argument(required=True)
112 @click.option("--collection", required=False, help="Name of the calibration collection that associates datasets with validity ranges.")
113 @click.option("--label", "labels", multiple=True, help=("Extra strings to include (with automatic delimiters) in all RUN collection names, "
114  "as well as the calibration collection name if it is not provided via --collection."))
115 @options_file_option()
116 def write_curated_calibrations(*args, **kwargs):
117  """Add an instrument's curated calibrations to the data repository.
118  """
119  script.writeCuratedCalibrations(*args, **kwargs)
120 
def convert(repo, gen2root, skymap_name, skymap_config, calibs, reruns, config_file, transfer, processes=1)
Definition: convert.py:35