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

Observation mode added as a new metadata. #140

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
11 changes: 11 additions & 0 deletions sunpy_soar/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class SOOP(SimpleAttr):
"""


class ObservationMode(SimpleAttr):
"""
The mode of observation to search for.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this have a fixed set of values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think, for all instruments except SPICE, there aren't many observation modes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know what they are or if we can with that out?

Copy link
Contributor Author

@NucleonGodX NucleonGodX Aug 3, 2024

Choose a reason for hiding this comment

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

I think we can make a list, As Eric suggested for SPICE there are around 80-90. And for others there aren't a lot.

"""


walker = AttrWalker()


Expand Down Expand Up @@ -141,3 +147,8 @@ def _(wlk, attr, params): # NOQA: ARG001
wavemin = attr.min.value
wavemax = attr.max.value
params.append(f"Wavemin='{wavemin}'+AND+Wavemax='{wavemax}'")


@walker.add_applier(ObservationMode)
def _(wlk, attr, params): # NOQA: ARG001
params.append(f"Observation_mode='{attr.value}'")
23 changes: 19 additions & 4 deletions sunpy_soar/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sunpy.net.base_client import BaseClient, QueryResponseTable
from sunpy.time import parse_time

from sunpy_soar.attrs import SOOP, Product, walker
from sunpy_soar.attrs import SOOP, ObservationMode, Product, walker

__all__ = ["SOARClient"]

Expand Down Expand Up @@ -71,7 +71,13 @@ def add_join_to_query(query: list[str], data_table: str, instrument_table: str):
parameter = f"Wavelength='{wavemin_match.group(1)}'"
elif wavemin_match and wavemax_match:
parameter = f"Wavemin='{wavemin_match.group(1)}'+AND+h2.Wavemax='{wavemax_match.group(1)}'"
prefix = "h1." if not parameter.startswith("Detector") and not parameter.startswith("Wave") else "h2."
prefix = (
"h1."
if not parameter.startswith("Detector")
and not parameter.startswith("Wave")
and not parameter.startswith("Observation")
else "h2."
)
if parameter.startswith("begin_time"):
time_list = parameter.split("+AND+")
final_query += f"h1.{time_list[0]}+AND+h1.{time_list[1]}+AND+"
Expand All @@ -90,7 +96,7 @@ def add_join_to_query(query: list[str], data_table: str, instrument_table: str):
)
if instrument_table:
from_part += f" JOIN {instrument_table} AS h2 USING (data_item_oid)"
select_part += ", h2.detector, h2.wavelength, h2.dimension_index"
select_part += ", h2.detector, h2.wavelength, h2.dimension_index, h2.observation_mode"
return where_part, from_part, select_part

@staticmethod
Expand Down Expand Up @@ -204,6 +210,7 @@ def _do_search(query):
)
if "detector" in info:
result_table["Detector"] = info["detector"]
result_table["Observation mode"] = info["observation_mode"]
if "wavelength" in info:
result_table["Wavelength"] = info["wavelength"]
result_table.sort("Start time")
Expand Down Expand Up @@ -253,7 +260,7 @@ def _can_handle_query(cls, *query):
True if this client can handle the given query.
"""
required = {a.Time}
optional = {a.Instrument, a.Detector, a.Wavelength, a.Level, a.Provider, Product, SOOP}
optional = {a.Instrument, a.Detector, a.Wavelength, a.Level, a.Provider, Product, SOOP, ObservationMode}
if not cls.check_attr_types_in_query(query, required, optional):
return False
# check to make sure the instrument attr passed is one provided by the SOAR.
Expand Down Expand Up @@ -290,15 +297,23 @@ def load_dataset_values():
all_instr = json.load(instr_attrs_file)
all_instr = list(all_instr.items())

# SOOP attrs
soop_path = pathlib.Path(__file__).parent / "data" / "soop_attrs.json"
with soop_path.open() as soop_path_file:
all_soops = json.load(soop_path_file)

all_soops = list(all_soops.items())

# Observation modes
obs_modes_path = pathlib.Path(__file__).parent / "data" / "observation_attrs.json"
with obs_modes_path.open() as obs_modes_file:
observation_modes = json.load(obs_modes_file)
observation_modes = list(observation_modes.items())

return {
Product: all_datasets,
a.Instrument: all_instr,
SOOP: all_soops,
a.Provider: [("SOAR", "Solar Orbiter Archive.")],
ObservationMode: observation_modes,
}
39 changes: 30 additions & 9 deletions sunpy_soar/data/attrs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"RPW-SBM1": "Solar Orbiter Radio/Plasma Wave, LL01 parameters",
"RPW-SBM2": "Solar Orbiter Radio/Plasma Wave, LL01 parameters",
"RPW-TNR": "Solar Orbiter Radio/Plasma Wave, LL01 parameters",
"SOC-ORBIT": "Solar Orbiter SOC Ancillary Orbit Data",
"epd-ept-1min": "Solar Orbiter, Level 3 Data, Energetic Particle Detector, Electron Proton Telescope, 1 minute resolution data",
"epd-ept-asun-burst-ele-close": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Electron Proton Telescope, Anti-Sun direction, Burst, Electrons, Close mode",
"epd-ept-asun-burst-ion": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Electron Proton Telescope, Anti-Sun direction, Burst, Ions",
"epd-ept-asun-hcad": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Electron Proton Telescope, Anti-Sun direction, High Cadence",
Expand Down Expand Up @@ -43,13 +45,13 @@
"epd-sis-a-hehist": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, A Telescope, Helium histogram",
"epd-sis-a-rates": "Solar Orbiter, Level 1 Low Latency Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, A Telescope, Particle Rates",
"epd-sis-a-rates-fast": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, A Telescope, Particle rates, fast cadence",
"epd-sis-a-rates-medium": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, A Telescope, Particle rates, medium cadence",
"epd-sis-a-rates-medium": "Solar Orbiter, Level 1 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, A Telescope, Particle rates, medium cadence",
"epd-sis-a-rates-slow": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, A Telescope, Particle rates, slow cadence",
"epd-sis-b-hehist": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, B Telescope, Helium histogram",
"epd-sis-b-rates": "Solar Orbiter, Level 1 Low Latency Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, B Telescope, Particle Rates",
"epd-sis-b-rates-fast": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, B Telescope, Particle rates, fast cadence",
"epd-sis-b-rates-medium": "Solar Orbiter, Level 1 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, B Telescope, Particle rates, medium cadence",
"epd-sis-b-rates-slow": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, B Telescope, Particle rates, slow cadence",
"epd-sis-b-rates-fast": "Solar Orbiter, Level 1 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, B Telescope, Particle rates, fast cadence",
"epd-sis-b-rates-medium": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, B Telescope, Particle rates, medium cadence",
"epd-sis-b-rates-slow": "Solar Orbiter, Level 1 Data, Energetic Particle Detector, Suprathermal Ion Spectrograph, B Telescope, Particle rates, slow cadence",
"epd-step-aux": "Solar Orbiter, Level 1 Data, Energetic Particle Detector, SupraThermal Electrons and Protons, Auxiliary product",
"epd-step-burst": "Solar Orbiter, Level 2 Data, Energetic Particle Detector, SupraThermal Electrons and Protons, Burst",
"epd-step-burst1-close": "Solar Orbiter, Level 1 Data, Energetic Particle Detector, SupraThermal Electrons and Protons, Burst product 1 close mode",
Expand Down Expand Up @@ -112,14 +114,21 @@
"metis-vl-pol-angle": "",
"metis-vl-stokes": "",
"metis-vl-tb": "",
"phi-fdt-bazi": "",
"phi-fdt-binc": "",
"phi-fdt-blos": "",
"phi-fdt-bmag": "",
"phi-fdt-icnt": "",
"phi-fdt-stokes": "",
"phi-fdt-vlos": "",
"phi-hrt-bazi": "",
"phi-hrt-binc": "",
"phi-hrt-blos": "",
"phi-hrt-bmag": "",
"phi-hrt-icnt": "",
"phi-hrt-stokes": "",
"phi-hrt-vlos": "",
"rates": "Solar Orbiter Level 2 Solar Wind Analyser Heavy Ion Sensor Rates",
"rates": "Solar Orbiter Level 1 Solar Wind Analyser Heavy Ion Sensor Rates",
"rpw-bia-density": "Solar Orbiter Radio/Plasma Wave, LFR L3 plasma density derived from the spacecraft potential",
"rpw-bia-density-10-seconds": "Solar Orbiter Radio/Plasma Wave, LFR L3 plasma density derived from the spacecraft potential, downsampled",
"rpw-bia-density-10-seconds-cdag": "Solar Orbiter Radio/Plasma Wave, LFR L3 plasma density derived from the spacecraft potential, downsampled",
Expand All @@ -132,16 +141,17 @@
"rpw-bia-scpot-10-seconds": "Solar Orbiter Radio/Plasma Wave, LFR L3 spacecraft potential, downsampled",
"rpw-bia-scpot-10-seconds-cdag": "Solar Orbiter Radio/Plasma Wave, LFR L3 spacecraft potential, downsampled",
"rpw-bia-scpot-cdag": "Solar Orbiter Radio/Plasma Wave, LFR L3 spacecraft potential",
"rpw-bia-vht": "Solar Orbiter Radio/Plasma Wave, LFR L3 de Hoffmann-Teller solar wind velocity",
"rpw-hfr-surv": "Solar Orbiter Radio/Plasma Wave, HFR L2 parameters",
"rpw-lfr-surv-asm": "Solar Orbiter Radio/Plasma Wave, LFR L2 parameters",
"rpw-lfr-surv-bp1": "Solar Orbiter Radio/Plasma Wave, LFR L2 parameters",
"rpw-lfr-surv-bp2": "Solar Orbiter Radio/Plasma Wave, LFR L2 parameters",
"rpw-lfr-surv-cwf": "Solar Orbiter Radio/Plasma Wave, LFR L1 parameters",
"rpw-lfr-surv-cwf-b": "Solar Orbiter Radio/Plasma Wave, LFR L2 magnetic parameters",
"rpw-lfr-surv-cwf-b": "Solar Orbiter, Level 2, Radio and Plasma Waves, Low Frequency Receiver, Continous Waveform of magnetic data in survey mode",
"rpw-lfr-surv-cwf-e": "Solar Orbiter Radio/Plasma Wave, LFR L2 electric parameters",
"rpw-lfr-surv-cwf-e-cdag": "Solar Orbiter Radio/Plasma Wave, LFR L2 electric parameters",
"rpw-lfr-surv-swf": "Solar Orbiter Radio/Plasma Wave, LFR L1 parameters",
"rpw-lfr-surv-swf-b": "Solar Orbiter Radio/Plasma Wave, LFR L2 magnetic parameters",
"rpw-lfr-surv-swf-b": "Solar Orbiter, Level 2, Radio and Plasma Waves, Low Frequency Receiver, Snapshot Waveform of magnetic data in survey mode",
"rpw-lfr-surv-swf-e": "Solar Orbiter Radio/Plasma Wave, LFR L2 electric parameters",
"rpw-lfr-surv-swf-e-cdag": "Solar Orbiter Radio/Plasma Wave, LFR L2 electric parameters",
"rpw-sbm1": "Solar Orbiter Radio/Plasma Wave, LL02 parameters",
Expand All @@ -150,26 +160,37 @@
"rpw-tds-surv-hist2d": "Solar Orbiter Radio/Plasma Wave, TDS L2 parameters",
"rpw-tds-surv-mamp": "Solar Orbiter Radio/Plasma Wave, TDS L2 parameters",
"rpw-tds-surv-rswf": "Solar Orbiter Radio/Plasma Wave, TDS L1 parameters",
"rpw-tds-surv-rswf-b": "Solar Orbiter Radio/Plasma Wave, TDS L2 magnetic parameters",
"rpw-tds-surv-rswf-b": "Solar Orbiter, Level 2, Radio and Plasma Waves, Time Domain Sampler, Regular Snapshot Waveform of magnetic data in survey mode",
"rpw-tds-surv-rswf-e": "Solar Orbiter Radio/Plasma Wave, TDS L2 waveform snapshots",
"rpw-tds-surv-stat": "Solar Orbiter Radio/Plasma Wave, TDS L2R parameters",
"rpw-tds-surv-tswf": "Solar Orbiter Radio/Plasma Wave, TDS L1 parameters",
"rpw-tds-surv-tswf-b": "Solar Orbiter Radio/Plasma Wave, TDS L2 magnetic parameters",
"rpw-tds-surv-tswf-b": "Solar Orbiter, Level 2, Radio and Plasma Waves, Time Domain Sampler, Triggered Snapshot Waveform of magnetic data in survey mode",
"rpw-tds-surv-tswf-e": "Solar Orbiter Radio/Plasma Wave, TDS L2 waveform snapshots",
"rpw-tnr": "Solar Orbiter Radio/Plasma Wave, LL02 parameters",
"rpw-tnr-fp": "Solar Orbiter Radio/Plasma Wave, data from plasma peak tracking L3",
"rpw-tnr-surv": "Solar Orbiter Radio/Plasma Wave, TNR L2 parameters",
"sensorrates": "solo_L1_swa-his-sensor_rates",
"solohi-11t": "",
"solohi-12t": "",
"solohi-1ft": "",
"solohi-1ut": "",
"solohi-1vt": "",
"solohi-21s": "",
"solohi-21t": "",
"solohi-22t": "",
"solohi-23t": "",
"solohi-24t": "",
"solohi-2ft": "",
"solohi-2us": "",
"solohi-2ut": "",
"solohi-31t": "",
"solohi-32t": "",
"solohi-3fg": "",
"solohi-3ft": "",
"solohi-3ut": "",
"solohi-4-001800001780": "",
"solohi-41t": "",
"solohi-42t": "",
"solohi-4fg": "",
"solohi-4ft": "",
"solohi-4ut": "",
Expand Down
Loading