Skip to content
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: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "ASTRA-spectra"
version = "1.2.5"
version = "1.2.6"
description = "Interface to open stellar spectra and construct stellar and telluric models"
readme = "README.md"
requires-python = ">=3.11,<=3.12.8"
Expand All @@ -12,6 +12,7 @@ dependencies = [
"matplotlib>=3.10.1",
"numpy>=1.23.2,<2.0.0",
"pandas>=2.2.3",
"pyqt6>=6.11.0",
"scipy>=1.15.2",
"sqlalchemy>=2.0.40",
"sqlalchemy-utils>=0.41.2",
Expand Down
1 change: 1 addition & 0 deletions src/ASTRA/Instruments/ESO_PIPELINE.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(
"INS NAME": "INSTRUME",
"INS MODE": f"HIERARCH {KW_identifier} INS MODE",
"PROG ID": f"HIERARCH {KW_identifier} OBS PROG ID",
"OBS NAME": "HIERARCH ESO OBS NAME",
}
if override_KW_map is not None:
for key, value in override_KW_map.items():
Expand Down
19 changes: 16 additions & 3 deletions src/ASTRA/Instruments/ESPRESSO.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,38 @@ def __init__(
# https://www.eso.org/sci/facilities/paranal/astroclimate/site.html
self.instrument_properties["site_pressure"] = 750

self.is_poet_data = None
self.UT_number = None

def _load_ESO_DRS_KWs(self, header):
super()._load_ESO_DRS_KWs(header)
self.is_poet_data = header.get("ESO INS POET MODE",False)
if self.is_poet_data:
logger.info("Detected PoET frame")
self.UT_number = 5
self.observation_info["POET_APERTURE"] = header.get("ESO POET APER", "UNKNOWN")
def load_telemetry_info(self, header):
# Find the UT number and load the airmass
for i in range(1, 5):
for i in range(1, 6):
try:
self.observation_info["airmass"] = header[f"HIERARCH ESO TEL{i} AIRM START"]
self.UT_number = i
break
except KeyError as e:
if i == 4:
if i == 5:
msg = "\tCannot find ESO TELx AIRM START key"
raise KeyError(msg) from e

# Environmental KWs for telfit (also needs airmassm previously loaded)
ambi_KWs = {
"relative_humidity": "AMBI RHUM",
"ambient_temperature": "AMBI TEMP",
"seeing": "AMBI FWHM START",
}

if self.is_poet_data:
ambi_KWs["seeing"] = "AMBI FWHM"

for name, endKW in ambi_KWs.items():
self.observation_info[name] = float(header[f"HIERARCH ESO TEL{self.UT_number} {endKW}"])
if "temperature" in name: # store temperature in KELVIN for TELFIT
Expand Down
2 changes: 1 addition & 1 deletion src/ASTRA/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""ASTRA - interface for spectra."""

version = "1.2.5"
version = "1.2.6"

__version__ = version.replace(".", "-")
__version_info__ = (int(i) for i in __version__.split("-"))
Expand Down
2 changes: 2 additions & 0 deletions src/ASTRA/base_models/Frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ def __init__(
"INS NAME": "None",
"PROG ID": "None",
"DATE_NIGHT": "None",
"OBS NAME": "",
"POET_APERTURE": None,
}

# Used to allow to reject a wavelength region from one order and keep any overlap that might exist on others
Expand Down
30 changes: 29 additions & 1 deletion src/ASTRA/utils/spectral_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
valid_error_condition = KEYWORD_condition(KW="previousRV_ERR",
bounds = [0, 50*meter_second])

- It is possible to match the Keyword values to a specific one:
.. code-block:: python


valid_error_condition = KEYWORD_condition(KW="OBS NAME",
value = "OB NAME as defined in the header"
)

Rejection based on filenames
================================
Expand Down Expand Up @@ -149,7 +156,6 @@ def evaluate(self, frame: Frame) -> Tuple[bool, List[Flag]]:
if output_flag != VALID:
flags.append(output_flag)
valid_OBS = False

return valid_OBS, flags

def select_spectra(self, frame: Frame) -> Flag:
Expand Down Expand Up @@ -177,6 +183,28 @@ def write_to_disk(self, file: UI_PATH) -> None:
for condition in self._cond_information:
file.write("\t" + "".join(condition) + "\n")

class KEYWORD_value(ConditionModel):
"""Limit the kW to be a specific value."""
def __init__(self, KW: str, value: Any) -> None:
self.KW = KW
self.value = value
super().__init__()


def select_spectra(self, frame) -> Flag:
"""Reject if from a given sub-instrument."""

KW_val = frame.get_KW_value(self.KW)
if KW_val != self.value:
flag = USER_BLOCKED(f"{self.KW} value ({KW_val}) does not match the required one ({self.value})")
else:
flag = VALID
return flag

@property
def cond_info(self) -> str: # noqa: D102
return f"Keyword {self.KW} has value {self.value}"


class KEYWORD_condition(ConditionModel):
"""Limit the KW to be inside the defined interval (edges included)."""
Expand Down
52 changes: 51 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading