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")
class simcado.detector.Detector(cmds, small_fov=True)[source]

Bases: object

Generate a series of Chip objects for a focal plane array

The Detector is a holder for the series of Chip objects which make up the detector array. The main advantage of the Detector object is that the user can read out all chips in the whole detector array at once. A Detector is a parameter in the Source.apply_optical_train() method.

Parameters
cmdsUserCommands

Commands for how to model the Detector

small_fovbool, optional

Default is True. Uses a single 1024x1024 window at the centre of the FoV

Examples

Create a Detector object

>>> import simcado as sim
>>> my_cmds = sim.UserCommands()
>>> my_detector = sim.Detector(my_cmds)

Read out only the first Chip

>>> my_detector.readout(filename=image.fits, chips=[0])
Attributes
cmdsUserCommands

commands for modelling the detector layout and exposures

layoutastropy.table.Table

table of positions and sizes of the chips on the focal plane

chipslist

a list of the Chips which make up the detector array

oversampleint

factor between the internal angular resolution and the pixel FOV

fpa_resfloat

[mas] field of view of a single pixel

ditfloat

[s] exposure time of a single DIT

trofloat

[s] time between consecutive non-destructive readouts in up-the-ramp mode

nditint

number of exposures (DITs)

Methods

read_out()

for reading out the detector array into a FITS file

open()

not yet implemented

write()

not yet implemented Save the Detector object into a FITS file

.. todo::

Open should be moved into a general function for detector.py which returns a Detector object after reading in a saved detector file

read_out(self, filename=None, to_disk=False, chips=None, read_out_type='superfast', **kwargs)[source]

Simulate the read-out process of the detector array

Based on the parameters set in the UserCommands object, the detector will read out the images stored on the Chips according to the specified read-out scheme, i.e. Fowler, up-the-ramp, single read, etc.

Parameters
filenamestr

where the file is to be saved. If None and to_disk is true, the output file is called “output.fits”. Default is None

to_diskbool

a flag for where the output should go. If filename is given or if to_disk=True, the Chip images will be written to a .fits` file on disk. If no filename` is specified, the output will be called “output.fits”.

chipsint, array-like, optional

The chip or chips to be read out, based on the detector_layout.dat file. Default is the first Chip specified in the list, i.e. [0].

read_out_typestr, optional

The name of the algorithm used to read out the chips: - “superfast” - “non_destructive” - “up_the_ramp”

Returns
astropy.io.fits.HDUList
write(self, filename=None, **kwargs)[source]

Write a Detector object out to a FITS file

Writes the important information contained in a Detector object into FITS file for later use. The main information written out includes: the layout of the detector chips, any pixel maps associated with the detector chips, a linearity curve and a QE curve for the chips.

Parameters
filenamestr, optional

path to the FITS file where the Detector object is stored. If filename=None (by default), the file written is ./detector.fits

class simcado.detector.Chip(x_cen, y_cen, x_len, y_len, pix_res, pixsize=15, angle=0, gain=1, obs_coords=[0, 0], fieldangle=0, chipid=None, flat_field=None)[source]

Bases: object

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

The Chip object contains information on where it is located in the focal plane array. The method <Source>.apply_optical_train() passes an image of the on-sky object to each Chip. This image is resampled to the Chip pixel scale. Each Chip holds the “ideal” image as an array of expectation values for number of photons arriving per second. The Chip then adds detector noise and other characteristics to the image when <Detector>.readout() is called.

Parameters
x_cen, y_cenfloat

[micron] the coordinates of the centre of the chip relative to the centre of the focal plane

x_len, y_lenint

the number of pixels per dimension

pix_resfloat

[arcsec] the field of view per pixel

idint

an identification number for the chip (assuming they are not correctly ordered)

flat_fieldnp.ndarray

a 2D array holding the flat fielding effects for the chip

Attributes
x_cen, y_cenfloat

[arcsec] the coordinates of the centre of the chip relative to the centre of the focal plane

naxis1, naxis2int

the number of pixels per dimension

pix_resfloat

[arcsec] the field of view per pixel

chipidint, optional

the id of the chip relative to the others on the detector array. Default is None

dx, dyfloat

[arcsec] half of the field of view of each chip

x_min, x_max, y_min, y_maxfloat

[arcsec] the borders of the chip relative to the centre of the focal plane

arraynp.ndarray

an array for holding the signal registered by the Chip

Methods

add_signal(signal)

adds signal to .array. The signal should be the same dimensions as Chip.array

add_uniform_background(emission, lam_min, lam_max, output=False)

adds a constant to the signal in .array. The background level is found by integrating the emission curve between lam_min and lam_max. If output is set to True, an image with the same dimensions as .array scaled to the background flux is returned.

apply_pixel_map(pixel_map_path=None, dead_pix=None, max_well_depth=1E5)

applies a mask to .array representing the position of the current “hot” and “dead” pixels / lines

reset()

resets the signal on the Chip to zero. In future releases, an implementation of the persistence characteristics of the detector will go here.

add_signal(self, signal)[source]

Add a 2D array of photon signal to the Chip

Add some signal photons to the detector array. Input units are expected to be [ph/s/pixel]

Parameters
signalnp.ndarray

[ph/pixel/s] photon signal. signal should have the same dimensions as the array

Returns
None
add_uniform_background(self, emission, lam_min, lam_max, output=False)[source]

Add a uniform background

Take an EmissionCurve and some wavelength boundaries, lam_min and lam_max, and sum up the photons in between. Add those to the source array.

Parameters
- emission_curve: EmissionCurve object with background emission photons
- lam_min, lam_max: the wavelength limits
Optional keywords:
- output: [False, True] if output is True, the BG emission array is

returned

Output is in [ph/s/pixel].
apply_pixel_map(self, pixel_map_path=None, dead_pix=None, max_well_depth=100000.0)[source]

Adds “hot” and “dead” pixels to the array

applies a mask to .array representing the positions of the current “hot” and “dead” pixels / lines. The method either reads in a FITS file with locations of these pixels, or generates a series of random coordinates and random weights for the pixels.

Parameters
pixel_map_pathstr

path to the FITS file. Default is None

dead_pixint

[%] the percentage of dead or hot pixels on the chip - only used if pixel_map_path = None. Default is None.

max_well_depth1E5
Returns
None
read_out(self, cmds, read_out_type='superfast')[source]

Read out the detector array

Parameters
cmdssimcado.UserCommands

Commands for how to read out the chip

Returns
out_arraynp.ndarray

image of the chip read out

reset(self)[source]
simcado.detector.open(self, filename)[source]

Opens a saved Detector file.

** Not yet implemented ** ** Should be moved outside of Detector and called with detector.open() **

Detector objects can be saved to FITS file and read back in for later simulations.

Parameters
filenamestr

path to the FITS file where the Detector object is stored

Returns
simcado.Detector object
simcado.detector.plot_detector(detector)[source]

Plot the contents of a detector array

Parameters
detectorsimcado.Detector

The detector object to be shown

simcado.detector.plot_detector_layout(detector, plane='sky', fmt='g-', plot_origin=False, label=True, **kwargs)[source]

Plot the detector layout

Parameters
detectorsimcado.Detector

The Detector to be shown

plane‘sky’ or ‘fpa’

Plot detector layout on the sky (in arcsec) or in the focal plane (in mm)

fmtmatplotlib format string
plot_originbool

Mark position pixel (1,1) for each chip.

labelbool

Label the chips with their numberq

simcado.detector.make_noise_cube(num_layers=25, filename='FPA_noise.fits', multicore=True)[source]

Create a large noise cube with many separate readout frames.

Note: Each frame takes about 15 seconds to be generated. The default value of 25 frames will take around six minutes depending on your computer’s architecture.

Parameters
num_layersint, optional

the number of separate readout frames to be generated. Default is 25.

filenamestr, optional

The filename for the FITS cube. Default is “FPA_noise.fits”

multicorebool, optional

If you’re not using windows, this allows the process to use all available cores on your machine to speed up the process. Default is True

Notes

multicore doesn’t work - fix it

simcado.detector.install_noise_cube(n=9)[source]

Install a noise cube in the package directory

Parameters
nint, optional

number of layers.