Skip to content

Commit 8809f00

Browse files
Added another check in get_hap_hst_link, fixed code style
1 parent a4b7aba commit 8809f00

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

astroquery/esa/hubble/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ def get_hap_hst_link(self, observation_id):
148148
if observation_id is None:
149149
raise ValueError(self.REQUESTED_OBSERVATION_ID)
150150
observation_type = self.get_observation_type(observation_id)
151-
152-
if 'HAP' in observation_type:
151+
if 'Composite' in observation_type:
152+
raise ValueError("HAP-HST link is only available for simple observations. Input observation is Composite.")
153+
elif 'HAP' in observation_type:
153154
oids = self._select_members(observation_id)
154155
elif 'HST' in observation_type:
155156
query = f"select observation_id from ehst.observation where obs_type='HAP Simple' and members like '%{observation_id}%'"

astroquery/esa/hubble/tests/test_esa_hubble.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class MockResponse:
7373
def pformat():
7474
return True
7575

76+
7677
class TestESAHubble:
7778

7879
def get_dummy_tap_handler(self):
@@ -570,6 +571,14 @@ def test_get_hap_hst_link_attributeerror(self):
570571
dummy_obs_id = None
571572
ehst.get_hap_hst_link(dummy_obs_id)
572573

574+
@patch.object(ESAHubbleClass, 'get_observation_type')
575+
def test_get_hap_hst_link_compositeerror(self, mock_observation_type):
576+
with pytest.raises(ValueError):
577+
mock_observation_type.return_value = "HAP Composite"
578+
ehst = ESAHubbleClass(self.get_dummy_tap_handler())
579+
dummy_obs_id = "1234"
580+
ehst.get_hap_hst_link(dummy_obs_id)
581+
573582
@patch.object(ESAHubbleClass, '_select_members')
574583
@patch.object(ESAHubbleClass, 'get_observation_type')
575584
def test_get_member_observations_composite(self, mock_observation_type, mock_select_members):

astroquery/esa/hubble/tests/test_esa_hubble_remote.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ def test_hst_simple_to_hap_simple(self):
115115
result = esa_hubble.get_hap_hst_link('jec071i9q')
116116
assert result == ['hst_16316_71_acs_sbc_f150lp_jec071i9']
117117

118+
118119
"""
119120
def test_query_target(self):
120121
temp_file = self.temp_folder.name + "/" + "m31_query.xml"
121-
table = esa_hubble.query_target("m31", temp_file)
122+
table = esa_hubble.query_target("m3", temp_file)
122123
assert os.path.exists(temp_file)
123124
assert 'OBSERVATION_ID' in table.columns
124125
"""

docs/esa/hubble.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,39 @@ votable). The result of the query will be stored in the file
339339
result.get_results() or printing it by doing print(result).
340340

341341

342+
-------------------------------
343+
9. Getting related members of HAP and HST observations
344+
-------------------------------
345+
346+
This function takes in an observation id of a Composite or Simple observation.
347+
If the observation is Simple the method returns the Composite observation that
348+
is built on this simple observation. If the observation is Composite then the
349+
method returns the simple observations that make it up.
350+
351+
.. code-block:: python
352+
353+
>>> from astroquery.esa.hubble import ESAHubble
354+
>>> esahubble = ESAHubble()
355+
>>> result = esahubble.get_member_observations("jdrz0c010")
356+
>>> print(result)
357+
358+
359+
-------------------------------
360+
10. Getting link between Simple HAP and HST observations
361+
-------------------------------
362+
363+
This function takes in an observation id of a Simple HAP or HST observation and
364+
returns the corresponding HAP or HST observation
365+
366+
.. code-block:: python
367+
368+
>>> from astroquery.esa.hubble import ESAHubble
369+
>>> esahubble = ESAHubble()
370+
>>> result = esahubble.get_hap_hst_link("hst_16316_71_acs_sbc_f150lp_jec071i9")
371+
>>> print(result)
372+
373+
374+
342375
Reference/API
343376
=============
344377

0 commit comments

Comments
 (0)