Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-26550: Add observation_reason property #40

Merged
merged 1 commit into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/astro_metadata_translator/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
"observation_id": ("Label uniquely identifying this observation "
"(can be related to 'exposure_id').",
"str", str),
"observation_reason": ("Reason this observation was taken, or its purpose ('science' and "
"'calibration' are common values)",
"str", str),
"exposure_group": ("Label to use to associate this exposure with others "
"(can be related to 'exposure_id').",
"str", str),
Expand Down
18 changes: 18 additions & 0 deletions python/astro_metadata_translator/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,24 @@ def to_exposure_group(self):
else:
return str(exposure_id)

@cache_translation
def to_observation_reason(self):
"""Return the reason this observation was taken.

Base class implementation returns the ``science`` if the
``observation_type`` is science, else ``unknown``.
A subclass may do something different.

Returns
-------
name : `str`
The reason for this observation.
"""
obstype = self.to_observation_type()
if obstype == "science":
return "science"
return "unknown"


def _make_abstract_translator_method(property, doc, return_typedoc, return_type):
"""Create a an abstract translation method for this property.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cfht.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_megaprime_translator(self):
object="w2.+2+2",
observation_id="1038843",
observation_type="science",
observation_reason="science",
physical_filter="i.MP9702",
pressure=617.65*u.hPa,
relative_humidity=39.77,
Expand All @@ -64,6 +65,7 @@ def test_megaprime_translator(self):
object="D3",
observation_id="849375",
observation_type="science",
observation_reason="science",
physical_filter="r",
pressure=615.79*u.hPa,
relative_humidity=15.76,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_decam.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_decam_translator(self):
object="DES supernova hex SN-S1 tiling 22",
observation_id="ct4m20130901t060255",
observation_type="science",
observation_reason="science",
physical_filter="z DECam SDSS c0004 9260.0 1520.0",
pressure=779.0*u.hPa,
relative_humidity=23.0,
Expand All @@ -64,6 +65,7 @@ def test_decam_translator(self):
object="postflats-BIAS",
observation_id="ct4m20121211t220632",
observation_type="zero",
observation_reason="unknown",
physical_filter="Y DECam c0005 10095.0 1130.0",
pressure=777.0*u.hPa,
relative_humidity=38.0,
Expand All @@ -89,6 +91,7 @@ def test_decam_translator(self):
object="Blind15A_03",
observation_id="ct4m20150220t004721",
observation_type="science",
observation_reason="science",
physical_filter="g",
pressure=777.0*u.hPa,
relative_humidity=76.0,
Expand All @@ -114,6 +117,7 @@ def test_decam_translator(self):
object="",
observation_id="ct4m20190402t050618",
observation_type="science",
observation_reason="science",
physical_filter="VR DECam c0007 6300.0 2600.0",
pressure=779.0*u.hPa,
relative_humidity=38.0,
Expand Down
1 change: 1 addition & 0 deletions tests/test_sdss.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_sdss_translator(self):
object="82 S",
observation_id="6377 4 g 407",
observation_type="science",
observation_reason="science",
physical_filter="g",
pressure=None,
relative_humidity=None,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_subaru.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_hsc_translator(self):
object="STRIPE82L",
observation_id="HSCA90402400",
observation_type="science",
observation_reason="science",
physical_filter="HSC-I",
pressure=621.7*u.hPa,
relative_humidity=33.1,
Expand All @@ -62,6 +63,7 @@ def test_hsc_translator(self):
object="SSP-Wide",
observation_id="HSCA04090000",
observation_type="science",
observation_reason="science",
physical_filter="HSC-R",
pressure=625.4*u.hPa,
relative_humidity=8.6,
Expand Down Expand Up @@ -93,6 +95,7 @@ def test_suprimecam_translator(self):
object="Ecliptic Deep Field",
observation_id="SUPE00535770",
observation_type="science",
observation_reason="science",
physical_filter="W-S-R+",
pressure=621.5*u.hPa,
relative_humidity=4.9,
Expand Down