diff --git a/CHANGES.rst b/CHANGES.rst index 701c68e955..b6e9cc50ca 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -205,7 +205,7 @@ mast - Present users with an error rather than a warning when nonexistent query criteria are used in ``mast.Observations.query_criteria`` and ``mast.Catalogs.query_criteria``. [#3084] -- Support for case-insensitive criteria keyword arguments in ``mast.Observations.query_criteria`` and +- Support for case-insensitive criteria keyword arguments in ``mast.Observations.query_criteria`` and ``mast.Catalogs.query_criteria``. [#3087] - Added function ``mast.Observations.get_unique_product_list`` to return the unique data products associated with @@ -802,6 +802,8 @@ esa.esasky - Added Solar System Object functionality. [#2106] +- Added support for eROSITA downloads. [#3111] + ipac ^^^^ diff --git a/astroquery/esasky/core.py b/astroquery/esasky/core.py index fe5e71a150..a86dd03c1c 100644 --- a/astroquery/esasky/core.py +++ b/astroquery/esasky/core.py @@ -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" @@ -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 if url_key == "" or mission == "ALMA": log.info(mission + " does not yet support downloading of fits files") return maps @@ -1520,13 +1523,20 @@ def _get_maps_for_mission(self, maps_table, mission, download_dir, cache, json, response.raise_for_status() - if ('Content-Type' in response.headers - and response.headers['Content-Type'] == 'application/zip'): + if response.headers.get('Content-Type') == 'application/zip': with ZipFile(file=BytesIO(response.content)) as zip: for info in zip.infolist(): if self._ends_with_fits_like_extentsion(info.filename): maps.append(self._open_fits( zip.extract(info.filename, path=mission_directory), verbose=verbose)) + elif response.headers.get('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( + Path(mission_directory, file.name), verbose=verbose)) else: file_name = self._extract_file_name_from_response_header(response.headers) if file_name == "": diff --git a/astroquery/esasky/tests/test_esasky_remote.py b/astroquery/esasky/tests/test_esasky_remote.py index 9434dda82c..9f43ed294e 100755 --- a/astroquery/esasky/tests/test_esasky_remote.py +++ b/astroquery/esasky/tests/test_esasky_remote.py @@ -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'],