diff --git a/CHANGES.rst b/CHANGES.rst index e3af10bd20..b6700ced10 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,6 +14,8 @@ gaia - Deprecated ``band`` from ``load_data`` as it has no effect on upstream response any more. [#3278] +- New datalink retrieve types EPOCH_PHOTOMETRY_CROWDED_FIELD, EPOCH_ASTROMETRY_BRIGHT, XP_MEAN_SPECTRUM_GRAVLENS, + EPOCH_FLAGS_NSS, EPOCH_PARAMETERS_RVS_SINGLE, EPOCH_PARAMETERS_RVS_DOUBLE, EPOCH_FLAGS_VARI. [#3371, #3372] Service fixes and enhancements ------------------------------ @@ -47,6 +49,7 @@ heasarc - Add support for astropy.table.Row in Heasarc.download_data and Heasarc.locate_data. [#3270] - Heasarc.locate_data returns empty rows with an error in the error_message column if there are no data associated with that row rather than filtering it out. [#3275] +- Heasarc.locate_data changed to use POST request instead of GET to accomodate large requests. [#3356] imcce ^^^^^ @@ -127,6 +130,8 @@ utils - Raising cleaner errors earlier when server returns with error. [#3284] +- ``return_frame`` parameter in ``utils.commons.parse_coordinates`` returns coordinates in the specified frame. [#3164] + 0.4.10 (2025-03-18) =================== @@ -2263,4 +2268,4 @@ Infrastructure, Utility and Other Changes and Additions 0.1 (2013-09-19) ================ -- Initial release. Includes features! +- Initial release. Includes features! \ No newline at end of file diff --git a/astroquery/mast/collections.py b/astroquery/mast/collections.py index bd14943a9c..ffab0d18f2 100644 --- a/astroquery/mast/collections.py +++ b/astroquery/mast/collections.py @@ -204,7 +204,7 @@ def query_region_async(self, coordinates, *, radius=0.2*u.deg, catalog="Hsc", """ # Put coordinates and radius into consistent format - coordinates = commons.parse_coordinates(coordinates) + coordinates = commons.parse_coordinates(coordinates, return_frame='icrs') # if radius is just a number we assume degrees radius = coord.Angle(radius, u.deg) diff --git a/astroquery/mast/missions.py b/astroquery/mast/missions.py index 184305fa37..e56ee51efe 100644 --- a/astroquery/mast/missions.py +++ b/astroquery/mast/missions.py @@ -219,7 +219,7 @@ def query_region_async(self, coordinates, *, radius=3*u.arcmin, limit=5000, offs self._validate_criteria(**criteria) # Put coordinates and radius into consistent format - coordinates = commons.parse_coordinates(coordinates) + coordinates = commons.parse_coordinates(coordinates, return_frame='icrs') # If radius is just a number, assume arcminutes radius = coord.Angle(radius, u.arcmin) diff --git a/astroquery/mast/observations.py b/astroquery/mast/observations.py index 11694aeb1a..3c14db9963 100644 --- a/astroquery/mast/observations.py +++ b/astroquery/mast/observations.py @@ -22,8 +22,9 @@ from astropy.table import Table, Row, vstack from astroquery import log from astroquery.mast.cloud import CloudAccess +from astroquery.utils import commons -from ..utils import commons, async_to_sync +from ..utils import async_to_sync from ..utils.class_or_instance import class_or_instance from ..exceptions import (InvalidQueryError, RemoteServiceError, NoResultsWarning, InputWarning) @@ -234,7 +235,7 @@ def query_region_async(self, coordinates, *, radius=0.2*u.deg, pagesize=None, pa """ # Put coordinates and radius into consistent format - coordinates = commons.parse_coordinates(coordinates) + coordinates = commons.parse_coordinates(coordinates, return_frame='icrs') # if radius is just a number we assume degrees radius = coord.Angle(radius, u.deg) @@ -363,7 +364,7 @@ def query_region_count(self, coordinates, *, radius=0.2*u.deg, pagesize=None, pa """ # build the coordinates string needed by ObservationsClass._caom_filtered_position - coordinates = commons.parse_coordinates(coordinates) + coordinates = commons.parse_coordinates(coordinates, return_frame='icrs') # if radius is just a number we assume degrees radius = coord.Angle(radius, u.deg) diff --git a/astroquery/mast/tests/test_mast_remote.py b/astroquery/mast/tests/test_mast_remote.py index f377f39d07..c1fc0bd4e2 100644 --- a/astroquery/mast/tests/test_mast_remote.py +++ b/astroquery/mast/tests/test_mast_remote.py @@ -1365,7 +1365,7 @@ def test_tesscut_get_sectors_mt(self): assert sector_table['ccd'][0] == 1 error_noname = ("Please specify the object name or ID (as understood by the " - "`JPL ephemerides service `__) " + "`JPL ephemerides service `__) " "of a moving target such as an asteroid or comet.") error_nameresolve = f"Could not resolve {moving_target_name} to a sky position." error_mt_coord = "Only one of moving_target and coordinates may be specified." @@ -1448,7 +1448,7 @@ def test_tesscut_download_cutouts_mt(self, tmpdir): assert os.path.isfile(row['Local Path']) error_noname = ("Please specify the object name or ID (as understood by the " - "`JPL ephemerides service `__) of " + "`JPL ephemerides service `__) of " "a moving target such as an asteroid or comet.") error_nameresolve = f"Could not resolve {moving_target_name} to a sky position." error_mt_coord = "Only one of moving_target and coordinates may be specified." @@ -1529,7 +1529,7 @@ def test_tesscut_get_cutouts_mt(self): assert isinstance(cutout_hdus_list[0], fits.HDUList) error_noname = ("Please specify the object name or ID (as understood by the " - "`JPL ephemerides service `__) of " + "`JPL ephemerides service `__) of " "a moving target such as an asteroid or comet.") error_nameresolve = f"Could not resolve {moving_target_name} to a sky position." error_mt_coord = "Only one of moving_target and coordinates may be specified." diff --git a/astroquery/mast/utils.py b/astroquery/mast/utils.py index 49c6524bc1..868ae8d15e 100644 --- a/astroquery/mast/utils.py +++ b/astroquery/mast/utils.py @@ -216,7 +216,8 @@ def parse_input_location(*, coordinates=None, objectname=None, resolver=None): Returns ------- response : `~astropy.coordinates.SkyCoord` - The given coordinates, or object's location as an `~astropy.coordinates.SkyCoord` object. + The given coordinates, or object's location as an `~astropy.coordinates.SkyCoord` object + in the ICRS frame. """ # Checking for valid input @@ -232,8 +233,9 @@ def parse_input_location(*, coordinates=None, objectname=None, resolver=None): if objectname: obj_coord = resolve_object(objectname, resolver=resolver) + # Parse coordinates, if given if coordinates: - obj_coord = commons.parse_coordinates(coordinates) + obj_coord = commons.parse_coordinates(coordinates, return_frame='icrs') return obj_coord diff --git a/astroquery/utils/commons.py b/astroquery/utils/commons.py index 6170d68777..2fec1e15dc 100644 --- a/astroquery/utils/commons.py +++ b/astroquery/utils/commons.py @@ -40,7 +40,7 @@ ASTROPY_LT_7_1_1 = not minversion('astropy', '7.1.1') -def parse_coordinates(coordinates): +def parse_coordinates(coordinates, *, return_frame=None): """ Takes a string or astropy.coordinates object. Checks if the string is parsable as an `astropy.coordinates` @@ -51,6 +51,10 @@ def parse_coordinates(coordinates): ---------- coordinates : str or `astropy.coordinates` object Astronomical coordinate + return_frame : `astropy.coordinates` frame + The frame to return the coordinates in. If None and ``coordinates`` is + a string, the frame will be ICRS. If ``coordinates`` is an `astropy.coordinates` object, the + frame will be the same as the input object. Returns ------- @@ -93,6 +97,11 @@ def parse_coordinates(coordinates): c = SkyCoord(coordinates) else: raise TypeError("Argument cannot be parsed as a coordinate") + + # Convert to requested frame, if given + if return_frame and c.frame.name != return_frame.lower(): + c = c.transform_to(return_frame) + return c diff --git a/astroquery/utils/tests/test_utils.py b/astroquery/utils/tests/test_utils.py index ce09b862ff..3132380e23 100644 --- a/astroquery/utils/tests/test_utils.py +++ b/astroquery/utils/tests/test_utils.py @@ -80,6 +80,30 @@ def test_parse_coordinates_4(): assert c.to_string() == coordinates +def test_parse_coordinates_return_frame(): + # String input should return in icrs frame + coords = commons.parse_coordinates('266.40498829 -28.93617776') + assert coords.frame.name == 'icrs' + + # SkyCoord input without return_frame should return in original frame + galactic = coord.SkyCoord('0 0', unit='deg', frame='galactic') + coords = commons.parse_coordinates(galactic) + assert coords.frame.name == 'galactic' + + # Parse a SkyCoord in galactic frame into icrs frame + galactic = coord.SkyCoord('0 0', unit='deg', frame='galactic') + icrs = galactic.transform_to('icrs') # Expected result + coords = commons.parse_coordinates(galactic, return_frame='icrs') + assert icrs.ra.deg == coords.ra.deg + assert icrs.dec.deg == coords.dec.deg + assert galactic.frame.name == 'galactic' + assert coords.frame.name == 'icrs' + + # ValueError if transformation fails + with pytest.raises(ValueError): + coords = commons.parse_coordinates(galactic, return_frame='invalid') + + col_1 = [1, 2, 3] col_2 = [0, 1, 0, 1, 0, 1] col_3 = ['v', 'w', 'x', 'y', 'z']