Using !-string and #-string commands

!-strings are for setting simulation parameters

TL;DR

import scopesim as sim
opt = sim.load_example_optical_train()
opt.cmds["!ATMO"]
opt.cmds["!ATMO.background"]
opt.cmds["!ATMO.background.filter_name"]

!-strings are a convenient way of accessing multiple layers of a nested dictionary structure with a single string using the format:

"!<ALIAS>.<sub-dict>...<sub-dict>.<param>"

Any level of the nested dictionary can be reached by truncating the keyword.

[1]:
import scopesim as sim
opt = sim.load_example_optical_train()
[2]:
opt.cmds["!ATMO"]
[2]:
{'background': {'filter_name': 'J', 'value': 16.6, 'unit': 'mag'},
 'element_name': 'basic_atmosphere'}
[3]:
opt.cmds["!ATMO.background"]
[3]:
{'filter_name': 'J', 'value': 16.6, 'unit': 'mag'}
[4]:
opt.cmds["!ATMO.background.filter_name"]
[4]:
'J'

#-strings are for accessing Effect object parameters

TL;DR

opt.effects
opt["#exposure_action."]
opt["#exposure_action.ndit"]
opt["#exposure_action.ndit!"]

Similar to !-strings, #-strings allow us to get at the preset values inside the Effect-objects of the optical system. #-strings allow us to pring the contents of an effect’s meta dictionary.

First let’s list the effects

[5]:
opt.effects
[5]:
Table length=17
elementnameclassincluded
str16str22str29bool
basic_atmosphereatmospheric_radiometryAtmosphericTERCurveFalse
basic_telescopepsfSeeingPSFTrue
basic_telescopetelescope_reflectionTERCurveTrue
basic_instrumentstatic_surfacesSurfaceListTrue
basic_instrumentfilter_wheel : [J]FilterWheelTrue
basic_instrumentslit_wheel : [narrow]SlitWheelFalse
basic_detectordetector_windowDetectorWindowTrue
basic_detectorqe_curveQuantumEfficiencyCurveTrue
basic_detectorexposure_actionSummedExposureTrue
basic_detectordark_currentDarkCurrentTrue
basic_detectorshot_noiseShotNoiseTrue
basic_detectordetector_linearityLinearityCurveTrue
basic_detectorreadout_noisePoorMansHxRGReadoutNoiseTrue
basic_detectorsource_fits_keywordsSourceDescriptionFitsKeywordsTrue
basic_detectoreffects_fits_keywordsEffectsMetaKeywordsTrue
basic_detectorconfig_fits_keywordsSimulationConfigFitsKeywordsTrue
basic_detectorextra_fits_keywordsExtraFitsKeywordsTrue

We list the meta dictionary contents by using the string format

"#<effect-name>."
[6]:
opt["#exposure_action."]
[6]:
{'filename': None,
 'description': 'Summing up sky signal for all DITs and NDITs',
 'history': [],
 'name': 'exposure_action',
 'image_plane_id': 0,
 'temperature': -230,
 'dit': '!OBS.dit',
 'ndit': '!OBS.ndit',
 'width': 1024,
 'height': 1024,
 'x': 0,
 'y': 0,
 'element_name': 'basic_detector',
 'z_order': [860],
 'include': True}

We print a specific meta parameter by adding it after the .

[7]:
opt["#exposure_action.ndit"]
[7]:
'!OBS.ndit'

Notice that the value of this dictionary entry is itself a !-string. We can resolve this by adding a ! to the end of the string, to force it to get the actual value from opt.cmds:

[8]:
opt["#exposure_action.ndit!"]
[8]:
1