LSSTApplications  21.0.0+37efb4748c,21.0.0+d529cf1a41,21.0.0-1-g763706f+6421b4843a,21.0.0-1-ga51b5d4+6432c6fd8d,21.0.0-12-gb58d4cc3+949a467db4,21.0.0-2-g103fe59+aca4f75afe,21.0.0-2-g1367e85+181fee7d9e,21.0.0-2-g2909d54+37efb4748c,21.0.0-2-g35ce6d5+6421b4843a,21.0.0-2-g45278ab+d529cf1a41,21.0.0-2-g4bc9b9f+08d353aae0,21.0.0-2-g5242d73+181fee7d9e,21.0.0-2-g54e2caa+61c423f472,21.0.0-2-g5dd23de+8d1b0dada6,21.0.0-2-g66bcc37+6421b4843a,21.0.0-2-g7f82c8f+4ec738cb2a,21.0.0-2-g8dde007+ad96df9df1,21.0.0-2-g8f08a60+4fac22bdb7,21.0.0-2-g973f35b+6dae26221f,21.0.0-2-ga326454+4ec738cb2a,21.0.0-2-ga63a54e+d52114195a,21.0.0-2-ga885a99+c1363b8d99,21.0.0-2-gc738bc1+c663aa589a,21.0.0-2-gde069b7+44dbdb3492,21.0.0-2-ge17e5af+181fee7d9e,21.0.0-2-ge712728+5916d5b72f,21.0.0-2-gecfae73+727fd727a7,21.0.0-2-gfc62afb+181fee7d9e,21.0.0-3-g4c5b185+e92e89f28a,21.0.0-3-g5051ac2+d529cf1a41,21.0.0-3-gaa929c8+54eb6ec8b5,21.0.0-3-gd222c45+88b21af515,21.0.0-3-gf22bc3e+ca784bd997,21.0.0-4-g051ac7e+54eb6ec8b5,21.0.0-4-g42917e2+7988b1f7d3,21.0.0-6-g2b8c1f54+e7fb5877da,21.0.0-6-ge3f375325+ce03d725a7,21.0.0-9-g0393deb+2a5fe077cf,w.2020.50
LSSTDataManagementBasePackage
makeGen3DcrSubfilters.py
Go to the documentation of this file.
1 # This file is part of pipe_tasks.
2 #
3 # Developed for the LSST Data Management System.
4 # This product includes software developed by the LSST Project
5 # (https://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 <https://www.gnu.org/licenses/>.
21 import lsst.pex.config as pexConfig
22 import lsst.pipe.base as pipeBase
23 
24 from sqlalchemy.exc import IntegrityError
25 
26 
27 class MakeGen3DcrSubfiltersConfig(pexConfig.Config):
28  """Config for MakeGen3DcrSubfiltersTask.
29  """
30  numSubfilters = pexConfig.Field(
31  doc="The number of subfilters to be used for chromatic modeling.",
32  dtype=int,
33  default=3,
34  optional=False
35  )
36  filterNames = pexConfig.ListField(
37  doc="The filters to add chromatic subfilters to in the registry.",
38  dtype=str,
39  default=["g"],
40  optional=False
41  )
42 
43 
44 class MakeGen3DcrSubfiltersTask(pipeBase.Task):
45  ConfigClass = MakeGen3DcrSubfiltersConfig
46  _DefaultName = "makeGen3DcrSubfilters"
47 
48  """This is a task to construct the set of subfilters for chromatic modeling.
49 
50  Parameters
51  ----------
52  config : `MakeGen3DcrSubfiltersConfig` or None
53  Instance of a configuration class specifying task options, a default
54  config is created if value is None
55  """
56 
57  def __init__(self, *, config=None, **kwargs):
58  super().__init__(config=config, **kwargs)
59 
60  def run(self, butler):
61  """Construct a set of subfilters for chromatic modeling.
62 
63  Parameters
64  ----------
65  butler : `lsst.daf.butler.Butler`
66  Butler repository to add the subfilter definitions to.
67  """
68  with butler.registry.transaction():
69  try:
70  self.register(butler.registry)
71  except IntegrityError as err:
72  raise RuntimeError(f"Subfilters for at least one filter of {self.config.filterNames} "
73  "are already defined.") from err
74 
75  def register(self, registry):
76  """Add Subfilters to the given registry.
77 
78  Parameters
79  ----------
80  registry : `lsst.daf.butler.Registry`
81  The registry to add to.
82  """
83  record = []
84  for filterName in self.config.filterNames:
85  self.log.info(f"Initializing filter {filterName} with "
86  f"{self.config.numSubfilters} subfilters")
87  for sub in range(self.config.numSubfilters):
88  record.append({
89  "band": filterName,
90  "subfilter": sub
91  })
92  registry.insertDimensionData("subfilter", *record)
lsst::log.log.logContinued.info
def info(fmt, *args)
Definition: logContinued.py:201
lsst.pipe.tasks.makeGen3DcrSubfilters.MakeGen3DcrSubfiltersConfig
Definition: makeGen3DcrSubfilters.py:27
lsst.pipe.tasks.makeGen3DcrSubfilters.MakeGen3DcrSubfiltersTask
Definition: makeGen3DcrSubfilters.py:44
lsst.pipe.tasks.makeGen3DcrSubfilters.MakeGen3DcrSubfiltersTask.__init__
def __init__(self, *config=None, **kwargs)
Definition: makeGen3DcrSubfilters.py:57
lsst.pex.config
Definition: __init__.py:1
lsst.pipe.tasks.makeGen3DcrSubfilters.MakeGen3DcrSubfiltersTask.register
def register(self, registry)
Definition: makeGen3DcrSubfilters.py:75
lsst.pipe.tasks.makeGen3DcrSubfilters.MakeGen3DcrSubfiltersTask.run
def run(self, butler)
Definition: makeGen3DcrSubfilters.py:60
lsst.pipe.base
Definition: __init__.py:1