Skip to content

Commit

Permalink
Merge pull request #2 from tylerapritchard/pandas_table
Browse files Browse the repository at this point in the history
Pandas table
  • Loading branch information
Nschanche authored Feb 2, 2024
2 parents a187b1f + 7ce03d3 commit 28f7cfd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/newlk_search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ def _search_products(

joint_table = joint_table.to_pandas()


# Add the user-friendly 'author' column (synonym for 'provenance_name')
joint_table["author"] = joint_table["provenance_name"]
# Add the user-friendly 'mission' column
Expand All @@ -996,7 +997,8 @@ def _search_products(
# K2 campaigns 9, 10, and 11 were split into two sections, which are
# listed separately in the table with suffixes "a" and "b"
mask = ((joint_table["project"] == "K2") &
(joint_table["sequence_number"].values.isin([9, 10, 11])))
(joint_table["sequence_number"].isin([9, 10, 11])))


for index, row in joint_table[mask].iterrows():
for half, letter in zip([1,2],["a","b"]):
Expand Down Expand Up @@ -1073,6 +1075,7 @@ def _search_products(
if query_result is not None:
query_result["start_time"] = pd.to_datetime([Time(x + 2400000.5, format="jd").iso for x in query_result['t_min']])
query_result["end_time"] = pd.to_datetime([Time(x + 2400000.5, format="jd").iso for x in query_result['t_max']])

return(SearchResult(query_result))

def _query_mast(
Expand Down Expand Up @@ -1179,7 +1182,7 @@ def _query_mast(
# astroquery does not report distance when querying by `target_name`;
# we add it here so that the table returned always has this column.
obs["distance"] = 0.0
return obs
return(obs)
else:
log.debug(f"No observations found. Now performing a cone search instead.")

Expand Down
12 changes: 11 additions & 1 deletion tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,14 @@ def test_customize_search_result_display_case_nonexistent_column():

search = search_lightcurve("TIC390021728")
search.display_extra_columns = ['foo_col']
assert 'foo_col' not in search.__repr__()
assert 'foo_col' not in search.__repr__()



# Putting the tests I ran while debugging here. We can use or not use these as we see fit
# @pytest.mark.remote_data
#sr = search.search_timeseries('TIC 150428135') # TOI-700

# Should return the same results if searching by TIC or TOI number
# (Note this is not true for objects with neighbors within .0001 arcsec)
assert len(search.search_timeseries('TOI 700').table) == len(search.search_timeseries('TIC 150428135').table)

0 comments on commit 28f7cfd

Please sign in to comment.