LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Static Public Attributes | List of all members
lsst.pipe.tasks.colorterms.ColortermLibrary Class Reference

A mapping of photometric reference catalog name or glob to ColortermDict. More...

Inheritance diagram for lsst.pipe.tasks.colorterms.ColortermLibrary:

Public Member Functions

def getColorterm
 Get the appropriate Colorterm from the library. More...
 

Static Public Attributes

tuple data
 

Detailed Description

A mapping of photometric reference catalog name or glob to ColortermDict.

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

For example: 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 112 of file colorterms.py.

Member Function Documentation

def lsst.pipe.tasks.colorterms.ColortermLibrary.getColorterm (   self,
  filterName,
  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
filterNamename of filter
photoCatNamename 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).
[in]doRaiseif True then raise ColortermNotFoundError if no suitable Colorterm found; if False then return a null Colorterm with filterName as the primary and secondary filter
Returns
the appropriate Colorterm
Exceptions
ColortermNotFoundErrorif no suitable Colorterm found and doRaise true; other exceptions may be raised for unexpected errors, regardless of the value of doRaise

Definition at line 146 of file colorterms.py.

147  def getColorterm(self, filterName, photoCatName, doRaise=True):
148  """!Get the appropriate Colorterm from the library
149 
150  Use dict of color terms in the library that matches the photoCatName.
151  If the photoCatName exactly matches an entry in the library, that
152  dict is used; otherwise if the photoCatName matches a single glob (shell syntax,
153  e.g., "sdss-*" will match "sdss-dr8"), then that is used. If there is no
154  exact match and no unique match to the globs, raise an exception.
155 
156  @param filterName name of filter
157  @param photoCatName name of photometric reference catalog from which to retrieve the data.
158  This argument is not glob-expanded (but the catalog names in the library are,
159  if no exact match is found).
160  @param[in] doRaise if True then raise ColortermNotFoundError if no suitable Colorterm found;
161  if False then return a null Colorterm with filterName as the primary and secondary filter
162  @return the appropriate Colorterm
163 
164  @throw ColortermNotFoundError if no suitable Colorterm found and doRaise true;
165  other exceptions may be raised for unexpected errors, regardless of the value of doRaise
166  """
167  try:
168  trueRefCatName = None
169  ctDictConfig = self.data.get(photoCatName)
170  if ctDictConfig is None:
171  # try glob expression
172  matchList = [libRefNameGlob for libRefNameGlob in self.data
173  if fnmatch.fnmatch(photoCatName, libRefNameGlob)]
174  if len(matchList) == 1:
175  trueRefCatName = matchList[0]
176  ctDictConfig = self.data[trueRefCatName]
177  elif len(matchList) > 1:
179  "Multiple library globs match photoCatName %r: %s" % (photoCatName, matchList))
180  else:
181  raise ColortermNotFoundError("No colorterm dict found with photoCatName %r" % photoCatName)
182  ctDict = ctDictConfig.data
183  if filterName not in ctDict:
184  # Perhaps it's an alias
185  try:
186  filterName = Filter(Filter(filterName).getId()).getName()
187  except pexExcept.NotFoundError:
188  pass # this will be handled shortly
189  if filterName not in ctDict:
190  errMsg = "No colorterm found for filter %r with photoCatName %r" % (filterName, photoCatName)
191  if trueRefCatName is not None:
192  errMsg += " = catalog %r" % (trueRefCatName,)
193  raise ColortermNotFoundError(errMsg)
194  return ctDict[filterName]
195  except ColortermNotFoundError:
196  if doRaise:
197  raise
198  else:
199  return Colorterm(filterName, filterName)
def getColorterm
Get the appropriate Colorterm from the library.
Definition: colorterms.py:146
Holds an integer identifier for an LSST filter.
Definition: Filter.h:107
Colorterm correction for one pair of filters.
Definition: colorterms.py:39

Member Data Documentation

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

Definition at line 139 of file colorterms.py.


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