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

Sorting table based on time #96

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/96.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Now query returns time sorted table of results.
4 changes: 3 additions & 1 deletion sunpy_soar/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _do_search(query):
info["begin_time"] = parse_time(info["begin_time"]).iso
info["end_time"] = parse_time(info["end_time"]).iso

return astropy.table.QTable(
result_table = astropy.table.QTable(
{
"Instrument": info["instrument"],
"Data product": info["descriptor"],
Expand All @@ -108,6 +108,8 @@ def _do_search(query):
"SOOP Name": info["soop_name"],
},
)
result_table.sort("Start time")
return result_table

def fetch(self, query_results, *, path, downloader, **kwargs):
"""
Expand Down
4 changes: 3 additions & 1 deletion sunpy_soar/tests/test_sunpy_soar.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_search():
res = Fido.search(instrument, time, level, product)
assert len(res) == 1
assert len(res[0]) == 37
assert u.allclose(res[0, 0]["Filesize"], 3.47 * u.Mbyte)
assert u.allclose(res[0, 0]["Filesize"], 3.45 * u.Mbyte)

# check passing upper case descriptor
product = a.soar.Product("EUI-FSI174-IMAGE")
Expand All @@ -29,7 +29,9 @@ def test_search():
files = Fido.fetch(res[0, 0])
assert len(files) == 1
fname = files[0]

assert u.allclose(Path(fname).stat().st_size * u.byte, res[0, 0]["Filesize"], atol=1e-3 * u.Mbyte)

# Smoke test that we can read this into a map
sunpy.map.Map(fname)

Expand Down
Loading