Using !-string and #-string commands#
!-strings are for setting simulation parameters#
!-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.
Note: !-strings only work on UserCommands objects
Below is an example of how to use !-strings, using the example optical train.
import scopesim as sim
opt = sim.load_example_optical_train()
opt.cmds["!ATMO"]
[1] mapping
- background:
- filter_name: J
- value: 16.6
- unit: mag
- element_name: basic_atmosphere
opt.cmds["!ATMO.background"]
[1] mapping
- filter_name: J
- value: 16.6
- unit: mag
opt.cmds["!ATMO.background.filter_name"]
'J'
#-strings are for accessing Effect object parameters#
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.
Note: !-strings only work on OpticalTrain objects
Here, we’re again using the example optical train defined above. First let’s list the effects:
opt.effects
| element | name | class | included |
|---|---|---|---|
| str16 | str22 | str29 | bool |
| basic_atmosphere | atmospheric_radiometry | AtmosphericTERCurve | True |
| basic_telescope | psf | SeeingPSF | True |
| basic_telescope | telescope_reflection | TERCurve | True |
| basic_instrument | static_surfaces | SurfaceList | True |
| basic_instrument | filter_wheel : [J] | FilterWheel | True |
| basic_instrument | slit_wheel : [narrow] | SlitWheel | False |
| basic_instrument | image_slicer | ApertureList | False |
| basic_detector | detector_window | DetectorWindow | True |
| basic_detector | detector_3d | DetectorList3D | False |
| basic_detector | qe_curve | QuantumEfficiencyCurve | True |
| basic_detector | exposure_integration | ExposureIntegration | True |
| basic_detector | dark_current | DarkCurrent | True |
| basic_detector | shot_noise | ShotNoise | True |
| basic_detector | detector_linearity | LinearityCurve | True |
| basic_detector | readout_noise | PoorMansHxRGReadoutNoise | True |
| basic_detector | source_fits_keywords | SourceDescriptionFitsKeywords | True |
| basic_detector | effects_fits_keywords | EffectsMetaKeywords | True |
| basic_detector | config_fits_keywords | SimulationConfigFitsKeywords | True |
| basic_detector | extra_fits_keywords | ExtraFitsKeywords | True |
We list the meta dictionary contents by using the string format
"#<effect-name>."
Note: The . at the end is important, otherwise the optical train will look for a non-existant effect named #<effect-name>
opt["#exposure_integration."]
{'filename': None,
'description': 'Summing up sky signal for all DITs and NDITs',
'history': [],
'name': 'exposure_integration',
'image_plane_id': 0,
'temperature': -230,
'dit': '!OBS.dit',
'ndit': '!OBS.ndit',
'width': 1024,
'height': 1024,
'x': 0,
'y': 0,
'element_name': 'basic_detector',
'include': True,
'cmds': CurrObs contents:
CurrSys contents:
├─OBS:
│ ├─instrument: basic_instrument
│ ├─psf_fwhm: 1.5
│ ├─modes: ['imaging']
│ ├─dit: 60
│ ├─ndit: 1
│ ├─slit_name: narrow
│ ├─wavelen: 2.1
│ ├─include_slit: False
│ ├─include_slicer: False
│ ├─include_det_window: True
│ ├─include_det_3d: False
│ └─filter_name: J
├─ATMO:
│ ├─background:
│ │ ├─filter_name: J
│ │ ├─value: 16.6
│ │ └─unit: mag
│ └─element_name: basic_atmosphere
├─TEL:
│ ├─telescope: Basic Telescope
│ ├─temperature: 0
│ ├─element_name: basic_telescope
│ ├─area: 0.19634954084936207 m2
│ └─etendue: 0.007853981633974483 arcsec2 m2
├─INST:
│ ├─temperature: -190
│ ├─pixel_scale: 0.2
│ ├─plate_scale: 20
│ └─element_name: basic_instrument
└─DET:
├─image_plane_id: 0
├─temperature: -230
├─dit: !OBS.dit
├─ndit: !OBS.ndit
├─width: 1024
├─height: 1024
├─x: 0
├─y: 0
└─element_name: basic_detector
SystemDict contents:
├─SIM:
│ ├─spectral:
│ │ ├─wave_min: 0.3
│ │ ├─wave_mid: 2.2
│ │ ├─wave_max: 20
│ │ ├─wave_unit: um
│ │ ├─spectral_bin_width: 0.0001
│ │ ├─spectral_resolution: 5000
│ │ ├─minimum_throughput: 1e-06
│ │ └─minimum_pixel_flux: 1
│ ├─sub_pixel:
│ │ ├─flag: False
│ │ └─fraction: 1
│ ├─random:
│ │ └─seed: None
│ ├─computing:
│ │ ├─chunk_size: 2048
│ │ ├─max_segment_size: 16777217
│ │ ├─oversampling: 1
│ │ ├─spline_order: 1
│ │ ├─flux_accuracy: 0.001
│ │ ├─preload_field_of_views: False
│ │ └─nan_fill_value: 0.0
│ ├─file:
│ │ ├─example_data:
│ │ │ ├─suburl: example_data
│ │ │ └─hash_file: example_data_registry.txt
│ │ ├─psfs:
│ │ │ ├─suburl: psfs
│ │ │ └─hash_file: psfs_registry.txt
│ │ ├─atmo:
│ │ │ ├─suburl: atmo
│ │ │ └─hash_file: atmo_registry.txt
│ │ ├─local_packages_path: /home/docs/checkouts/readthedocs.org/user_builds/scopesim/checkouts/stable/scopesim/tests/mocks
│ │ ├─server_base_url: https://scopesim.univie.ac.at/InstPkgSvr/
│ │ ├─retries: 3
│ │ ├─use_cached_downloads: False
│ │ ├─search_path: ['./inst_pkgs/', './']
│ │ └─error_on_missing_file: False
│ ├─reports:
│ │ ├─ip_tracking: False
│ │ ├─verbose: False
│ │ ├─rst_path: ./reports/rst/
│ │ ├─latex_path: ./reports/latex/
│ │ ├─image_path: ./reports/images/
│ │ ├─image_format: png
│ │ └─preamble_file: None
│ └─tests:
│ ├─run_integration_tests: True
│ └─run_skycalc_ter_tests: True
├─OBS:
├─TEL:
│ ├─etendue: 0
│ └─area: 0
└─INST:
├─pixel_scale: 0
├─plate_scale: 0
└─decouple_detector_from_sky_headers: False}
We print a specific meta parameter by adding it after the .
opt["#exposure_integration.ndit"]
'!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:
opt["#exposure_integration.ndit!"]
1