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

Update Fido client for new aspect, ephemeris file name and path #153

Merged
merged 2 commits into from
Jan 30, 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
1 change: 1 addition & 0 deletions changelog/153.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update `Fido` client for change in aspect/ephemeris file name and path.
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ ignore-words-list =
process,
livetime,
technik,
thirdparty
thirdparty,
commutated

[coverage:run]
omit =
Expand Down
10 changes: 5 additions & 5 deletions stixpy/coordinates/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sunpy.coordinates import HeliographicStonyhurst, Helioprojective

from stixpy.coordinates.frames import STIXImaging
from stixpy.coordinates.transforms import _get_aux_data, get_hpc_info
from stixpy.coordinates.transforms import _get_ephemeris_data, get_hpc_info


@pytest.mark.skip(reason="Test data maybe incorrect")
Expand Down Expand Up @@ -85,15 +85,15 @@ def test_stx_to_hpc_obstime_end():
@pytest.mark.remote_data
def test_get_aux_data():
with pytest.raises(ValueError, match="No STIX pointing data found for time range"):
_get_aux_data(Time("2015-06-06")) # Before the mission started
_get_ephemeris_data(Time("2015-06-06")) # Before the mission started

aux_data = _get_aux_data(Time("2022-08-28T16:02:00"))
aux_data = _get_ephemeris_data(Time("2022-08-28T16:02:00"))
assert len(aux_data) == 1341

aux_data = _get_aux_data(Time("2022-08-28T16:02:00"), end_time=Time("2022-08-28T16:04:00"))
aux_data = _get_ephemeris_data(Time("2022-08-28T16:02:00"), end_time=Time("2022-08-28T16:04:00"))
assert len(aux_data) == 1341

aux_data = _get_aux_data(Time("2022-08-28T23:58:00"), end_time=Time("2022-08-29T00:02:00"))
aux_data = _get_ephemeris_data(Time("2022-08-28T23:58:00"), end_time=Time("2022-08-29T00:02:00"))
assert len(aux_data) == 2691


Expand Down
10 changes: 5 additions & 5 deletions stixpy/coordinates/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_hpc_info(times, end_time=None):
-------

"""
aux = _get_aux_data(times.min(), end_time or times.max())
aux = _get_ephemeris_data(times.min(), end_time or times.max())

indices = np.argwhere((aux["time"] >= times.min()) & (aux["time"] <= times.max()))
if end_time is not None:
Expand Down Expand Up @@ -155,7 +155,7 @@ def get_hpc_info(times, end_time=None):


@lru_cache
def _get_aux_data(start_time, end_time=None):
def _get_ephemeris_data(start_time, end_time=None):
r"""
Search, download and read L2 pointing data.

Expand All @@ -175,9 +175,9 @@ def _get_aux_data(start_time, end_time=None):
query = Fido.search(
a.Time(start_time, end_time),
a.Instrument.stix,
a.Level.l2,
a.stix.DataType.aux,
a.stix.DataProduct.aux_ephemeris,
a.Level.anc,
a.stix.DataType.asp,
a.stix.DataProduct.asp_ephemeris,
)
if len(query["stix"]) == 0:
raise ValueError(f"No STIX pointing data found for time range {start_time} to {end_time}.")
Expand Down
26 changes: 0 additions & 26 deletions stixpy/net/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,14 @@

__all__ = ["DataType", "DataProduct"]

DATA_TYPES = ["QL", "SCI", "HK", "CAL"]
DATA_PRODUCTS = [
"ql_lightcurve",
"ql_background",
"ql_variance",
"ql_spectra",
"ql_calibration_spectrum",
"ql_flareflag",
"sci_xray_l0",
"sci_xray_l1",
"sci_xray_l2",
"sci_xray_l3",
"sci_spectrogram",
"sci_visibility",
]


class DataType(SimpleAttr):
"""
Data type Quicklook (QL), science (SCI), or housekeeping (HK)
"""

# def __init__(self, value):
# if str(value).casefold not in [t.casefold for t in DATA_TYPES]:
# raise ValueError(f'Data type must be one of {DATA_TYPES} not {value}')
# super().__init__(value)


class DataProduct(SimpleAttr):
"""
Data product
"""

# def __init__(self, value):
# if str(value).casefold not in [t.casefold for t in DATA_PRODUCTS]:
# raise ValueError(f'Data product must be one of {DATA_PRODUCTS} not {value}')
# super().__init__(value)
13 changes: 7 additions & 6 deletions stixpy/net/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class STIXClient(GenericClient):
<BLANKLINE>
"""

baseurl = r"https://pub099.cs.technik.fhnw.ch/data/fits/" r"{level}/{year:4d}/{month:02d}/{day:02d}/{datatype}/"
baseurl = r"https://pub099.cs.technik.fhnw.ch/data/fits/{level}/{year:4d}/{month:02d}/{day:02d}/{datatype}/"
ql_filename = r"solo_{level}_stix-{product}_\d{{8}}_V\d{{2}}\D?.fits"
sci_filename = r"solo_{level}_stix-{product}_" r"\d{{8}}T\d{{6}}-\d{{8}}T\d{{6}}_V\d{{2}}\D?_.*.fits"

Expand Down Expand Up @@ -85,7 +85,7 @@ def search(self, *args, **kwargs):
elif datatype.lower() == "cal" and product.startswith("cal"):
url = self.baseurl + self.ql_filename
pattern = self.base_pattern + self.ql_pattern
elif datatype.lower() == "aux" and product.startswith("aux"):
elif datatype.lower() == "asp" and product.startswith("asp"):
url = self.baseurl + self.ql_filename
pattern = self.base_pattern + self.ql_pattern

Expand All @@ -104,7 +104,7 @@ def search(self, *args, **kwargs):
rowdict = self.post_search_hook(i, matchdict)
file_tr = rowdict.pop("tr", None)
if file_tr is not None:
# 4 cases file time full in, fully our start in or end in
# 4 cases file time full in, fully our start in or ends in
if file_tr.start >= tr.start and file_tr.end <= tr.end:
metalist.append(rowdict)
elif tr.start <= file_tr.start and tr.end >= file_tr.end:
Expand Down Expand Up @@ -150,15 +150,16 @@ def register_values(cls):
adict = {
attrs.Instrument: [("STIX", "Spectrometer/Telescope for Imaging X-rays")],
attrs.Level: [
("L0", "STIX: Decommutated, uncompressed, uncalibrated data."),
("L0", "STIX: commutated, uncompressed, uncalibrated data."),
("L1", "STIX: Engineering and UTC time conversion ."),
("L2", "STIX: Calibrated data."),
("ANC", "STIX: Ancillary data."),
],
attrs.stix.DataType: [
("QL", "Quick Look"),
("SCI", "Science Data"),
("CAL", "Calibration"),
("AUX", "Auxiliary"),
("ASP", "Aspect"),
("HK", "House Keeping"),
],
attrs.stix.DataProduct: [
Expand All @@ -176,7 +177,7 @@ def register_values(cls):
("sci_xray_scpd", "Summed Compressed Pixel Data"),
("sci_xray_vis", "Visibilities"),
("sci_xray_spec", "Spectrogram"),
("aux_ephemeris", "Auxiliary ephemeris data"),
("asp-ephemeris", "Aspect Solution and Ephemeris data"),
],
}
return adict
Loading