Skip to content

Commit

Permalink
Sorting table based on time (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
hayesla authored Sep 11, 2023
1 parent e362e92 commit 4ca6c91
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
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

0 comments on commit 4ca6c91

Please sign in to comment.