The scene YAML file

As already introduced in The scene file of the initial example, the scene is an auxiliary external YAML file that contains a description of the sources and associated spectra to be simulated.

YAML is a human-friendly data serialization language that can be easily generated and modified with any text editor. See YAML Syntax description for more information.

Warning

Basic rules of YAML files:

  • Indentation matters and plays an important part in structuring the data.

  • The number of spaces doesn’t matter, as long as the child node indentation is greater that its parent. In any case, it is a good practice to keep the same number of spaces to define the indentation level.

  • Never use tabs outside of quoted strings, especially for indentation. The tab character is illegal within YAML files.

  • YAML is case sensitive.

  • YAML’s comments start with a # and go until the end of the line.

The scene file may contain several sources, each one separated by a line containing --- (the end of directives marker in YAML). For each object, a first level of keys must be specified: scene_block_name, spectrum, geometry, nphotons, wavelength_sampling, apply_seeing, apply_atmosphere_transmission and render.

Here’s a skeleton of a YAML scene file containing several sources (note that ... indicates lines to be filled in; see explanation below):

scene_block_name: <string>                         # mandatory
spectrum:                                          # mandatory
  type: <string>
  ...
  ...
geometry:                                          # mandatory
  ...
  ...
nphotons: <number>                                 # mandatory
wavelength_sampling: <random | fixed>              # default: random
apply_seeing: <True | False>                       # default: True
apply_atmosphere_transmission: <True | False>      # default: True
render: <True | False>                             # default: True
---
scene_block_name: <string>                         # mandatory
spectrum:                                          # mandatory
  type: <string>
  ...
  ...
geometry:                                          # mandatory
  ...
  ...
nphotons: <number>                                 # mandatory
wavelength_sampling: <random | fixed>              # default: random
apply_seeing: <True | False>                       # default: True
apply_atmosphere_transmission: <True | False>      # default: True
render: <True | False>                             # default: True
---
...
...

The following provides a detailed description of the different sections that make up each block in a scene.

scene_block_name

The value of this first-level key is a user-defined text string. Its value has no numerical effect on the execution of the simulator, but it allows the user to see which astronomical source is being simulated at any given time in the terminal. This is useful when the scene to be simulated contains multiple sources. Ideally, the text string should not be repeated in different blocks, although this has no impact.

This key is mandatory (it has no default value).

spectrum

This first-level key opens an indented section that contains all the information required to define the kind of spectrum to be associated to the geometry described below.

This key is mandatory (it has no default value).

The following tabs show the different options available. In each case, a general description and an example are provided.

General description

Note: The order of the different key: value pairs within the spectrum level is not relevant.

spectrum:
  type: constant-flux
  wave_min: <float>    # optional (default value: null)
  wave_max: <float>    # optional (default value: null)
  wave_unit: <unit>    # optional (default value: m)

Simulate spectrum with constant flux (in PHOTLAM units). This is the type of spectrum that we simulated in The scene file of the initial example.

If wave_unit is not specified, the default FRIDA wave_unit is assumed (meter, which is the basic irreducible unit adopted in astropy). Otherwise, a valid astropy unit should be employed. Valid options are angstrom, nm, etc.

Both wave_min and wave_max are optional. If they are not specified, the minimum and maximum wavelengths covered by the adopted grating are used.

Example

Unless there is a specific need to use one of the optional parameters, in most cases it is sufficient to use:

spectrum:
  type: constant-flux

geometry

This first-level key opens an indented section that indicates how the photons generated following the previous spectrum type are going to be distributed in the IFU field of view.

This key is mandatory (it has no default value).

The following tabs show the different options available. In each case, a general description and an example are provided.

General description

geometry:
  type: flatfield

This option redistributes the photons homogeneously over the entire field of view of the IFU. It is the appropriate procedure to generate, for example, the contribution of sky emission.

Example

This case is very simple. There are no additional parameters.

geometry:
  type: flatfield

nphotons

The value of this first-level key indicates the initial number of photons to be simulated.

If atmospheric transmission is considered in the simulation, a fraction of the simulated photons will not reach the detector. This means that the final number of simulated photons that reach the detector will be less than this initial number.

Additionally, seeing can cause simulated photons on the edges of the IFU’s field of view to fall outside the IFU when this effect is taken into account, which means that the final number of photons reaching the detector may be even smaller.

This key is mandatory (it has no default value).

wavelength_sampling

Method employed to assing the wavelength to each simulated photon. Two methods have been implemented:

  • random: the simulated wavelengths are assigned by randomly sampling the cumulative distribution function of the simulated spectrum. This method mimics the Poissonian arrival of photons. This should be the default value.

  • fixed: the simulated wavelengths are assigned by uniformly sampling the cumulative distribution function of the simulated spectrum (i.e., avoding the Poissonian noise). This last method should provide a perfectly constant flux (+/- 1 photon due to rounding) for an object with constant PHOTLAM, when using the parameter --spectral_blurring_pixel 0.

This key is not mandatory (default value: random)

apply_seeing

Boolean first-level key indicating whether seeing must be taken into account. If True, each simulated photon is randomly displaced in the focal plane of the IFU according to a probability distribution that is determined by the seeing PSF.

The script arguments seeing_fwhm_arcsec and seeing_psf define the seeing FWHM and the mathematical function employed to reproduce the PSF. Note that this arguments are ignored for those scene sources for which apply_seeing: False.

This key is not mandatory (default value: True).

apply_atmosphere_transmission

Boolean first-level key indicating whether the atmosphere transmission must be considered. If True, the atmosphere transmission defined in the script argument atmosphere_transmission will be used.

This key is not mandatory (default value: True).

render

Boolean first-level key indicate whether the considered scene block must be simulated.

It may be useful to set this key to False when we want to simulate images with several sources in the IFU field of view and one needs to remove some particular objects from the simulation without deleting the corresponding lines in the YAML file.

This key is not mandatory (default value: True).