Coverage for python/lsst/obs/base/script/defineVisits.py: 24%
Shortcuts 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
Shortcuts 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/>.
21import logging
23from lsst.daf.butler import Butler
24from lsst.obs.base import DefineVisitsTask, DefineVisitsConfig
25from ..utils import getInstrument
27log = logging.getLogger("defineVisits")
30def defineVisits(repo, config_file, collections, instrument, processes=1):
31 """Implements the command line interface `butler define-visits` subcommand,
32 should only be called by command line tools and unit test code that tests
33 this function.
35 Defines visits from exposures in the butler registry
37 Parameters
38 ----------
39 repo : `str`
40 URI to the location to create the repo.
41 config_file : `str` or `None`
42 Path to a config file that contains overrides to the ingest config.
43 collections : `list` [`str`]
44 An expression specifying the collections to be searched (in order) when
45 reading datasets, and optionally dataset type restrictions on them.
46 If empty it will be passed as `None` to Butler.
47 instrument : `str`
48 The name or fully-qualified class name of an instrument.
50 Notes
51 -----
52 Camera geometry is not currently found in registry but instead a default
53 camera will be used for the relevant instrument.
54 """
55 if not collections:
56 collections = None
57 butler = Butler(repo, collections=collections, writeable=True)
58 instr = getInstrument(instrument, butler.registry)
59 config = DefineVisitsConfig()
60 instr.applyConfigOverrides(DefineVisitsTask._DefaultName, config)
62 if collections is None:
63 # Default to the raw collection for this instrument
64 collections = instr.makeDefaultRawIngestRunName()
65 log.info("Defaulting to searching for raw exposures in collection %s", collections)
67 if config_file is not None:
68 config.load(config_file)
69 task = DefineVisitsTask(config=config, butler=butler)
71 # Assume the dataset type is "raw" -- this is required to allow this
72 # query to filter out exposures not relevant to the specified collection.
73 task.run(butler.registry.queryDataIds(["exposure"], dataId={"instrument": instr.getName()},
74 collections=collections, datasets="raw"),
75 collections=collections, processes=processes)