Coverage for python/lsst/fgcmcal/sedterms.py : 70%

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 fgcmcal.
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"""Configuration for SED terms in fgcmcal.
22Analogous to colorterms.
23"""
25from lsst.pex.config import Config, Field, ConfigDictField
27__all__ = ["Sedterm", "SedtermDict", "Sedboundaryterm", "SedboundarytermDict"]
30class Sedboundaryterm(Config):
31 """SED boundary term for a pair of bands.
33 The SED slope (in flux units) at the boundary between two bands is given by:
35 S = -0.921 * (primary - secondary) / (lambda_primary - lambda_secondary)
37 To construct a Sedboundaryterm, use keyword arguments:
38 Sedboundaryterm(primary=primaryBandName, secondary=secondaryBandName)
40 This is a subclass of Config. This follows the form of
41 `lsst.pipe.tasks.Colorterm`.
42 """
43 primary = Field(dtype=str, doc="name of primary band")
44 secondary = Field(dtype=str, doc="name of secondary band")
47class SedboundarytermDict(Config):
48 """A mapping of Sedboundaryterm name to Sedterm.
50 To construct a SedboundarytermDict use keyword arguments:
51 SedboundarytermDict(data=dataDict)
52 where dataDict is a Python dict of name to Sedterm
53 For example:
54 SedboundarytermDict(data={
55 'gr': Sedboundaryterm(primary="g", secondary="r"),
56 'ri': Sedboundaryterm(primary="r", secondary="i"),
57 })
59 This is a subclass of Config. This follows the form of
60 `lsst.pipe.tasks.ColortermDict`.
61 """
62 data = ConfigDictField(
63 doc="Mapping of Sedboundary term name to Sedboundaryterm",
64 keytype=str,
65 itemtype=Sedboundaryterm,
66 default={},
67 )
70class Sedterm(Config):
71 """SED term for a single band.
73 The SED slope (in flux units) in the middle of a band is computed either
74 as an "interpolated" or "extrapolated" computation. See Burke et al. 2018
75 Appendix A (https://ui.adsabs.harvard.edu/abs/2018AJ....155...41B).
77 For interpolation, with a secondary term:
78 F'_nu ~ constant * (primaryTerm + secondaryTerm) / 2.0
80 For interpolation, without a secondary term:
81 F'_nu ~ constant * primaryTerm
83 For extrapolation:
84 F'_nu ~ primaryTerm + constant * (((lambda_primaryBand - lambda_secondaryBand) /
85 (lambda_primaryBand - lambda_tertiaryBand)) *
86 (primaryTerm - secondaryTerm))
88 where primaryTerm and secondaryTerm are names from a `SedboundarytermDict`, and
89 primaryBand, secondaryBand, and tertiaryBand are band names.
91 To construct a Sedterm, use keyword arguments:
92 Sedterm(primaryTerm=primaryTermName, secondaryTerm=secondaryTermName,
93 extrapolated=False, constant=1.0)
94 or
95 Sedterm(primaryTerm=primaryTermName, secondaryTerm=secondaryTermName,
96 extrapolated=True, constant=1.0, primaryBand=primaryBandName,
97 secondaryBand=secondaryBandName, tertiaryBand=tertiaryBandName)
99 This is a subclass of Config. This follows the form of
100 `lsst.pipe.tasks.Colorterm`.
101 """
102 primaryTerm = Field(dtype=str, doc="Name of primary Sedboundaryterm")
103 secondaryTerm = Field(dtype=str, default=None, optional=True,
104 doc="Name of secondary Sedboundaryterm")
105 extrapolated = Field(dtype=bool, default=False, doc="Extrapolate to compute SED slope")
106 constant = Field(dtype=float, default=1.0, doc="Adjustment constant for SED slope")
107 primaryBand = Field(dtype=str, default=None, optional=True,
108 doc="Primary band name for extrapolation")
109 secondaryBand = Field(dtype=str, default=None, optional=True,
110 doc="Secondary band name for extrapolation")
111 tertiaryBand = Field(dtype=str, default=None, optional=True,
112 doc="Tertiary band name for extrapolation")
114 def validate(self):
115 Config.validate(self)
116 if self.extrapolated:
117 if self.primaryBand is None or \
118 self.secondaryBand is None or \
119 self.tertiaryBand is None:
120 raise RuntimeError("extrapolated requires primaryBand, secondaryBand, and "
121 "tertiaryBand are provided.")
124class SedtermDict(Config):
125 """A mapping of bands to Sedterms.
127 To construct a SedtermDict use keyword arguments:
128 SedtermDict(data=dataDict)
129 where dataDict is a Python dict of band to Sedterm
130 For example:
131 SedtermDict(data={
132 'g': Sedterm(primaryTerm='gr', secondaryTerm='ri', extrapolated=True, constant=0.25,
133 primaryBand='g', secondaryBand='r', tertiaryBand='i'),
134 'r': Sedterm(primaryTerm='gr', secondaryTerm='ri', extrapolated=False)
135 })
137 This is a subclass of Config. This follows the form of
138 `lsst.pipe.tasks.ColortermDict`.
139 """
140 data = ConfigDictField(
141 doc="Mapping of band name to Sedterm",
142 keytype=str,
143 itemtype=Sedterm,
144 default={},
145 )