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("lsst.obs.base.defineVisits")
30def defineVisits(repo, config_file, collections, instrument, processes=1, raw_name="raw"):
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.
49 raw_name : `str`, optional
50 Name of the raw dataset type name. Defaults to 'raw'.
52 Notes
53 -----
54 Camera geometry is not currently found in registry but instead a default
55 camera will be used for the relevant instrument.
56 """
57 if not collections:
58 collections = None
59 butler = Butler(repo, collections=collections, writeable=True)
60 instr = getInstrument(instrument, butler.registry)
61 config = DefineVisitsConfig()
62 instr.applyConfigOverrides(DefineVisitsTask._DefaultName, config)
64 if collections is None:
65 # Default to the raw collection for this instrument
66 collections = instr.makeDefaultRawIngestRunName()
67 log.info("Defaulting to searching for raw exposures in collection %s", collections)
69 if config_file is not None:
70 config.load(config_file)
71 task = DefineVisitsTask(config=config, butler=butler)
73 # Assume the dataset type is "raw" -- this is required to allow this
74 # query to filter out exposures not relevant to the specified collection.
75 task.run(butler.registry.queryDataIds(["exposure"], dataId={"instrument": instr.getName()},
76 collections=collections, datasets=raw_name),
77 collections=collections, processes=processes)