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

Adding support for query by Solar Distance #137

Merged
merged 17 commits into from
Aug 18, 2024
Merged
8 changes: 6 additions & 2 deletions sunpy_soar/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Distance(Range):
type_name = "distance"

hayesla marked this conversation as resolved.
Show resolved Hide resolved
@quantity_input(dist_min=u.m, dist_max=u.m)
def __init__(self, dist_min: u.Quantity, dist_max: u.Quantity):
def __init__(self, dist_min: u.Quantity, dist_max: u.Quantity): # NOQA: ANN204
nabobalis marked this conversation as resolved.
Show resolved Hide resolved
"""
Specifies the distance range.

Expand All @@ -45,6 +45,7 @@ def __init__(self, dist_min: u.Quantity, dist_max: u.Quantity):
The lower bound of the range.
dist_max : `~astropy.units.Quantity`
The upper bound of the range.

Notes
-----
The valid units for distance are AU, km, and mm. Any unit directly
Expand Down Expand Up @@ -192,7 +193,10 @@ def _(wlk, attr, params): # NOQA: ARG001
# to filter the query without time consideration.
dmin = attr.min.value
dmax = attr.max.value
if not (0.28 <= dmin <= 1.0) or not (0.28 <= dmax <= 1.0):
min_possible = 0.28
max_possible = 1.0

if not (min_possible <= dmin <= max_possible) or not (min_possible <= dmax <= max_possible):
warnings.warn(
"Distance values must be within the range 0.28 AU to 1.0 AU.",
SunpyUserWarning,
Expand Down
3 changes: 1 addition & 2 deletions sunpy_soar/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def add_join_to_query(query: list[str], data_table: str, instrument_table: str):
return where_part, from_part, select_part

@staticmethod
def _construct_payload(query):
def _construct_payload(query): # NOQA: C901
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is C901?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its about the function being too complex.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that should be added to the global ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright!

"""
Construct search payload.

Expand Down Expand Up @@ -296,7 +296,6 @@ def _can_handle_query(cls, *query) -> bool:
bool
True if this client can handle the given query.
"""

required = {Distance} if any(isinstance(q, Distance) for q in query) else {a.Time}

optional = {a.Instrument, a.Detector, a.Wavelength, a.Level, a.Provider, Product, SOOP, Distance, a.Time}
Expand Down