Coverage for python/lsst/obs/base/filters.py : 29%

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
# This file is part of obs_base. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.
and for use by `lsst.afw.image.Filter`, gen2 dataIds, and gen3 Dimensions. """
"""An order-preserving collection of `FilterDefinition`s.
Parameters ---------- filters : sequence The filters in this collection. """
"""Whether these filters have been defined via `~lsst.afw.image.utils.defineFilter`. If so, set to ``self`` to identify the filter collection that defined them. """
return self._filters[key]
return len(self._filters)
return "FilterDefinitions(" + ', '.join(str(f) for f in self._filters) + ')'
"""Define all the filters to `lsst.afw.image.Filter`.
`~lsst.afw.image.Filter` objects are singletons, so we protect against filters being defined multiple times.
Raises ------ RuntimeError Raised if any other `FilterDefinitionCollection` has already called ``defineFilters``. """ if self._defined is None: self.reset() for filter in self._filters: filter.defineFilter() FilterDefinitionCollection._defined = self elif self._defined is self: # noop: we've already defined these filters, so do nothing pass else: msg = f"afw Filters were already defined on: {self._defined}" raise RuntimeError(msg)
def reset(cls): """Reset the afw Filter definitions and clear the `defined` singleton. Use this in unittests that define different filters. """ lsst.afw.image.utils.resetFilters() cls._defined = None
class FilterDefinition: """The definition of an instrument's filter bandpass.
This class is used to interface between the `~lsst.afw.image.Filter` class and the Gen2 `~lsst.daf.persistence.CameraMapper` and Gen3 `~lsst.obs.base.Instruments` and ``physical_filter``/``abstract_filter`` `~lsst.daf.butler.Dimension`.
This class is likely temporary, until we have a better versioned filter definition system that includes complete transmission information. """
"""The name of a filter associated with a particular instrument: unique for each piece of glass. This should match the exact filter name used in the observatory's metadata.
This name is used to define the ``physical_filter`` gen3 Butler Dimension.
If neither ``abstract_filter`` or ``afw_name`` is defined, this is used as the `~lsst.afw.image.Filter` ``name``, otherwise it is added to the list of `~lsst.afw.image.Filter` aliases. """
"""The effective wavelength of this filter (nm)."""
"""The generic name of a filter not associated with a particular instrument (e.g. `r` for the SDSS Gunn r-band, which could be on SDSS, LSST, or HSC).
Not all filters have an abstract filter: engineering or test filters may not have a genericly-termed filter name.
If specified and if `afw_name` is None, this is used as the `~lsst.afw.image.Filter` ``name`` field, otherwise it is added to the list of `~lsst.afw.image.Filter` aliases. """
"""If not None, the name of the `~lsst.afw.image.Filter` object.
This is distinct from physical_filter and abstract_filter to maintain backwards compatibility in some obs packages. For example, for HSC there are two distinct ``r`` and ``i`` filters, named ``r/r2`` and ``i/i2``. """
"""The minimum wavelength of this filter (nm; defined as 1% throughput)""" """The maximum wavelength of this filter (nm; defined as 1% throughput)"""
"""Alternate names for this filter. These are added to the `~lsst.afw.image.Filter` alias list. """
# force alias to be immutable, so that hashing works if not isinstance(self.alias, frozenset): object.__setattr__(self, 'alias', frozenset(self.alias))
txt = f"FilterDefinition(physical_filter='{self.physical_filter}', lambdaEff='{self.lambdaEff}'" if self.abstract_filter is not None: txt += f", abstract_filter='{self.abstract_filter}'" if self.afw_name is not None: txt += f", afw_name='{self.afw_name}'" if not np.isnan(self.lambdaMin): txt += f", lambdaMin='{self.lambdaMin}'" if not np.isnan(self.lambdaMax): txt += f", lambdaMax='{self.lambdaMax}'" if len(self.alias) != 0: txt += f", alias='{self.alias}'" return txt + ")"
"""Declare the filters via afw.image.Filter. """ aliases = set(self.alias) name = self.physical_filter if self.abstract_filter is not None: name = self.abstract_filter aliases.add(self.physical_filter) if self.afw_name is not None: name = self.afw_name aliases.add(self.physical_filter) # Only add `physical_filter/abstract_filter` as an alias if afw_name is defined.ee if self.afw_name is not None: if self.abstract_filter is not None: aliases.add(self.abstract_filter) lsst.afw.image.utils.defineFilter(name, lambdaEff=self.lambdaEff, lambdaMin=self.lambdaMin, lambdaMax=self.lambdaMax, alias=sorted(aliases)) |