-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Enchancing Metadata Support for SOAR #118
Conversation
I'll review this in a bit more detail but can you add unit tests to ensure that detector works in a query as well as the construct methods create the expected queries? |
I've added tests, let me know if its fine. |
sunpy_soar/client.py
Outdated
Instrument table name. | ||
""" | ||
instrument_name = query_item.split("=")[1][1:-1].split("-")[0].upper() | ||
if instrument_name == "STIX": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a dict that maps the full name to the "table" name would be "cleaner" python code.
sunpy_soar/client.py
Outdated
@@ -20,6 +20,8 @@ class SOARClient(BaseClient): | |||
Client to access the Solar Orbiter Archive (SOAR). | |||
""" | |||
|
|||
join_needed = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I like the idea of this being part of the client, can this not be moved else where?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could achieve a solution by making a basic function for it, let me know if its better!
sunpy_soar/tests/test_sunpy_soar.py
Outdated
level = a.Level(1) | ||
res = Fido.search(instrument & time & level) | ||
assert "Detector" in res[0].columns | ||
assert res.file_num == 35 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing the number of results is maybe not very robust, this number might change in SOAR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just followed how tests are already written in test cases. But I do understand your point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can check for at least 35 files?
Based on my research and the insights provided by Eric, I have implemented the wavelength functionality. I believe we should discuss the details of this implementation and further changes needed in this week's meeting. |
Can you add a changelog entry. |
For some reason using detector= "FSI" in query results in an API error
if the query is done without taking detector in it, it gives normal response Even with an invalid detector in the query we get the normal 0 results output. And for other detectors also it works perfectly fine for example
|
sunpy_soar/tests/test_sunpy_soar.py
Outdated
assert "Detector" in res[0].columns | ||
assert res.file_num >= 35 | ||
|
||
# test for invalid detector.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# test for invalid detector.. | |
# Invalid detector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be duplicated?
I also think it should be its own test.
Co-authored-by: Nabil Freij <[email protected]>
sunpy_soar/tests/test_sunpy_soar.py
Outdated
assert res.file_num == 0 | ||
|
||
|
||
def test_search_wavelength_column_wavelength(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like 3 separate tests in one? I think this is the same for the test below as well?
I would prefer if we can keep each unit test as focused as possible.
It makes fixing one easier if one part breaks but not another.
Thanks for the advice to use this indexed column. Maybe indexed columns could be indicated in the Tables, Views, and Columns help page? I understand that timeouts can be expected when using WHERE conditions on non-indexed columns. |
Co-authored-by: Laura Hayes <[email protected]>
@NucleonGodX I think the last thing to do is to not return the PHI wavelengths now until we resolve the issue with the A vs nm. So I think we should just not return it in this PR. And similarly we should not return this for SPICE. Like we discussed on our call yesterday/ So for these both, we should maybe not even return the wavelength column. Let me know if this isnt clear. Apart from these this PR is good to go! |
sunpy_soar/attrs.py
Outdated
def _(wlk, attr, params): # NOQA: ARG001 | ||
wavemin = attr.min.value | ||
wavemax = attr.max.value | ||
params.append(f"Wavemin='{wavemin}'+AND+h2.Wavemax='{wavemax}'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something, but isn't wavemin from h2 too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it is just parsed as a pattern in client.py, shouldn't it be consistent with wavemax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think as we are giving both wavemin and wavemax as a single parameter for query, I think its one of the simpler ways to implement it. If its still necessary to try something else, let me know :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it was just a thought about consistency between Wavemin and Wavemax.
where_part, from_part, select_part = SOARClient.add_join_to_query(query, data_table, instrument_table) | ||
else: | ||
from_part = data_table | ||
select_part = "*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need *
here, as we select not all columns when a join is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for instruments where we don't need the join.
def test_search_wavelength_detector_column(): | ||
instrument = a.Instrument("EUI") | ||
time = a.Time("2021-02-01", "2021-02-02") | ||
level = a.Level(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a test for LL data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there is test_search_low_latency()
(for MAG data; executes the query), and the new test_join_low_latency_query()
(for EUI; only tests the query string, without executing it). So maybe this is enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, will reverse this change!
sunpy_soar/client.py
Outdated
# For PHI, we specify the wavemin as a parameter. | ||
# This enables us to retrieve columns containing wavemin and their corresponding wavemax values. | ||
# For SPICE we get data in form of wavemin/wavemax columns, but only for the first spectral window. | ||
# Therefore, to make sure this data is not misleading to the user we do not return any values. | ||
if "phi" in instrument_table: | ||
parameter = f"Wavemin='{wavemin_match.group(1)}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment we don't consider wavelength for PHI and SPICE (see this comment).
Thanks for the first stage of the project @NucleonGodX, you can now rebase the other two PRs to remove the commits that came from this PR. |
This Pull Request is part of Google Summer of Code (GSoC) 2024, focused on enhancing metadata support for SOAR in sunpy-soar (as discussed in issue #46 ). This initial phase involves integrating attributes from the existing sunpy.net attribute system. Specifically, join methods have been developed, and the Detector attribute has been successfully implemented for remote-sensing instruments.