scopesim.commands.user_commands.UserCommands#
- class scopesim.commands.user_commands.UserCommands(*maps, **kwargs)#
Bases:
NestedChainMapContains all the setting a user may wish to alter for an optical train.
Most of the important settings are kept in the internal nested dictionary. Setting can be accessed by using the alias names. Currently these are:
ATMO: atmospheric and observatory location settings
TEL: telescope related settings
RO: relay optics settings, i.e. between telescope and instrument
INST: instrument optics settings
DET: detector settings
OBS: observation settings, and
SIM: simulation settings
All of the settings are contained in a special
SystemDictdictionary that allows the user to access all the settings via a bang-string (!). E.g:cmds = UserCommands() cmds["!SIM.file.local_packages_path]
Note
To use this format for accessing hierarchically-stored values, the bang string must always begin with a “!”
Alternatively the same value can be accessed via the normal dictionary format. E.g:
cmds["SIM"]["file"]["local_packages_path"]
- Parameters:
use_instrument (str, optional) – The name of the main instrument to use
packages (list, optional) – list of package names needed for the optical system, so that ScopeSim can find the relevant files. E.g. [“Armazones”, “ELT”, “MICADO”]
yamls (list, optional) – list of yaml filenames that are needed for the combined optical system E.g. [“MICADO_Standalone_RO.yaml”, “MICADO_H4RG.yaml”, “MICADO_.yaml”]
mode_yamls (list of yamls, optional) – list of yaml docs (“OBS” docs) that are applicable only to specific operational modes of the instrument. Further yaml files can be specified in the recursive doc entry: “yamls”
set_modes (list of strings, optional) – A list of default mode yamls to load. E.g. [“SCAO”, “IMG_4mas”]
properties (dict, optional) – Any extra “OBS” properties that should be added
ignore_effects (list) – Not yet implemented
add_effects (list) – Not yet implemented
override_effect_values (dict) – Not yet implemented
- cmds#
Built from the
propertiesdictionary of a yaml dictionary. All values here are accessible globally by allEffectsobjects in anOpticalTrainonce theUserCommandshas been passed to theOpticalTrain.- Type:
RecursiveNestedMapping
Examples
Here we use a combination of the main parameters:
packages,yamls, andproperties. When not using theuse_instrumentkey,packagesandyamlsmust be specified, otherwise scopesim will not know where to look for yaml files (only relevant if reading in yaml files):>>> from scopesim.server.database import download_package >>> from scopesim.commands import UserCommands >>> >>> download_package("test_package") >>> cmd = UserCommands(packages=["test_package"],
… yamls=[“test_telescope.yaml”, … {“alias”: “ATMO”, … “properties”: {“pwv”: 9001}}], … properties={“!ATMO.pwv”: 8999})
Notes
Attention
We track your IP address when
ScopeSimchecks for updatesWhen initialising a UserCommands object via
use_instrument=,ScopeSimchecks on the database whether there are updates to the instrument package. Our server records the IP address of each query for out own statistics only.WE DO NOT STORE OR TRACK PERSONAL DATA. THESE STATISTICS ARE NEEDED FOR GETTING MORE FUNDING TO CONTINUE DEVELOPING THIS PROJECT.
We are doing this solely as a way of showing the austrian funding agency that people are indeed using this software (or not). Your participation in this effort greatly helps our chances of securing the next grant.
However, if you would still like to avoid your IP address being stored, you can run
scopesim100% anonymously by setting:>>> scopsim.rc.__config__["!SIM.reports.ip_tracking"] = True
at the beginning of each session. Alternatively you can also pass the same bang keyword when generating a
UserCommandobject:>>> from scopesim import UserCommands >>> UserCommands(use_instrument="MICADO",
… properties={“!SIM.reports.ip_tracking”: False})
If you use a custom
yamlconfiguration file, you can also add this keyword to thepropertiessection of theyamlfile.Changed in version v0.8.0: This now inherits from (a subclass of) collections.ChainMap.
- __init__(*maps, **kwargs)#
Initialize a ChainMap by setting maps to the given mappings. If no mappings are provided, a single empty dictionary is used.
Methods
__init__(*maps, **kwargs)Initialize a ChainMap by setting maps to the given mappings.
clear()Clear maps[0], leaving maps[1:] intact.
copy()New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]
fromkeys(iterable, *args)Create a ChainMap with a single dict created from the iterable.
get(key[, default])D.get(k[,d]) -> D[k] if k in D, else d.
items()D.items() -> a set-like object providing a view on D's items
keys()D.keys() -> a set-like object providing a view on D's keys
Yield tuples of length >= 2 with mode names and descriptions.
new_child([m])New ChainMap with a new map followed by all previous maps.
pop(key, *args)Remove key from maps[0] and return its value.
popitem()Remove and return an item pair from maps[0].
set_modes(*modes)Reload with the specified modes.
setdefault(key[, default])D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
update([other])Update the current parameters with a yaml dictionary.
update_alias(mapping, new_dict)Update a dict-like according to the alias-properties syntax.
values()D.values() -> an object providing a view on D's values
Attributes
- clear()#
Clear maps[0], leaving maps[1:] intact.
- copy()#
New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]
- classmethod fromkeys(iterable, *args)#
Create a ChainMap with a single dict created from the iterable.
- get(key, default=None)#
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- items()#
D.items() -> a set-like object providing a view on D’s items
- keys()#
D.keys() -> a set-like object providing a view on D’s keys
- list_modes() Iterable[tuple[str, ...]]#
Yield tuples of length >= 2 with mode names and descriptions.
Changed in version v0.8.0.
This used to return the formatted string. For a broader range of use cases, it now returns a generator of tuples of strings.
- new_child(m=None, **kwargs)#
New ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Keyword arguments update the map or new empty dict.
- property parents#
].
- Type:
New ChainMap from maps[1
- pop(key, *args)#
Remove key from maps[0] and return its value. Raise KeyError if key not in maps[0].
- popitem()#
Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.
- set_modes(*modes) None#
Reload with the specified modes.
Changed in version v0.8.0.
This used to take a single list-like argument, now used a “*args” approach to deal with multiple modes.
- setdefault(key, default=None)#
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
- update(other=None, /, **kwargs)#
Update the current parameters with a yaml dictionary.
See the
UserCommandsmain docstring for acceptable kwargs
- static update_alias(mapping: MutableMapping, new_dict: Mapping) None#
Update a dict-like according to the alias-properties syntax.
This used to be part of astar_utils.NestedMapping, but is specific to ScopeSim and thus belongs somewhere here. It should only be used in the context of YAML-dicts loaded by UserCommands, hence it was put here.
- values()#
D.values() -> an object providing a view on D’s values