SimCADO Package

simcado.commands module

simcado.commands Module

Functions

dump_defaults([filename, selection])

Dump the frequent.config file to a path specified by the user

dump_chip_layout([path])

Dump the FPA_chip_layout.dat file to a path specified by the user

dump_mirror_config([path, what])

Dump the EC_mirrors_scope.tbl or the EC_mirrors_ao.tbl to disk

read_config(config_file)

Read in a SimCADO configuration file

update_config(config_file, config_dict)

Update a SimCADO configuration dictionary

Classes

UserCommands([filename, sim_data_dir])

An extended dictionary with the parameters needed for running a simulation

simcado.detector module

simcado.detector Module

A description of the Chip noise properties and their positions on the Detector

Module Summary

This module holds three classes: Detector, Chip and HXRGNoise.

Chip Everything to do with photons and electrons happens in the Chip class. Each Chip is initialised with a position relative to the centre of the detector array, a size [in pixels] and a resolution [in arcsec]. Photons fall onto the Chip s and are read out together with the read noise characteristics of the Chip.

Detector The Detector holds the information on where the Chip s are placed on the focal plane. Focal plane coordinates are in [arcsec]. These coordinates are either read in from a default file or determined by the user. The Detector object is an intermediary - it only passes information on the photons to the Chip s. It is mainly a convenience class so that the user can read out all Chip s at the same time.

Classes

Detector

builds an array of Chip objects based on a UserCommands object

Chip

converts incoming photons into ADUs and adds in read-out noise

See Also

simcado.optics.OpticalTrain, simcado.source.Source

Notes

References

[1] Bernhard Rauscher’s HxRG Noise Generator script

Examples

The Detector can be used in stand-alone mode. In this case it outputs only the noise that a sealed-off detector would generate:

>>> import simcado
>>> fpa = simcado.Detector(simcado.UserCommands())
>>> fpa.read_out(output=True, chips=[0])

The Detector is more useful if we combine it with a Source object and an OpticalTrain. Here we create a Source object for an open cluster in the LMC and pass the photons arriving from it through the E-ELT and MICADO. The photons are then cast onto the detector array. Each Chip converts the photons to ADUs and adds the resulting image to an Astropy HDUList. The HDUList is then written to disk.

>>> # Create a set of commands, optical train and detector
>>>
>>> import simcado
>>> cmds = simcado.UserCommands()
>>> opt_train = simcado.OpticalTrain(cmds)
>>> fpa = simcado.Detector(cmds)
>>>
>>> # Pass photons from a 10^4 Msun open cluster in the LMC through to the detector
>>>
>>> src = sim.source.source_1E4_Msun_cluster()
>>> src.apply_optical_train(opt_train, fpa)
>>>
>>># Read out the detector array to a FITS file
>>>
>>> fpa.read_out(filename="my_raw_image.fits")

Functions

open(self, filename)

Opens a saved Detector file.

plot_detector(detector)

Plot the contents of a detector array

plot_detector_layout(detector[, plane, fmt, …])

Plot the detector layout

make_noise_cube([num_layers, filename, …])

Create a large noise cube with many separate readout frames.

install_noise_cube([n])

Install a noise cube in the package directory

Classes

Detector(cmds[, small_fov])

Generate a series of Chip objects for a focal plane array

Chip(x_cen, y_cen, x_len, y_len, pix_res[, …])

Holds the “image” as seen by a single chip in the focal plane

simcado.nghxrg module

simcado.nghxrg Module

NGHXRG by Bernard Rauscher see the paper: http://arxiv.org/abs/1509.06264 downloaded from: http://jwst.nasa.gov/publications.html

Classes

HXRGNoise([naxis1, naxis2, naxis3, n_out, …])

A class to generate HxRG noise frames

simcado.optics module

simcado.optics Module

optics.py

Functions

get_filter_curve(filter_name)

Return a Vis/NIR broadband filter TransmissionCurve object

get_filter_set([path])

Return a list of the filters installed in the package directory

Classes

OpticalTrain(cmds, **kwargs)

The OpticalTrain object reads in or generates the information necessary to model the optical path for all (3) sources of photons: the astronomical source, the atmosphere and the primary mirror.

simcado.psf module

simcado.psf Module

PSFs and PSFCubes

Todo

revise this opening text

Description

Car Sagan said

“If you want to bake an apple pie from scratch,

first you must create the universe”

Single PSFs

We need to start by generating a single PSF in order to generate a PSFCube. We need to know the spatial characteristics of the PSF: The commonalities of all PSFs are:

  • pix_width

  • pix_height

  • pix_res

  • type

The types of PSF offered: Moffat, Gaussian2D, Airy, Delta, Line, User For each of the PSF types we need to create a subclass of PSF. Each subclass takes its own list of parameters:

  • MoffatPSF (alpha, beta)

  • GaussianPSF (fwhm, eccentricity=0, angle=0)

  • AiryPSF (first_zero, eccentricity=0, angle=0)

  • DeltaPSF (x=0, y=0)

  • LinePSF (x0, x1, y0, y1, angle=0)

  • UserPSFCube (filename, ext_no=0)

Multiple PSFs in a Cube

To generate a PSF cube we need to know the spectral bins and the type of PSF. The bins are defined by a central wavelength, however a cube should also contain the edges of each bin so that transmission and emission can be re-binned properly. - lam_bin_centers - lam_bin_edges - lam_res

A PSF instance will have these additional arguments: - array … a 2D array to hold the PSF image

A psf instance will have these additional arguments: - cube … a (l,x,y) 3D array to hold the PSF cube

As far as input goes, psf should be able to accept a dictionary with the keywords necessary to build the cube.

Notes

All wavelength values are given in [um] All pixel dimensions are given in [arcsec] All angles are given in [deg]

Classes

PSF(object) psf(object)

Subclasses

MoffatPSF(PSF) GaussianPSF(PSF) AiryPSF(PSF) DeltaPSF(PSF) LinePSF(PSF) UserPSFCube(PSF)

Deltapsf(psf) Airypsf(psf) Gaussianpsf(psf) Moffatpsf(psf) CombinedPSFCube(psf) UserPSFCube(psf) ADC_psf(psf)

There are two types of psf object here: - a cube - a single psf image

The cube is essentially a list of psf images, homogenized in size Should we have separate classes for these?

Both PSF and psf can be created from a single model or through convolution of a list of PSF components

Functions

poppy_eelt_psf([plan, wavelength, mode, …])

Generate a PSF for the E-ELT for plan A or B with POPPY

poppy_ao_psf(strehl[, mode, plan, size, …])

Create a diffraction limited E-ELT PSF with a Seeing halo

seeing_psf([fwhm, psf_type, size, pix_res, …])

Return a seeing limited PSF

get_eelt_segments([plan, missing, …])

Generate a list of segments for POPPY for the E-ELT

make_foreign_PSF_cube(fnames[, out_name, …])

Combine several PSF FITS images into a single PSF FITS file

Classes

PSF(size, pix_res)

Point spread function (single layer) base class

PSFCube(lam_bin_centers)

Class holding wavelength dependent point spread function.

MoffatPSF(fwhm, **kwargs)

Generate a PSF for a Moffat function.

MoffatPSFCube(lam_bin_centers[, fwhm])

Generate a list of MoffatPSFs for wavelengths defined in lam_bin_centers

AiryPSF(fwhm[, obscuration, size, pix_res])

Generate a PSF for an Airy function with an equivalent FWHM

AiryPSFCube(lam_bin_centers[, fwhm])

Generate a list of AiryPSFs for wavelengths defined in lam_bin_centers

GaussianPSF(fwhm, **kwargs)

Generate a PSF for an Gaussian function

GaussianPSFCube(lam_bin_centers[, fwhm])

Generate a list of GaussianPSFs for wavelengths defined in lam_bin_centers

DeltaPSF(**kwargs)

Generate a PSF with a delta function at position (x,y)

DeltaPSFCube(lam_bin_centers[, positions])

Generate a list of DeltaPSFs for wavelengths defined in lam_bin_centers

CombinedPSF(psf_list, **kwargs)

Generate a PSF from a collection of several PSFs.

CombinedPSFCube(psf_list, **kwargs)

Generate a list of CombinedPSFCubes from the list of psfs in psf_list

UserPSF(filename, **kwargs)

Import a PSF from a FITS file.

UserPSFCube(filename, lam_bin_centers)

Read in a psf previously saved as a FITS file

FieldVaryingPSF(**kwargs)

simcado.simulation module

simcado.simulation Module

simulation.py

Functions

run(src[, mode, cmds, opt_train, fpa, …])

Run a MICADO simulation with default parameters

snr(exptimes, mags[, filter_name, cmds])

Returns the signal-to-noise ratio(s) for given exposure times and magnitudes

check_chip_positions([filename, x_cen, …])

Creates a series of grids of stars and generates the output images

limiting_mags([exptimes, filter_names, …])

Return or plot a graph of the limiting magnitudes for MICADO

zeropoint([filter_name])

Returns the zero point magnitude for a SimCADO filter

simcado.source module

simcado.source Module

The module that contains the functionality to create Source objects

Module Summary

The Source is essentially a list of spectra and a list of positions. The list of positions contains a reference to the relevant spectra. The advantage here is that if there are repeated spectra in a data cube, we can reduce the amount of calculations needed. Furthermore, if the input is originally a list of stars, etc., where the position of a star is not always an integer multiple of the plate scale, we can keep the information until the PSFs are needed.

Classes

Source

Functions

Functions to create Source objects

empty_sky()
star(mag, filter_name="Ks", spec_type="A0V", x=0, y=0)
stars(mags, filter_name="Ks", spec_types=["A0V"], x=[0], y=[0])
star_grid(n, mag_min, mag_max, filter_name="Ks", separation=1, area=1,
          spec_type="A0V")
source_from_image(images, lam, spectra, pix_res, oversample=1,
                  units="ph/s/m2", flux_threshold=0,
                  center_pixel_offset=(0, 0))
source_1E4_Msun_cluster(distance=50000, half_light_radius=1)

Functions for manipulating spectra for a Source object

scale_spectrum(lam, spec, mag, filter_name="Ks", return_ec=False)
scale_spectrum_sb(lam, spec, mag_per_arcsec, pix_res=0.004,
                  filter_name="Ks", return_ec=False)
flat_spectrum(mag, filter_name="Ks", return_ec=False)
flat_spectrum_sb(mag_per_arcsec, filter_name="Ks", pix_res=0.004,
                 return_ec=False)

Functions regarding photon flux and magnitudes

zero_magnitude_photon_flux(filter_name)
_get_stellar_properties(spec_type, cat=None, verbose=False)
_get_stellar_mass(spec_type)
_get_stellar_Mv(spec_type)
_get_pickles_curve(spec_type, cat=None, verbose=False)

Helper functions

value_at_lambda(lam_i, lam, val, return_index=False)
SED(spec_type, filter_name="V", magnitude=0.)

Functions

star([spec_type, mag, filter_name, x, y])

Creates a simcado.Source object for a star with a given magnitude

stars([spec_types, mags, filter_name, x, y])

Creates a simcado.Source object for a bunch of stars.

cluster([mass, distance, half_light_radius])

Generate a source object for a cluster

point_source([spectrum, mag, filter_name, x, y])

Creates a simcado.Source object for a point source with a given magnitude

spiral(half_light_radius, plate_scale[, …])

Create a extended Source object for a “Galaxy”

spiral_profile(r_eff[, ellipticity, angle, …])

Creates a spiral profile with arbitary parameters

elliptical(half_light_radius, plate_scale[, …])

Create a extended Source object for a “Galaxy”

sersic_profile([r_eff, n, ellipticity, …])

Returns a 2D array with a normalised Sersic profile

source_from_image(images, lam, spectra, …)

Create a Source object from an image or a list of images.

star_grid(n, mag_min, mag_max[, …])

Creates a square grid of A0V stars at equal magnitude intervals

empty_sky()

Returns an empty source so that instrumental fluxes can be simulated

SED(spec_type[, filter_name, magnitude])

Return a scaled SED for a star or type of galaxy

redshift_SED(z, spectrum, mag[, filter_name])

Redshift a SimCADO SED and scale it to a magnitude in a user specified filter

sie_grad(x, y, par)

Compute the deflection of an SIE (singular isothermal ellipsoid) potential

apply_grav_lens(image[, x_cen, y_cen, …])

Apply a singular isothermal ellipsoid (SIE) gravitational lens to an image

get_SED_names([path])

Return a list of the SEDs installed in the package directory

scale_spectrum(lam, spec, mag[, …])

Scale a spectrum to be a certain magnitude

scale_spectrum_sb(lam, spec, mag_per_arcsec)

Scale a spectrum to be a certain magnitude per arcsec2

flat_spectrum(mag[, filter_name, return_ec])

Return a flat spectrum scaled to a certain magnitude

flat_spectrum_sb(mag_per_arcsec[, …])

Return a flat spectrum for a certain magnitude per arcsec

value_at_lambda(lam_i, lam, val[, return_index])

Return the value at a certain wavelength - i.e.

BV_to_spec_type(B_V)

Returns the latest main sequence spectral type(s) for (a) B-V colour

zero_magnitude_photon_flux(filter_name)

Return the number of photons for a m=0 star for a filter with synphot

mag_to_photons(filter_name[, magnitude])

Return the number of photons for a certain filter and magnitude

photons_to_mag(filter_name[, photons])

Return the number of photons for a certain filter and magnitude

_get_pickles_curve(spec_type[, cat, verbose])

Returns the emission curve for a single or list of spec_type, normalised to 5556A

_get_stellar_properties(spec_type[, cat, …])

Returns an astropy.Table with the list of properties for the star(s) in spec_type

_get_stellar_Mv(spec_type)

Returns a single (or list of) float(s) with the V-band absolute magnitude(s)

_get_stellar_mass(spec_type)

Returns a single (or list of) float(s) with the stellar mass(es)

Classes

Source([filename, lam, spectra, x, y, ref, …])

Create a source object from a file or from arrays

simcado.spatial module

simcado.spatial Module

TODO: Insert docstring

Functions

tracking(arr, cmds)

A method to simulate tracking errors ===== Currently a place holder with minimum functionality ========= !! TODO, work out the shift during the DIT for the object RA, DEC etc !!

derotator(arr, cmds)

A method to simulate field rotation in case the derotator is <100% effective ===== Currently a place holder with minimum functionality ========= !! TODO, work out the rotation during the DIT for the object RA, DEC etc !!

wind_jitter(arr, cmds)

A method to simulate wind jitter ===== Currently a place holder with minimum functionality ========= !! TODO, get the read spectrum for wind jitter !! !! Add in an angle parameter for the ellipse !!

adc_shift(cmds)

Generates a list of x and y shifts from a commands object

make_distortion_maps(real_xy, detector_xy[, …])

Generate distortion maps based on star positions.

get_distorion_offsets(x, y, dist_map_hdus, …)

Returns the distortion offsets for position relative to the FoV centre

simcado.spectral module

simcado.spectral Module

Classes for spectral curves

Functions

get_sky_spectrum(fname, airmass[, return_type])

Return a spectral curve for the sky for a certain airmass

Classes

TransmissionCurve([filename, lam, val])

Very basic class to either read in a text file for a transmission curve or take two vectors to make a transmission curve

EmissionCurve([filename])

Class for emission curves

BlackbodyCurve(lam, temp, **kwargs)

Blackbody emission curve

UnityCurve([lam, val])

Constant transmission curve

simcado.utils module

simcado.utils Module

Helper functions for SimCADO

Functions

add_SED_to_simcado(file_in[, file_out, …])

Adds the SED given in file_in to the SimCADO data directory

add_keyword(filename, keyword, value[, …])

Add a keyword, value pair to an extension header in a FITS file

add_mags(mags)

Returns a combined magnitude for a group of objects with mags

airmass2zendist(airmass)

Convert airmass to zenith distance

airmass_to_zenith_dist(airmass)

returns zenith distance in degrees

angle_in_arcseconds(distance, width)

Returns the angular distance of an object in arcseconds.

atmospheric_refraction(lam[, z0, temp, …])

Compute atmospheric refraction

bug_report()

Get versions of dependencies for inclusion in bug report

deriv_polynomial2d(poly)

Derivatives (gradient) of a Polynomial2D model

dist_mod_from_distance(d)

mu = 5 * np.log10(d) - 5

distance_from_dist_mod(mu)

d = 10**(1 + mu / 5)

download_file(url[, save_dir])

Download the extra data that aren’t in the SimCADO package

find_file(filename[, path, silent])

Find a file in search path

get_extras()

Downloads large files that SimCADO needs to simulate MICADO

is_fits(filename)

Checks if file is a FITS file based on extension

moffat(r, alpha, beta)

!!Unfinished!! Return a Moffat function

msg(cmds, message[, level])

Prints a message based on the level of verbosity given in cmds

nearest(arr, val)

Return the index of the value from ‘arr’ which is closest to ‘val’

parallactic_angle(ha, de[, lat])

Compute the parallactic angle

poissonify(arr)

Add a realisation of the poisson process to the array ‘arr’.

quantify(item, unit)

Ensure an item is a Quantity

seq(start, stop[, step])

Replacement for numpy.arange modelled after R’s seq function

telescope_diffraction_limit(aperture_size, …)

Returns the diffraction limit of a telescope

transverse_distance(angle, distance)

Turn an angular distance into a proper transverse distance

unify(x, unit[, length])

Convert all types of input to an astropy array/unit pair

zendist2airmass(zendist)

Convert zenith distance to airmass

zenith_dist_to_airmass(zenith_dist)

zenith_dist is in degrees