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

Add methods for querying NASA Exoplanet Archive for ephemeris #127

Merged
merged 9 commits into from
Jul 29, 2024

Conversation

bmorris3
Copy link
Contributor

@bmorris3 bmorris3 commented Jul 16, 2024

Demo

from lcviz import LCviz
from lightkurve import search_lightcurve

lc = search_lightcurve(
    "TRAPPIST-1", mission='K2', author='EVEREST'
)[0].download().remove_nans().normalize().remove_outliers()

# load into LCviz:
lcviz = LCviz()
lcviz.load_data(lc)
lcviz.show()

# flatten the light curve to remove rotational modulation:
flatten = lcviz.plugins['Flatten']
flatten.window_length = 31
flatten.flatten();

# query for the planets in this system:
ephem = lcviz.plugins['Ephemeris']
ephem.query_for_ephemeris()

# make a new ephemeris viewer for the first three planets:
for planet in ephem.query_result.choices[:3]:
    ephem.query_result = planet
    ephem.adopt_from_catalog_in_new_viewer()
Screen Shot 2024-07-22 at 16 29 52

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 91.17647% with 6 lines in your changes missing coverage. Please review.

Project coverage is 91.19%. Comparing base (7b78df5) to head (aa1a4f8).
Report is 42 commits behind head on main.

Files with missing lines Patch % Lines
lcviz/plugins/ephemeris/ephemeris.py 91.04% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #127      +/-   ##
==========================================
- Coverage   93.92%   91.19%   -2.74%     
==========================================
  Files          37       41       +4     
  Lines        1598     2147     +549     
==========================================
+ Hits         1501     1958     +457     
- Misses         97      189      +92     

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

@kecnry kecnry added this to the 0.5.0 milestone Jul 16, 2024
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

I like it! Just a few suggestions, mostly so that we can move towards exposing the API. This will also need test coverage before merge (but I'm guessing that's partly why its still in draft).

I'm not too worried yet about whether this will ultimately live here or need to be shared by other plugins - we're before 1.0 release and haven't committed to backwards compatibility yet, so let's just implement things and we can always change them.

Comment on lines 615 to 648
if self.query_name:
self._query_result = self.nasa_exoplanet_archive.query_object(
self.query_name, table='pscomppars'
)

elif None not in (self.query_ra, self.query_dec):
coord = SkyCoord(ra=self.query_ra, dec=self.query_dec, unit=u.deg)
self._query_result = self.nasa_exoplanet_archive.query_region(
coord, self.query_radius * u.arcsec,
table='pscomppars'
)

else:
# no metadata found for RA, Dec, or object name
return None
Copy link
Member

Choose a reason for hiding this comment

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

can we either have the UI reflect this logic (only show coordinate inputs if the name entry is empty or something) or just require inputing a name (is there ever a case where someone would actually want to use this by coordinates? I guess maybe to search for background contamination?)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My main motivation for the backup here is that anyone can generate a file with whatever they want in the "OBJECT" card, and every star has aliases. If the name that they use can't be resolved by the archive, the coordinates provide another way.

Copy link
Member

Choose a reason for hiding this comment

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

That's fine, I just think we need to think of a UI/UX that helps make that clear. So either a dropdown to choose whether to query by identifier or coords, or have the coords hide when the identifier is not blank might help to make that feel intuitive without having to look in the docs.

lcviz/plugins/ephemeris/ephemeris.py Outdated Show resolved Hide resolved
lcviz/plugins/ephemeris/ephemeris.py Outdated Show resolved Hide resolved
lcviz/plugins/ephemeris/ephemeris.py Outdated Show resolved Hide resolved
lcviz/plugins/ephemeris/ephemeris.py Outdated Show resolved Hide resolved
@bmorris3 bmorris3 marked this pull request as ready for review July 22, 2024 20:50
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

I think eventually we may want to move this up or even into the ephemeris component... component, but this is good for now until we decide what else we want to support for querying (other catalogs, loading from metadata, etc).

Just one comment on the diff and then we can always iterate further later before an official 1.0 release - this definitely is useful to get in ASAP!

lcviz/plugins/ephemeris/ephemeris.py Outdated Show resolved Hide resolved
@bmorris3
Copy link
Contributor Author

@kecnry I've renamed adopt_from_catalog_in_new_viewer to create_ephemeris_from_query, and removed the unused method adopt_from_catalog.

@bmorris3 bmorris3 requested a review from kecnry July 24, 2024 15:23
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

Functionality looks good to me now, just a few requests for API docs, but otherwise I think this is good to go in, thanks!

lcviz/plugins/ephemeris/ephemeris.py Outdated Show resolved Hide resolved
Comment on lines 160 to 161
'adopt_period_at_max_power', 'query_for_ephemeris',
'query_result', 'adopt_from_catalog', 'create_ephemeris_from_query'
Copy link
Member

Choose a reason for hiding this comment

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

query_for_ephemeris, query_result, and create_ephemeris_from_query need to be added to the API docs.

@bmorris3 bmorris3 requested a review from kecnry July 29, 2024 13:58
@kecnry kecnry merged commit 7757a7c into spacetelescope:main Jul 29, 2024
11 of 13 checks passed
@kecnry kecnry mentioned this pull request Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants