Construction of stellar templates¶
The construction of Stellar templates is handled through the StellarModel interface, which will create independent stellar templates for each sub-Instrument that we have available in the DataClass. The construction of the stellar templates follows the framework described in Silva et al, 2022, and is shematized in here:

In [1]:
Copied!
from pathlib import Path
from ASTRA.data_objects import DataClassManager
from ASTRA.data_objects.DataClass import DataClass
from ASTRA.Instruments import ESPRESSO
from ASTRA.template_creation.StellarModel import StellarModel
storage_path = Path("../../tmp")
manager = DataClassManager()
manager.start()
d: DataClass = manager.DataClass(
list(Path("/home/amiguel/spectra_collection/ESPRESSO/proxima").glob("*.fits")),
storage_path=storage_path,
instrument=ESPRESSO,
)
stell = StellarModel(
storage_path,
user_configs={},
)
stell.Generate_Model(
dataClass=d,
template_configs={},
force_computation=True,
)
from pathlib import Path
from ASTRA.data_objects import DataClassManager
from ASTRA.data_objects.DataClass import DataClass
from ASTRA.Instruments import ESPRESSO
from ASTRA.template_creation.StellarModel import StellarModel
storage_path = Path("../../tmp")
manager = DataClassManager()
manager.start()
d: DataClass = manager.DataClass(
list(Path("/home/amiguel/spectra_collection/ESPRESSO/proxima").glob("*.fits")),
storage_path=storage_path,
instrument=ESPRESSO,
)
stell = StellarModel(
storage_path,
user_configs={},
)
stell.Generate_Model(
dataClass=d,
template_configs={},
force_computation=True,
)
/home/amiguel/development/ASTRA/.venv/lib/python3.12/site-packages/numpy/lib/nanfunctions.py:1215: RuntimeWarning: Mean of empty slice return np.nanmean(a, axis, out=out, keepdims=keepdims)
Accessing the templates¶
After construction of the Stellar template, we can access them independently for each sub-Instrument:
In [2]:
Copied!
stellar_template = stell.request_data("ESPRESSO19")
stellar_template = stell.request_data("ESPRESSO19")
This stellar_template object will have the same spectra-interfacing as the Frames:
In [12]:
Copied!
_ = stellar_template.plot_spectra(order=50)
_ = stellar_template.plot_spectra(order=50)
Load stellar template without interfacing with DataClass¶
It is possible to directly load the stellar template without needing a valid DataClass object. However, doing this is not as direct as using a StellarModel, needing to manually load each sub-Instrument worth of data:
In [17]:
Copied!
from ASTRA.template_creation.stellar_templates.sum_stellar import SumStellar
stell = StellarModel(
storage_path,
user_configs={},
)
stell.Generate_Model(
dataClass=None,
template_configs={
"NUMBER_WORKERS": 1,
"NORMALIZE_SPECTRA": True,
},
force_computation=False,
)
loaded_stellar_template = stell.request_data("ESPRESSO19")
_ = loaded_stellar_template.plot_spectra(order=50)
from ASTRA.template_creation.stellar_templates.sum_stellar import SumStellar
stell = StellarModel(
storage_path,
user_configs={},
)
stell.Generate_Model(
dataClass=None,
template_configs={
"NUMBER_WORKERS": 1,
"NORMALIZE_SPECTRA": True,
},
force_computation=False,
)
loaded_stellar_template = stell.request_data("ESPRESSO19")
_ = loaded_stellar_template.plot_spectra(order=50)