Skip to content

Commit 88b6409

Browse files
authored
Merge pull request astropy#3111 from emellega/esasky-support-erosita-downloads
ESASky handle eROSITA downloads
2 parents 060ab17 + 7ac1836 commit 88b6409

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

CHANGES.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ mast
205205
- Present users with an error rather than a warning when nonexistent query criteria are used in ``mast.Observations.query_criteria``
206206
and ``mast.Catalogs.query_criteria``. [#3084]
207207

208-
- Support for case-insensitive criteria keyword arguments in ``mast.Observations.query_criteria`` and
208+
- Support for case-insensitive criteria keyword arguments in ``mast.Observations.query_criteria`` and
209209
``mast.Catalogs.query_criteria``. [#3087]
210210

211211
- Added function ``mast.Observations.get_unique_product_list`` to return the unique data products associated with
@@ -802,6 +802,8 @@ esa.esasky
802802

803803
- Added Solar System Object functionality. [#2106]
804804

805+
- Added support for eROSITA downloads. [#3111]
806+
805807
ipac
806808
^^^^
807809

astroquery/esasky/core.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class ESASkyClass(BaseQuery):
5454
__TAP_DEC_COLUMN_STRING = "tapDecColumn"
5555
__METADATA_STRING = "metadata"
5656
__PRODUCT_URL_STRING = "product_url"
57+
__EROSITA_PRODUCT_URL_STRING = "prod_url"
5758
__ACCESS_URL_STRING = "access_url"
5859
__USE_INTERSECT_STRING = "useIntersectPolygonInsteadOfContainsPoint"
5960
__ZERO_ARCMIN_STRING = "0 arcmin"
@@ -1464,6 +1465,8 @@ def _get_maps_for_mission(self, maps_table, mission, download_dir, cache, json,
14641465
url_key = self.__PRODUCT_URL_STRING
14651466
if url_key == "" and self.__ACCESS_URL_STRING in maps_table.keys():
14661467
url_key = self.__ACCESS_URL_STRING
1468+
if url_key == "" and mission == 'EROSITA':
1469+
url_key = self.__EROSITA_PRODUCT_URL_STRING
14671470
if url_key == "" or mission == "ALMA":
14681471
log.info(mission + " does not yet support downloading of fits files")
14691472
return maps
@@ -1520,13 +1523,20 @@ def _get_maps_for_mission(self, maps_table, mission, download_dir, cache, json,
15201523

15211524
response.raise_for_status()
15221525

1523-
if ('Content-Type' in response.headers
1524-
and response.headers['Content-Type'] == 'application/zip'):
1526+
if response.headers.get('Content-Type') == 'application/zip':
15251527
with ZipFile(file=BytesIO(response.content)) as zip:
15261528
for info in zip.infolist():
15271529
if self._ends_with_fits_like_extentsion(info.filename):
15281530
maps.append(self._open_fits(
15291531
zip.extract(info.filename, path=mission_directory), verbose=verbose))
1532+
elif response.headers.get('Content-Type') == 'application/x-gzip':
1533+
with esatar.open(name='dummy', mode='r', fileobj=BytesIO(response.content)) as tar:
1534+
for file in tar.getmembers():
1535+
if self._ends_with_fits_like_extentsion(file.name):
1536+
file.name = os.path.basename(file.name)
1537+
tar.extract(file, path=mission_directory)
1538+
maps.append(self._open_fits(
1539+
Path(mission_directory, file.name), verbose=verbose))
15301540
else:
15311541
file_name = self._extract_file_name_from_response_header(response.headers)
15321542
if file_name == "":

astroquery/esasky/tests/test_esasky_remote.py

+9
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ def test_esasky_get_images(self, tmp_path, mission):
124124
for hdu_list in result[mission.upper()]:
125125
hdu_list.close()
126126

127+
@pytest.mark.bigdata
128+
def test_esasky_get_images_for_erosita(self, tmp_path):
129+
mission = 'eROSITA'
130+
result = ESASky.get_images(position="67.84 -61.44", missions=mission, download_dir=tmp_path)
131+
assert tmp_path.stat().st_size
132+
133+
for hdu_list in result[mission.upper()]:
134+
hdu_list.close()
135+
127136
@pytest.mark.bigdata
128137
@pytest.mark.parametrize('mission, position',
129138
zip(['JWST-MID-IR', 'JWST-NEAR-IR'],

0 commit comments

Comments
 (0)