Skip to content

Commit

Permalink
filter key handler fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
parejkoj committed Mar 7, 2020
1 parent d995bb9 commit b4c1804
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions python/lsst/obs/base/gen2to3/translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__all__ = ("Translator", "KeyHandler", "CopyKeyHandler", "ConstantKeyHandler",
"CalibKeyHandler", "AbstractFilterKeyHandler",
"CalibKeyHandler", "AbstractToPhysicalFilterKeyHandler", "PhysicalToAbstractFilterKeyHandler",
"makeCalibrationLabel")

import itertools
Expand Down Expand Up @@ -228,8 +228,13 @@ def extract(self, gen2id: dict, skyMap: Optional[BaseSkyMap], skyMapName: Option
ccd=gen2id.get(self.ccdKey), filter=gen2id.get("filter"))


class AbstractFilterKeyHandler(KeyHandler):
"""KeyHandler for filter keys that should be mapped to AbstractFilters.
class PhysicalToAbstractFilterKeyHandler(KeyHandler):
"""KeyHandler for gen2 ``filter`` keys that match ``physical_filter``
keys in gen3 but should be mapped to ``abstract_filter``.
Note that multiple physical filter can potentially map to one abstract
filter, so be careful to only use this translator on obs packages where
there is a one-to-one mapping.
"""

__slots__ = ("_map",)
Expand All @@ -244,8 +249,13 @@ def extract(self, gen2id, *args, **kwargs):
return self._map.get(physical, physical)


class PhysicalFilterKeyHandler(KeyHandler):
"""KeyHandler for filter keys that should be mapped to AbstractFilters.
class AbstractToPhysicalFilterKeyHandler(KeyHandler):
"""KeyHandler for gen2 ``filter`` keys that match ``abstract_filter``
keys in gen3 but should be mapped to ``physical_filter``.
Note that one abstract filter can potentially map to multiple physical
filters, so be careful to only use this translator on obs packages where
there is a one-to-one mapping.
"""

__slots__ = ("_map",)
Expand All @@ -256,8 +266,8 @@ def __init__(self, filterDefinitions):
if d.abstract_filter is not None}

def extract(self, gen2id, *args, **kwargs):
filter = gen2id["filter"]
return self._map.get(filter, filter)
abstract = gen2id["filter"]
return self._map.get(abstract, abstract)


class Translator:
Expand Down

0 comments on commit b4c1804

Please sign in to comment.