scopesim.optics.optical_train module¶
- class scopesim.optics.optical_train.OpticalTrain(cmds=None)[source]¶
Bases:
object
The main class for controlling a simulation.
- Parameters:
- cmdsUserCommands, str
If the name of an instrument is passed, OpticalTrain tries to find the instrument package, and internally creates the UserCommands object
Examples
Create an optical train:
>>> import scopesim as im >>> cmd = sim.UserCommands("MICADO") >>> opt = sim.OpticalTrain(cmd)
Observe a Source object:
>>> src = sim.source.source_templates.empty_sky() >>> opt.observe(src) >>> hdus = opt.readout()
List the effects modelled in an OpticalTrain:
>>> print(opt.effects)
Effects can be accessed by using the name of the effect:
>>> print(opt["dark_current"])
To include or exclude an effect during a simulation run, use the
.include
attribute of the effect:>>> opt["dark_current"].include = False
Data used by an Effect object is contained in the
.data
attribute, while other information is contained in the.meta
attribute:>>> opt["dark_current"].data >>> opt["dark_current"].meta
Meta data values can be set by either using the
.meta
attribute directly:>>> opt["dark_current"].meta["value"] = 0.5
or by passing a dictionary (with one or multiple entries) to the OpticalTrain object:
>>> opt["dark_current"] = {"value": 0.75, "dit": 30}
- property effects¶
- load(user_commands)[source]¶
(Re)Load an OpticalTrain with a new set of UserCommands.
- Parameters:
- user_commandsUserCommands or str
- observe(orig_source, update=True, **kwargs)[source]¶
Main controlling method for observing
Source
objects.- Parameters:
- orig_sourceSource
- updatebool
Reload optical system
- kwargsexpanded dict
Any keyword-value pairs from a config file
Notes
How the list of Effects is split between the 5 main tasks:
Make a FOV list - z_order = 0..99
Make a image plane - z_order = 100..199
Apply Source altering effects - z_order = 200..299
Apply FOV specific (3D) effects - z_order = 300..399
Apply FOV-independent (2D) effects - z_order = 400..499
[Apply detector plane (0D, 2D) effects - z_order = 500..599]
Todo
List is out of date - update
- prepare_source(source)[source]¶
Prepare source for observation.
The method is currently applied to cube fields only. The source data are converted to internally used units (PHOTLAM). The source data are interpolated to the waveset used by the FieldOfView This is necessary when the source data are sampled on a coarser grid than used internally, or if the source data are sampled on irregular wavelengths. For cube fields, the method assumes that the wavelengths at which the cube is sampled is provided explicitely as attribute wave if the cube ImageHDU.
- readout(filename=None, **kwargs)[source]¶
Produce detector readouts for the observed image.
- Parameters:
- filenamestr, optional
Where to save the FITS file
- kwargs
- Returns:
- hdufits.HDUList
Notes
Apply detector plane (0D, 2D) effects - z_order = 500..599
- shutdown()[source]¶
Shut down the instrument.
This method closes all open file handles and should be called when the optical train is no longer needed.