From 0e520a2d6260318129375e9dd83c7a1fe8a9a51b Mon Sep 17 00:00:00 2001 From: Xen0Xys Date: Tue, 16 Jul 2024 12:37:15 +0200 Subject: [PATCH] :sparkles: Implement hips2fits function --- src/ipyaladin/widget.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/ipyaladin/widget.py b/src/ipyaladin/widget.py index b5088c0a..c909d655 100644 --- a/src/ipyaladin/widget.py +++ b/src/ipyaladin/widget.py @@ -296,6 +296,30 @@ def target(self, target: Union[str, SkyCoord]) -> None: } ) + def hips2fits(self, hips: str, output_file: Optional[str] = None) -> None: + """Convert a HiPS image to a FITS file. + + Parameters + ---------- + hips: str + The HiPS to convert. See here for a list of available HiPS: + https://aladin.cds.unistra.fr/hips/list + output_file: str, optional + The name of the output FITS file. If None, the FITS file is not saved. + + """ + from astroquery.hips2fits import hips2fits + + fits = hips2fits.query_with_wcs( + hips=hips, + format="fits", + get_query_payload=False, + wcs=self.wcs, + ) + if output_file is not None: + fits.writeto(output_file) + return fits + def add_catalog_from_URL( self, votable_URL: str, votable_options: Optional[dict] = None ) -> None: