Skip to content

Commit

Permalink
Define the filter delimiter in a single place
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Feb 6, 2020
1 parent fb80d56 commit 1ac5862
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions python/lsst/obs/lsst/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
__all__ = ()

from lsst.obs.base import FilterDefinition, FilterDefinitionCollection
from .translators.lsst import FILTER_DELIMITER


LSSTCAM_FILTER_DEFINITIONS = FilterDefinitionCollection(
Expand Down Expand Up @@ -79,7 +80,6 @@

# Form a new set of filter definitions from all the explicit filters
_latiss_gratings = ("ronchi90lpmm", "ronchi170lpmm", "EMPTY", "NONE")
_delimiter = "~"

# Include the filters without the grating in case someone wants
# to retrieve a filter by an actual filter name
Expand All @@ -88,10 +88,10 @@
for filter in _latiss_filters:
for grating in _latiss_gratings:
# FilterDefinition is a frozen dataclass
new_name = _delimiter.join([filter.physical_filter, grating])
new_name = FILTER_DELIMITER.join([filter.physical_filter, grating])

# Also need to update aliases
new_aliases = {_delimiter.join([a, grating]) for a in filter.alias}
new_aliases = {FILTER_DELIMITER.join([a, grating]) for a in filter.alias}

combo = FilterDefinition(physical_filter=new_name,
lambdaEff=filter.lambdaEff,
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/obs/lsst/translators/latiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from astro_metadata_translator import cache_translation
from astro_metadata_translator.translators.helpers import is_non_science
from .lsst import LsstBaseTranslator
from .lsst import LsstBaseTranslator, FILTER_DELIMITER

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -434,7 +434,7 @@ def to_physical_filter(self):
else:
grating = "NONE"

physical_filter = f"{physical_filter}~{grating}"
physical_filter = f"{physical_filter}{FILTER_DELIMITER}{grating}"

return physical_filter

Expand Down
5 changes: 4 additions & 1 deletion python/lsst/obs/lsst/translators/lsst.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
TZERO = Time("2015-01-01T00:00", format="isot", scale="utc")
TZERO_DATETIME = TZERO.to_datetime()

# Delimiter to use for multiple filters/gratings
FILTER_DELIMITER = "~"

# Regex to use for parsing a GROUPID string
GROUP_RE = re.compile(r"^(\d\d\d\d\-\d\d\-\d\dT\d\d:\d\d:\d\d)\.(\d\d\d)(?:[\+#](\d+))?$")

Expand Down Expand Up @@ -596,7 +599,7 @@ def to_physical_filter(self):
Name of filter. Can be a combination of FILTER, FILTER1 and FILTER2
headers joined by a "~". Returns "NONE" if no filter is declared.
"""
joined = self._join_keyword_values(["FILTER", "FILTER1", "FILTER2"], delim="~")
joined = self._join_keyword_values(["FILTER", "FILTER1", "FILTER2"], delim=FILTER_DELIMITER)
if not joined:
joined = "NONE"

Expand Down

0 comments on commit 1ac5862

Please sign in to comment.