Skip to content

Commit

Permalink
ESASky handle eROSITA downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
emellega committed Oct 1, 2024
1 parent ecb0ea0 commit fc7737d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions astroquery/esasky/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ESASkyClass(BaseQuery):
__TAP_DEC_COLUMN_STRING = "tapDecColumn"
__METADATA_STRING = "metadata"
__PRODUCT_URL_STRING = "product_url"
__EROSITA_PRODUCT_URL_STRING = "prod_url"
__ACCESS_URL_STRING = "access_url"
__USE_INTERSECT_STRING = "useIntersectPolygonInsteadOfContainsPoint"
__ZERO_ARCMIN_STRING = "0 arcmin"
Expand Down Expand Up @@ -1464,6 +1465,8 @@ def _get_maps_for_mission(self, maps_table, mission, download_dir, cache, json,
url_key = self.__PRODUCT_URL_STRING
if url_key == "" and self.__ACCESS_URL_STRING in maps_table.keys():
url_key = self.__ACCESS_URL_STRING
if url_key == "" and mission == 'EROSITA':
url_key = self.__EROSITA_PRODUCT_URL_STRING

Check warning on line 1469 in astroquery/esasky/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/esasky/core.py#L1468-L1469

Added lines #L1468 - L1469 were not covered by tests
if url_key == "" or mission == "ALMA":
log.info(mission + " does not yet support downloading of fits files")
return maps
Expand Down Expand Up @@ -1527,6 +1530,15 @@ def _get_maps_for_mission(self, maps_table, mission, download_dir, cache, json,
if self._ends_with_fits_like_extentsion(info.filename):
maps.append(self._open_fits(
zip.extract(info.filename, path=mission_directory), verbose=verbose))
elif ('Content-Type' in response.headers and

Check warning on line 1533 in astroquery/esasky/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/esasky/core.py#L1533

Added line #L1533 was not covered by tests
response.headers['Content-Type'] == 'application/x-gzip'):
with esatar.open(name='dummy', mode='r', fileobj=BytesIO(response.content)) as tar:
for file in tar.getmembers():
if self._ends_with_fits_like_extentsion(file.name):
file.name = os.path.basename(file.name)
tar.extract(file, path=mission_directory)
maps.append(self._open_fits(

Check warning on line 1540 in astroquery/esasky/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/esasky/core.py#L1535-L1540

Added lines #L1535 - L1540 were not covered by tests
Path(mission_directory, file.name), verbose=verbose))
else:
file_name = self._extract_file_name_from_response_header(response.headers)
if file_name == "":
Expand Down
9 changes: 9 additions & 0 deletions astroquery/esasky/tests/test_esasky_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ def test_esasky_get_images(self, tmp_path, mission):
for hdu_list in result[mission.upper()]:
hdu_list.close()

@pytest.mark.bigdata
def test_esasky_get_images_for_erosita(self, tmp_path):
mission = 'eROSITA'
result = ESASky.get_images(position="67.84 -61.44", missions=mission, download_dir=tmp_path)
assert tmp_path.stat().st_size

for hdu_list in result[mission.upper()]:
hdu_list.close()

@pytest.mark.bigdata
@pytest.mark.parametrize('mission, position',
zip(['JWST-MID-IR', 'JWST-NEAR-IR'],
Expand Down

0 comments on commit fc7737d

Please sign in to comment.