Skip to content

Commit

Permalink
Add is_simulated and group_counter_*
Browse files Browse the repository at this point in the history
* is_simulated has become necessary now that we are taking ComCam
  data in the lab that is pretending to be on sky.
* group_counter is needed to allow the new LSSTCam visit definitions
  to work. Headers now say they are N of M so the first and last
  values for observation_counter can be determined from a
  header.
  • Loading branch information
timj committed Mar 25, 2022
1 parent fc6a95e commit 48b570e
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/astro_metadata_translator/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,14 @@ def simple_to_altaz(simple, **kwargs):
"observation_counter": ("Counter of this observation. Can be counter within observing_day "
" or a global counter. Likely to be observatory specific.",
"int", int, None, None),
"is_simulated": ("Boolean indicating whether any part of this observation was simulated.",
"bool", bool, None, None),
"group_counter_start": ("Observation counter for the start of the exposure group."
"Depending on the instrument the relevant group may be "
"visit_id or exposure_group.",
"int", int, None, None),
"group_counter_end": ("Observation counter for the end of the exposure group. "
"Depending on the instrument the relevant group may be "
"visit_id or exposure_group.",
"int", int, None, None),
}
54 changes: 54 additions & 0 deletions python/astro_metadata_translator/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,60 @@ def to_observation_counter(self):
"""
return 0

@cache_translation
def to_group_counter_start(self) -> int:
"""Return the observation counter of the observation that began
this group.
The definition of the relevant group is up to the metadata
translator. It can be the first observation in the exposure_group
or the first observation in the visit, but must be derivable
from the metadata of this observation.
Returns
-------
counter : `int`
The observation counter for the start of the relevant group.
Default implementation always returns the observation counter
of this observation.
"""
return self.to_observation_counter()

@cache_translation
def to_group_counter_end(self) -> int:
"""Return the observation counter of the observation that ends
this group.
The definition of the relevant group is up to the metadata
translator. It can be the last observation in the exposure_group
or the last observation in the visit, but must be derivable
from the metadata of this observation. It is of course possible
that the last observation in the group does not exist if a sequence
of observations was not completed.
Returns
-------
counter : `int`
The observation counter for the end of the relevant group.
Default implementation always returns the observation counter
of this observation.
"""
return self.to_observation_counter()

@cache_translation
def to_is_simulated(self) -> bool:
"""Return a boolean indicating whether any part of the observation
was simulated.
Returns
-------
is_simulated : `bool`
`True` if this exposure had simulated content. This can be
if some parts of the metadata or data were simulated. Default
implementation always returns `False`.
"""
return False

@classmethod
def determine_translatable_headers(cls, filename, primary=None):
"""Given a file return all the headers usable for metadata translation.
Expand Down
6 changes: 6 additions & 0 deletions tests/test_cfht.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def test_megaprime_translator(self):
exposure_id=1038843,
exposure_group="1038843",
exposure_time=615.037*u.s,
group_counter_end=1038843,
group_counter_start=1038843,
is_simulated=False,
object="w2.+2+2",
observation_counter=1038843,
observation_id="1038843",
Expand Down Expand Up @@ -64,6 +67,9 @@ def test_megaprime_translator(self):
exposure_id=849375,
exposure_group="849375",
exposure_time=300.202*u.s,
group_counter_end=849375,
group_counter_start=849375,
is_simulated=False,
object="D3",
observation_counter=849375,
observation_id="849375",
Expand Down
12 changes: 12 additions & 0 deletions tests/test_decam.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def test_decam_translator(self):
exposure_id=229388,
exposure_group="229388",
exposure_time=200.0*u.s,
group_counter_end=229388,
group_counter_start=229388,
is_simulated=False,
object="DES supernova hex SN-S1 tiling 22",
observation_counter=229388,
observation_id="ct4m20130901t060255",
Expand Down Expand Up @@ -64,6 +67,9 @@ def test_decam_translator(self):
exposure_id=160496,
exposure_group="160496",
exposure_time=0.0*u.s,
group_counter_end=160496,
group_counter_start=160496,
is_simulated=False,
object="postflats-BIAS",
observation_counter=160496,
observation_id="ct4m20121211t220632",
Expand Down Expand Up @@ -92,6 +98,9 @@ def test_decam_translator(self):
exposure_id=412037,
exposure_group="412037",
exposure_time=86.0*u.s,
group_counter_end=412037,
group_counter_start=412037,
is_simulated=False,
object="Blind15A_03",
observation_counter=412037,
observation_id="ct4m20150220t004721",
Expand Down Expand Up @@ -120,6 +129,9 @@ def test_decam_translator(self):
exposure_id=845291,
exposure_group="845291",
exposure_time=120.0*u.s,
group_counter_end=845291,
group_counter_start=845291,
is_simulated=False,
object="",
observation_counter=845291,
observation_id="ct4m20190402t050618",
Expand Down
3 changes: 3 additions & 0 deletions tests/test_sdss.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def test_sdss_translator(self):
exposure_id=6377,
exposure_group="6377",
exposure_time=53.907456*u.s,
group_counter_end=0,
group_counter_start=0,
is_simulated=False,
object="82 S",
observation_counter=0,
observation_id="6377 4 g 407",
Expand Down
9 changes: 9 additions & 0 deletions tests/test_subaru.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def test_hsc_translator(self):
exposure_id=904024,
exposure_group="904024",
exposure_time=30.0*u.s,
group_counter_end=904024,
group_counter_start=904024,
is_simulated=False,
object="STRIPE82L",
observation_counter=904024,
observation_id="HSCA90402400",
Expand All @@ -62,6 +65,9 @@ def test_hsc_translator(self):
exposure_id=40900,
exposure_group="40900",
exposure_time=150.0*u.s,
group_counter_end=40900,
group_counter_start=40900,
is_simulated=False,
object="SSP-Wide",
observation_counter=40900,
observation_id="HSCA04090000",
Expand Down Expand Up @@ -96,6 +102,9 @@ def test_suprimecam_translator(self):
exposure_id=53577,
exposure_group="53577",
exposure_time=200.0*u.s,
group_counter_end=53577,
group_counter_start=53577,
is_simulated=False,
object="Ecliptic Deep Field",
observation_counter=53577,
observation_id="SUPE00535770",
Expand Down

0 comments on commit 48b570e

Please sign in to comment.