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

Added nrt keyword to iris.data.query_hek(). #24

Merged
merged 3 commits into from
Feb 27, 2025
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
3 changes: 3 additions & 0 deletions iris/_tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@
@pytest.mark.parametrize("description", [""])
@pytest.mark.parametrize("obs_id", [None, _obsid_b2])
@pytest.mark.parametrize("limit", [5])
@pytest.mark.parametrize("nrt", [False, True])
def test_query_hek(
time_start: None | astropy.time.Time,
time_stop: None | astropy.time.Time,
description: str,
obs_id: None | str,
limit: int,
nrt: bool,
):
result = iris.data.query_hek(
time_start=time_start,
time_stop=time_stop,
description=description,
obs_id=obs_id,
limit=limit,
nrt=nrt,
)
assert isinstance(result, str)

Expand Down
14 changes: 13 additions & 1 deletion iris/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def query_hek(
description: str = "",
obs_id: None | int = None,
limit: int = 200,
nrt: bool = False,
) -> str:
"""
Constructs a query that can be sent to the Heliophysics Event Knowledge
Expand All @@ -43,6 +44,8 @@ def query_hek(
etc. of the observation. If :obj:`None`, all OBSIDs will be used.
limit
the maximum number of files returned by the query
nrt
Whether to return results with near-real-time (NRT) data.

Examples
--------
Expand Down Expand Up @@ -70,12 +73,17 @@ def query_hek(
if time_stop is None:
time_stop = astropy.time.Time.now()

if nrt:
hasData = "false"
else:
hasData = "true"

query_hek = (
"https://www.lmsal.com/hek/hcr?cmd=search-events3"
"&outputformat=json"
f"&startTime={time_start.strftime(format_spec)}"
f"&stopTime={time_stop.strftime(format_spec)}"
"&hasData=true"
f"&hasData={hasData}"
"&hideMostLimbScans=true"
f"&obsDesc={description}"
f"&limit={limit}"
Expand All @@ -92,6 +100,7 @@ def urls_hek(
description: str = "",
obs_id: None | int = None,
limit: int = 200,
nrt: bool = False,
spectrograph: bool = True,
sji: bool = True,
deconvolved: bool = False,
Expand Down Expand Up @@ -126,6 +135,8 @@ def urls_hek(
imagery. Has no effect if ``sji`` is :obj:`False`.
num_retry
The number of times to try to connect to the server.
nrt
Whether to return results with near-real-time (NRT) data.

Examples
--------
Expand All @@ -151,6 +162,7 @@ def urls_hek(
description=description,
obs_id=obs_id,
limit=limit,
nrt=nrt,
)

for i in range(num_retry):
Expand Down