Implement a function that converts from scopesim.Source object to pyxel
ScopeSim source code: https://github.com/AstarVienna/ScopeSim/blob/19b81fb25006b4b55844891e906ff27b8f4feeec/scopesim/source/source.py#L60
(old) simcado docs describing Source object https://simcado.readthedocs.io/en/latest/user_docs/C_Source.html#creating-a-source-object-from-scratch
Example:
Create a new Detector
>>> from pyxel.detectors import CCD
>>> detector = CCD(...)
Create a new ScopeSim Source
>>> from scopesim import Source
>>> source = Source(...)
Conversion from a ScopeSim Source object to a Pyxel Scene object
>>> detector.scene.from_scopesim(source)
>>> detector.scene
Scene(...)
Conversion from a Pyxel Scene object to a ScopeSim Source object
>>> new_source = detector.scene.to_scopesim()
>>> new_source
Source(...) # For ScopeSim
Example with a model using ScopeSim:
from pyxel.detectors import Detector
from scopesim import Source
# generalise this for all scopesim_templates submodules and functions
def add_stars(detector: Detector, **kwargs) -> None:
if not isinstance(detector, pyxel.detectors.Detector):
raise ValueError
# Get a ScopeSim Source objet from 'detector.scene'
actual_source = detector.scene.to_scopesim() # type: Source
# Create a new ScopeSim Source 'final_source'
new_source = stars(**kwargs, output_format="pyxel") # type: Source
final_source = actual_source + new_source # type: Source
# Put the new ScopeSim Source 'final_source' into 'detector.scene'
detector.scene.from_scopesim(final_source)
Edited by Frederic Lemmel