Skip to content

Handle non-ICRS coordinates in query functions #3164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

snbianco
Copy link
Contributor

@snbianco snbianco commented Dec 23, 2024

This PR handles coordinates passed into query functions that are not in the ICRS frame. If it is found that the given coordinates are not in ICRS, they are transformed.

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.07%. Comparing base (c522e2a) to head (873fc23).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3164   +/-   ##
=======================================
  Coverage   70.07%   70.07%           
=======================================
  Files         232      232           
  Lines       19893    19896    +3     
=======================================
+ Hits        13940    13943    +3     
  Misses       5953     5953           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@snbianco snbianco force-pushed the ASB-29990-coord-frame branch from 4dc257f to f2bd777 Compare January 24, 2025 22:01
@snbianco snbianco marked this pull request as ready for review January 24, 2025 22:19
@snbianco snbianco force-pushed the ASB-29990-coord-frame branch from 4baa044 to 50648fd Compare January 24, 2025 22:25
@bsipocz bsipocz added the mast label Feb 15, 2025
@bsipocz bsipocz added this to the v0.4.10 milestone Feb 15, 2025
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should live in the commons function, or you could use what we already have for simbad (_parse_coordinate_and_convert_to_icrs)?
(or also move the simbad one to commons? cc @ManonMarchand )

_parse_coordinate_and_convert_to_icrs

@@ -121,6 +121,32 @@ def resolve_object(objectname):
return coordinates


def parse_coordinates(coordinates):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be a kwarg argument for commons.parse_coordinates instead? e.g. to convert right at the end before returning the current output

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean a parameter like return_frame or something to that effect that you could pass in a value like 'ICRS' and get the coordinate back in whatever frame was given?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just made this change! I added a return_frame parameter to utils.commons.parse_coordinates that defaults to None. If it is provided and the coordinates are not already in that frame, it will attempt to transform them. If the transformation fails, a warning is issued and the coordinates are returned as is, without the transformation.

@ManonMarchand
Copy link
Member

Oh that methods only parses coordinates if I detect that they are written as a sim-script string. This is an old way of writing coordinates that only existed in the former Simbad interface (hence this is in Simbad's utils and not in commons).
In the other cases I use parse_coordinates from commons and then convert the SkyCoord it returns to icrs 🙂

@snbianco snbianco force-pushed the ASB-29990-coord-frame branch from f83c591 to 0746ddf Compare February 21, 2025 19:01
@snbianco snbianco force-pushed the ASB-29990-coord-frame branch 2 times, most recently from 69ca4b1 to 42597be Compare March 17, 2025 20:54
@bsipocz bsipocz modified the milestones: v0.4.10, v0.4.11 Mar 18, 2025
@snbianco
Copy link
Contributor Author

@bsipocz Pinging this PR again in case it was lost in the shuffle somewhere! I'll be offline from 3/26 - 4/3, but this isn't high priority, so no worries if you don't get around to it before then.

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments only. Thanks!

@@ -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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this mandatory kwarg please

Suggested change
def parse_coordinates(coordinates, return_frame=None):
def parse_coordinates(coordinates, *, return_frame=None):

Comment on lines 105 to 106
except ValueError:
warnings.warn(f"Failed to transform coordinates to requested frame: {return_frame}.", InputWarning)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel should let the exception propagate, after all this will only be triggered when return frame is explicitly asked for, thus a problem should be surfaced up to the user/module level

CHANGES.rst Outdated
@@ -239,6 +239,8 @@ Infrastructure, Utility and Other Changes and Additions
- Removed usage of the astropy TestRunner, therefore the unadvertised
``astroquery.test()`` functionality. [#3215]

- ``return_frame`` parameter in ``utils.commons.parse_coordinates`` returns coordinates in the specified frame. [#3164]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rebase to remove the merge commit and to squash out the changelog iterations, and to put this into the 0.4.11 section. Thanks!

@snbianco snbianco force-pushed the ASB-29990-coord-frame branch 2 times, most recently from 42597be to ef8e8c3 Compare August 1, 2025 13:39
@snbianco snbianco force-pushed the ASB-29990-coord-frame branch from ef8e8c3 to 43c951c Compare August 1, 2025 14:03
@snbianco
Copy link
Contributor Author

snbianco commented Aug 1, 2025

Updated and rebased!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants