scopesim.source.source.Source#

class scopesim.source.source.Source(filename=None, cube=None, ext=0, lam=None, spectra=None, x=None, y=None, ref=None, weight=None, table=None, image_hdu=None, flux=None, field=None, **kwargs)#

Bases: object

Create a source object from a file or from arrays.

A Source object must consist of a spatial and a spectral description of the on-sky source. Many sources can be added together and kept in memory as a single Source object.

The spatial descriptions are kept in the <Source>.fields list, while the spectral descriptions are in the <Source>.spectra list.

The spatial description can be built from any combination of:

  • a list of arrays (like in SimCADO >v0.5)

  • astropy Table objects

  • astropy ImageHDU objects

  • on disk FITS files

  • on disk ASCII tables

The spectral descriptions can be passed as either synphot.SourceSpectrum objects, or a set of two equal length arrays for wavelength and flux.

Hint

Initialisation parameter combinations include:

New ScopeSim-style input - table=<astropy.Table>, spectra=<list of synphot.SourceSpectrum> - table=<astropy.Table>, lam=<array>, spectra=<list of array> - image_hdu=<fits.ImageHDU>, spectra=<list of synphot.SourceSpectrum> - image_hdu=<fits.ImageHDU>, lam=<array>, spectra=<list of array> - image_hdu=<fits.ImageHDU>, flux=<astropy.Quantity>

Old SimCADO-style input - x=<array>, y=<array>, ref=<array>, spectra=<list of synphot.SourceSpectrum> - x=<array>, y=<array>, ref=<array>, spectra=<list of array>, lam=<array> - x=<array>, y=<array>, ref=<array>, weight=<array>, spectra=<list of array>, lam=<array>

More details on the content of these combinations can be found in the use-case documentation.

Parameters:
  • filename (str)

  • lam (np.array) – [um] Wavelength bins of length (m)

  • spectra (list of synphot.SourceSpectra) – [ph/s/cm2/AA]

  • x (np.array) – [arcsec] coordinates of where the emitting files are relative to the centre of the field of view

  • y (np.array) – [arcsec] coordinates of where the emitting files are relative to the centre of the field of view

  • ref (np.array) – the index for .spectra which connects a position (x, y) to a spectrum flux(x[i], y[i]) = spectra[ref[i]] * weight[i]

  • weight (np.array) – A weighting to scale the relevant spectrum for each position

  • table (astropy.Table)

  • image_hdu (fits.ImageHDU) – [arcsec-2] The .data array is simply a map of weights for the assiciated spectrum referenced by .header[“SPEC_REF]. Surface brightness values are assumed to be per arcsec2

  • flux (astropy.Quantity) – [u.mag, u.ABmag, u.Jy] Flux values are converted to a reference spectrum that is referenced by image_hdu.header[“SPEC_REF”]. flux can only be used in conjuction with image_hdu

fields#

The spatial distribution of the on-sky source, either as fits.ImageHDU or astropy.Table objects

Type:

list

spectra#

Dictionary of spectra associated with the fields

Type:

dict of synphot.SourceSpectrum objects

meta#

Dictionary of extra information about the source

Type:

dict

See also

synphot

https://synphot.readthedocs.io/en/latest/

Added the ability to instantiate directly from an existing SourceField subclass instance.

__init__(filename=None, cube=None, ext=0, lam=None, spectra=None, x=None, y=None, ref=None, weight=None, table=None, image_hdu=None, flux=None, field=None, **kwargs)#

Methods

__init__([filename, cube, ext, lam, ...])

append(source_to_add)

fluxes(wave_min, wave_max, **kwargs)

image(wave_min, wave_max, **kwargs)

image_in_range(wave_min, wave_max[, ...])

make_copy()

photons_in_range(wave_min, wave_max[, area, ...])

plot()

Plot the location of source components.

rotate(angle[, offset, layers])

shift([dx, dy, layers])

Shift the position of one or more fields w.r.t.

Attributes

bandpass

cube_fields

List of fields that are defined through 3D datacubes.

image_fields

List of fields that are defined through 2D images.

meta

spectra

table_fields

List of fields that are defined through tables.

property cube_fields#

List of fields that are defined through 3D datacubes.

property image_fields#

List of fields that are defined through 2D images.

photons_in_range(wave_min, wave_max, area=None, indices=None)#
Parameters:
  • wave_min (float, u.Quantity) – [um]

  • wave_max (float, u.Quantity) – [um]

  • area (float, u.Quantity, optional) – [m2]

  • indices (list of integers, optional)

Returns:

counts – [ph / s / m2] if area is None [ph / s] if area is passed

Return type:

u.Quantity list

plot()#

Plot the location of source components.

Source components instantiated from 2d or 3d ImageHDUs are represented by their spatial footprint. Source components instantiated from tables are shown as points.

shift(dx: float = 0, dy: float = 0, layers=None) None#

Shift the position of one or more fields w.r.t. the optical axis.

Parameters:
  • dx (float) – [arcsec]

  • dy (float) – [arcsec]

  • layers (list of ints) – which .fields entries to shift

property table_fields#

List of fields that are defined through tables.