LSST Applications g02d81e74bb+86cf3d8bc9,g180d380827+7a4e862ed4,g2079a07aa2+86d27d4dc4,g2305ad1205+e1ca1c66fa,g29320951ab+012e1474a1,g295015adf3+341ea1ce94,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+c429d67c83,g48712c4677+f88676dd22,g487adcacf7+27e1e21933,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+b41db86c35,g5a732f18d5+53520f316c,g64a986408d+86cf3d8bc9,g858d7b2824+86cf3d8bc9,g8a8a8dda67+585e252eca,g99cad8db69+84912a7fdc,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+a2b54eae19,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+6681f309db,gc120e1dc64+f0fcc2f6d8,gc28159a63d+0e5473021a,gcf0d15dbbd+c429d67c83,gdaeeff99f8+f9a426f77a,ge6526c86ff+0433e6603d,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+86cf3d8bc9,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
lsst.pipe.tasks.colorterms.ColortermLibrary Class Reference
Inheritance diagram for lsst.pipe.tasks.colorterms.ColortermLibrary:
lsst.pex.config.config.Config lsst.pex.config.config.ConfigMeta

Public Member Functions

 getColorterm (self, physicalFilter, photoCatName, doRaise=True)
 

Static Public Attributes

 data
 

Detailed Description

A mapping of photometric reference catalog name or glob to ColortermDict

Notes
-----
This allows photometric calibration using a variety of reference catalogs.

To construct a ColortermLibrary, use keyword arguments:
ColortermLibrary(data=dataDict)
where dataDict is a Python dict of catalog_name_or_glob: ColortermDict

Examples
--------

.. code-block:: none

    ColortermLibrary(data = {
        "hsc": ColortermDict(data={
            'g': Colorterm(primary="g", secondary="g"),
            'r': Colorterm(primary="r", secondary="r"),
            ...
        }),
        "sdss": ColortermDict(data={
            'g':    Colorterm(primary="g",
                              secondary="r",
                              c0=-0.00816446,
                              c1=-0.08366937,
                              c2=-0.00726883),
            'r':    Colorterm(primary="r",
                              secondary="i",
                              c0= 0.00231810,
                              c1= 0.01284177,
                              c2=-0.03068248),
            ...
        }),
    })

This is subclass of Config. That is a bit of a hack to make it easy to store the data
in an appropriate obs package as a config override file. In the long term some other
means of persistence will be used, at which point the constructor can be made saner.

Definition at line 205 of file colorterms.py.

Member Function Documentation

◆ getColorterm()

lsst.pipe.tasks.colorterms.ColortermLibrary.getColorterm ( self,
physicalFilter,
photoCatName,
doRaise = True )
Get the appropriate Colorterm from the library

Use dict of color terms in the library that matches the photoCatName.
If the photoCatName exactly matches an entry in the library, that
dict is used; otherwise if the photoCatName matches a single glob (shell syntax,
e.g., "sdss-*" will match "sdss-dr8"), then that is used. If there is no
exact match and no unique match to the globs, raise an exception.

Parameters
----------
physicalFilter : `str`
    Label of physical filter to correct to.
photoCatName : `str`
    Name of photometric reference catalog from which to retrieve the data.
    This argument is not glob-expanded (but the catalog names in the library are,
    if no exact match is found).
doRaise : `bool`
    If True then raise ColortermNotFoundError if no suitable Colorterm found;
    If False then return a null Colorterm with physicalFilter as the primary and secondary filter.

Returns
-------
ctDict : `Unknown`
    The appropriate Colorterm.

Raises
------
ColortermNotFoundError
    If no suitable Colorterm found and doRaise true;
    other exceptions may be raised for unexpected errors, regardless of the value of doRaise.

Definition at line 253 of file colorterms.py.

253 def getColorterm(self, physicalFilter, photoCatName, doRaise=True):
254 """Get the appropriate Colorterm from the library
255
256 Use dict of color terms in the library that matches the photoCatName.
257 If the photoCatName exactly matches an entry in the library, that
258 dict is used; otherwise if the photoCatName matches a single glob (shell syntax,
259 e.g., "sdss-*" will match "sdss-dr8"), then that is used. If there is no
260 exact match and no unique match to the globs, raise an exception.
261
262 Parameters
263 ----------
264 physicalFilter : `str`
265 Label of physical filter to correct to.
266 photoCatName : `str`
267 Name of photometric reference catalog from which to retrieve the data.
268 This argument is not glob-expanded (but the catalog names in the library are,
269 if no exact match is found).
270 doRaise : `bool`
271 If True then raise ColortermNotFoundError if no suitable Colorterm found;
272 If False then return a null Colorterm with physicalFilter as the primary and secondary filter.
273
274 Returns
275 -------
276 ctDict : `Unknown`
277 The appropriate Colorterm.
278
279 Raises
280 ------
281 ColortermNotFoundError
282 If no suitable Colorterm found and doRaise true;
283 other exceptions may be raised for unexpected errors, regardless of the value of doRaise.
284 """
285 try:
286 trueRefCatName = None
287 ctDictConfig = self.data.get(photoCatName)
288 if ctDictConfig is None:
289 # try glob expression
290 matchList = [libRefNameGlob for libRefNameGlob in self.data
291 if fnmatch.fnmatch(photoCatName, libRefNameGlob)]
292 if len(matchList) == 1:
293 trueRefCatName = matchList[0]
294 ctDictConfig = self.data[trueRefCatName]
295 elif len(matchList) > 1:
296 raise ColortermNotFoundError(
297 "Multiple library globs match photoCatName %r: %s" % (photoCatName, matchList))
298 else:
299 raise ColortermNotFoundError(
300 "No colorterm dict found with photoCatName %r" % photoCatName)
301 ctDict = ctDictConfig.data
302 if physicalFilter not in ctDict:
303 errMsg = "No colorterm found for filter %r with photoCatName %r" % (
304 physicalFilter, photoCatName)
305 if trueRefCatName is not None:
306 errMsg += " = catalog %r" % (trueRefCatName,)
307 raise ColortermNotFoundError(errMsg)
308 return ctDict[physicalFilter]
309 except ColortermNotFoundError:
310 if doRaise:
311 raise
312 else:
313 return Colorterm(physicalFilter, physicalFilter)

Member Data Documentation

◆ data

lsst.pipe.tasks.colorterms.ColortermLibrary.data
static
Initial value:
= ConfigDictField(
doc="Mapping of reference catalog name (or glob) to ColortermDict",
keytype=str,
itemtype=ColortermDict,
default={},
)

Definition at line 246 of file colorterms.py.


The documentation for this class was generated from the following file: