scopesim.commands.scopesimple.Simulation#
- class scopesim.commands.scopesimple.Simulation(instrument: str, mode: str | Sequence[str] | None = None, download_missing: bool = True, **kwargs)#
Bases:
objectConvenience wrapper class for UserCommands and OpticalTrain.
This high-level user interface is intended to simplify the workflow required by ScopeSim. It combines the creation of the
UserCommandsandOpticalTrainobjects, as well as theOpticalTrain.observe()andOpticalTrain.readout()calls into a single callable class.Additonally, it incorporates the downloading of the required IRDB packages, if those are not found in the search path. This functionality can be disabled, see below.
- Parameters:
instrument (str) – Name of the instrument (IRDB package).
mode (str | Sequence[str] | None, optional) – Mode or list of ombined modes for the instrument. Must match a mode listed in the instrument’s IRDB package. If omitted, the default mode defined in the IRDB is used.
download_missing (bool) – If instrument isn’t found, download it. Default is True, but can be switched off (i.e. never auto-download) by setting to False.
**kwargs – Any further arguments accepted by
scopesim.UserCommands.
- last_readout#
- settings#
- plot()#
Plot the simulated image. This method can only be used once the instance has been called with a source object.
- readout()#
Re-readout the detector(s). Can be used to simulate different exptimes.
Examples
Create a simple simulation setup for METIS, with the default IMG-LM mode:
>>> from scopesim import Simulation >>> simulation = Simulation("METIS")
Create a simulation setup for METIS in LSS-L mode:
>>> simulation = Simulation("METIS", "lss_l")
Some instruments, such as MICADO, use independend parallel mode settings:
>>> simulation = Simulation("MICADO", ["SCAO", "IMG_4mas"])
To observe a target, call the simulation on the source. After the simulation was run, the result can be plotted.
>>> from scopesim import Simulation >>> from scopesim_templates import star >>> simulation = Simulation("METIS") >>> source = star("R", 16) >>> output = simulation(source) >>> simulation.plot()
The output of the simulation run is an
astropy.io.fits.HDUListobject, which can be further manipulated. Alternatively, passing a file name or path as the second argument of the simulation call will save the resulting FITS file to disk, to be used by external tools. The following example also includes an exptime value to specify the exposure time:>>> simulation(source, "myoutput.fits", exptime=600)
To simulate different exposure times on an otherwise identical simulation, the
readoutmethod is provided, which can take either dit and ndit as arguments or a single exptime value for instrument setups which use theAutoExposureeffect.- __init__(instrument: str, mode: str | Sequence[str] | None = None, download_missing: bool = True, **kwargs) None#
Methods
__init__(instrument[, mode, download_missing])plot([img_slice, adjust_scale])Show simulated image, return mpl figure and axes.
readout([filename])Readout the detector(s) and optionally save the resulting FITS file.
Attributes
Return instrument name.
Return last readout HDUL, if any.
Return current instrument mode(s).
Return the current settings (UserCommands object).
- property mode: str#
Return current instrument mode(s).
Shortcut for settings[“!OBS.modes”].
Note that some instruments use multiple “parallel” modes, in which case the internal list of strings is converted to a single, comma-separated string.
- plot(img_slice=None, adjust_scale=False, **kwargs)#
Show simulated image, return mpl figure and axes.
- readout(filename: Path | str | None = None, **kwargs) HDUList#
Readout the detector(s) and optionally save the resulting FITS file.
Only available after the simulation was run (i.e. called). This is usually used to run the same simulation with different exposure times, which can be achived by passing exptime as a keyword argument.
This method is also internally called whenever the simulation is run.
- Parameters:
filename (Path | str | None, optional) – Name or path of the FITS output file. The default is None (don’t save anything to disk).
**kwargs – Any keyword arguments passed to
OpticalTrain.readout(). Commonly used keywords are exptime, dit and ndit.
- Returns:
result – List of HDUs containing simulation results.
- Return type:
fits.HDUList
- property settings: UserCommands#
Return the current settings (UserCommands object).