scopesim.effects.fits_headers module

class scopesim.effects.fits_headers.EffectsMetaKeywords(cmds=None, **kwargs)[source]

Bases: ExtraFitsKeywords

Adds meta dictionary info from all Effects to the FITS headers.

Parameters:
ext_numberint, list of ints, optional

Default 0. The numbers of the extensions to which the header keywords should be added

add_excluded_effectsbool, optional

Default False. Add meta dict for effects with <effect>.include=False

keyword_prefixstr, optional

Default “HIERARCH SIM”. Custom FITS header keyword prefix. Effect meta dict entries will appear in the header as: <keyword_prefix> EFFn <key> : <value>

Examples

Yaml file entry:

name: effect_dumper
class: EffectsMetaKeywords
description: adds all effects meta dict entries to the FITS header
kwargs:
  ext_number: [0, 1]
  add_excluded_effects: False
  keyword_prefix: HIERARCH SIM
apply_to(hdul, **kwargs)[source]

See parent docstring.

class scopesim.effects.fits_headers.ExtraFitsKeywords(cmds=None, **kwargs)[source]

Bases: Effect

Extra FITS header keywords to be added to the pipeline FITS files.

These keywords are ONLY for keywords that should be MANUALLY ADDED to the headers after a simulation is read-out by the detector.

Simulation parameters (Effect kwargs values, etc) will be added automatically by ScopeSim in a different function, but following this format.

The dictionaries should be split into different HIERARCH lists, e.g.:

  • HIERARCH ESO For ESO specific keywords

  • HIERARCH SIM For ScopeSim specific keywords, like simulation parameters

  • HIERARCH MIC For MICADO specific keywords, (unsure what these would be yet)

More HIERARCH style keywords can also be added as needed for other use-cases.

Parameters:
filenamestr, optional

Name of a .yaml nested dictionary file. See below for examples

yaml_stringstr, optional

A triple-” string containing the contents of a yaml file

header_dictnested dicts, optional

A series of nested python dictionaries following the format of the examples below. This keyword allows these dicts to be definied directly in the Effect yaml file, rather than in a seperate header keywords file.

Examples

Specifying the extra FITS keywords directly in the .yaml file where the Effect objects are described.

name: extra_fits_header_entries
class: ExtraFitsKeywords
kwargs:
  header_dict:
    - ext_type: PrimaryHDU
      keywords:
        HIERARCH:
          ESO:
            ATM:
              TEMPERAT: -5

The contents of header_dict can also be abstracted away into a seperate file, e.g. extra_FITS_keys.yaml. The file format is described below in detail below.

name: extra_fits_header_entries
class: ExtraFitsKeywords
kwargs:
  filename: extra_FITS_keys.yaml

The Effect can be added directly in an iPython session.

>>> hdr_dic = {"ext_type": "PrimaryHDU",
               "keywords":
                   {"HIERARCH":
                       {"SIM":
                           {"hello": world}
                       }
                   }
               }
>>> extra_keys = ExtraFitsKeywords(header_dict=hdr_dic)
>>> optical_train.optics_manager.add_effect(extra_keys)
apply_to(hdul, **kwargs)[source]

Add extra fits keywords from a yaml file including !,#-stings.

Parameters:
optical_trainscopesim.OpticalTrain, optional

Used to resolve #-strings

class scopesim.effects.fits_headers.SimulationConfigFitsKeywords(cmds=None, **kwargs)[source]

Bases: ExtraFitsKeywords

Adds parameters from all config dictionaries to the FITS headers.

Parameters:
ext_numberint, list of ints, optional

Default 0. The numbers of the extensions to which the header keywords should be added

resolvebool

Default True. If True, all !-strings and #-strings are resolved via from_currsys before being add to the header. If False, the unaltered !-strings or #-strings are added to the header.

keyword_prefixstr, optional

Default “HIERARCH SIM”. Custom FITS header keyword prefix. Effect meta dict entries will appear in the header as: <keyword_prefix> SRCn <key> : <value>

Examples

Yaml file entry:

name: source_descriptor
class: SimulationConfigFitsKeywords
description: adds info from all config dicts to the FITS header
kwargs:
  ext_number: [0]
  resolve: False
  keyword_prefix: HIERARCH SIM
apply_to(hdul, **kwargs)[source]

See parent docstring.

class scopesim.effects.fits_headers.SourceDescriptionFitsKeywords(cmds=None, **kwargs)[source]

Bases: ExtraFitsKeywords

Adds parameters from all Source fields to the FITS headers.

Parameters:
ext_numberint, list of ints, optional

Default 0. The numbers of the extensions to which the header keywords should be added

keyword_prefixstr, optional

Default “HIERARCH SIM”. Custom FITS header keyword prefix. Effect meta dict entries will appear in the header as: <keyword_prefix> SRCn <key> : <value>

Examples

Yaml file entry:

name: source_descriptor
class: SourceDescriptionFitsKeywords
description: adds info from all Source fields to the FITS header
kwargs:
  ext_number: [0]
  keyword_prefix: HIERARCH SIM
apply_to(hdul, **kwargs)[source]

See parent docstring.

scopesim.effects.fits_headers.flatten_dict(dic, base_key='', flat_dict=None, resolve=False, optics_manager=None, cmds=None)[source]

Flattens nested yaml dictionaries into a single level dictionary.

Parameters:
dicdict
base_keystr
flat_dictdict, optional

Top-level dictionary for recursive calls

resolvebool

If True, resolves !-str via from_currsys and #-str via optics_manager

optics_managerscopesim.OpticsManager

Required for resolving #-strings

cmdsUserCommands

To use for resolving !-strings

Returns:
flat_dictdict
scopesim.effects.fits_headers.get_relevant_extensions(dic, hdul)[source]