Skip to content
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

Protect against maskedconstant return from gaia query of no RV #55

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

wbalmer
Copy link
Owner

@wbalmer wbalmer commented Jan 12, 2024

I went ahead and tested the case where the host star requested has no RV measurement in Gaia DR3. To test this, I tried initializing backtracks.System with target_name='Kepler-1900'. The previous try/except loop let this past without raising the Except, I think because the Gaia.query_object_async table for a star with no RV actually gives a numpy.ma.core.MaskedConstant object in the radial_velocity column.

There was also a FutureWarning raised when trying to print this maskedconstant using format strings, so I added a if/else to protect against that, should numpy change this behavior in the future.

Creating a PR because I'm not sure if changing this try/except statement so dramatically leaves System.init unprotected to other exceptions Gilles was thinking of.

@wbalmer wbalmer self-assigned this Jan 12, 2024
@wbalmer wbalmer requested a review from gotten January 12, 2024 03:30
@wbalmer wbalmer added the bug Something isn't working label Jan 12, 2024
@gotten
Copy link
Collaborator

gotten commented Jan 12, 2024

Thanks for testing what actually comes back from the Gaia query. The double try except was because I didn't know yet what the query returned. If it was not an integer or float I would throw an exception and if it was something that would break the code I would also throw an exception. So we only need one exception now :).

Go ahead and merge this fix.

There might still be 3 debug lines in the code, do you need them?:

              print(type(self.radvelo))
               print(type(target_gaia['radial_velocity'][0]))
               print(isinstance(self.radvelo, (int, float)))

@wbalmer
Copy link
Owner Author

wbalmer commented Jan 12, 2024

Ah, let me remove my debug prints, thanks for catching them!

@wbalmer wbalmer merged commit c5a4b2b into main Jan 12, 2024
6 checks passed
@wbalmer wbalmer deleted the safe_rv_except branch January 12, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants