Skip to content

Commit

Permalink
increasing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Jul 23, 2024
1 parent 12f8c56 commit 888989f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

* Prevent duplicate sub-intervals (quarter/sector/campaign) in data labels. [#120]

* Add feature to query the NASA Exoplanet Archive for exoplanet ephemerides. [#127]

0.4.1 (07.15.2024)
------------------

Expand Down
12 changes: 9 additions & 3 deletions lcviz/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ def light_curve_like_kepler_quarter(seed=42):
)
lc['flux_alt'] = flux + 1
lc['flux_alt_err'] = flux_err
lc.meta['MISSION'] = 'KEPLER'
lc.meta['QUARTER'] = 10
lc.meta['OBJECT'] = 'HAT-P-11'
lc.meta.update(
{
'MISSION': 'KEPLER',
'QUARTER': 10,
'OBJECT': 'HAT-P-11',
'RA': 297.7101763,
'DEC': 48.0818635,
}
)

return lc

Expand Down
8 changes: 5 additions & 3 deletions lcviz/plugins/ephemeris/ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ def query_for_ephemeris(self):
if self.query_name:
# first query by object name:
query_result = self.nasa_exoplanet_archive.query_object(
self.query_name, table='pscomppars'
object_name=self.query_name,
table='pscomppars'
)

if (
Expand All @@ -637,8 +638,9 @@ def query_for_ephemeris(self):
# next query by coordinates:
coord = SkyCoord(ra=self.query_ra, dec=self.query_dec, unit=u.deg)
query_result = self.nasa_exoplanet_archive.query_region(
coord, self.query_radius * u.arcsec,
table='pscomppars'
table='pscomppars',
coordinates=coord,
radius=self.query_radius * u.arcsec,
)

if query_result is None or len(query_result) == 0:
Expand Down
36 changes: 29 additions & 7 deletions lcviz/tests/test_plugin_ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ def test_create_phase_viewer(helper, light_curve_like_kepler_quarter):
assert len(vc.viewer_types) == 3


def compare_against_literature_ephemeris(helper, ephem):
# compare against best/recent parameters:
period_yee_2018 = 4.88780244
assert abs(1 - period_yee_2018 / ephem.period) < 1e-3

epoch_kokori_2022 = 2455109.335119
ref_time = helper.app.data_collection[0].coords.reference_time.jd
expected_t0 = (epoch_kokori_2022 - ref_time) % period_yee_2018
assert abs(1 - expected_t0 / ephem.t0) < 1e-3


def test_ephemeris_queries(helper, light_curve_like_kepler_quarter):
helper.load_data(light_curve_like_kepler_quarter)
ephem = helper.plugins['Ephemeris']
Expand All @@ -146,11 +157,22 @@ def test_ephemeris_queries(helper, light_curve_like_kepler_quarter):
ephem.query_result = planet
ephem.adopt_from_catalog()

# compare against best/recent parameters:
period_yee_2018 = 4.88780244
assert abs(1 - period_yee_2018 / ephem.period) < 1e-3
compare_against_literature_ephemeris(helper, ephem)

epoch_kokori_2022 = 2455109.335119
ref_time = helper.app.data_collection[0].coords.reference_time.jd
expected_t0 = (epoch_kokori_2022 - ref_time) % period_yee_2018
assert abs(1 - expected_t0 / ephem.t0) < 1e-3

def test_ephemeris_query_no_name(helper, light_curve_like_kepler_quarter):
# test that the query successfully falls back on the RA/Dec:
light_curve_like_kepler_quarter.meta['OBJECT'] = ''

helper.load_data(light_curve_like_kepler_quarter)
ephem = helper.plugins['Ephemeris']

ephem.query_for_ephemeris()
# this should be HAT-P-11 b:
planet = ephem.query_result.choices[0]
assert planet == 'HAT-P-11 b'

ephem.query_result = planet
ephem.adopt_from_catalog()

compare_against_literature_ephemeris(helper, ephem)

0 comments on commit 888989f

Please sign in to comment.