scopesim.source.source module

# old functionality to implement: # - provide x, y, lam, spectra, weight, ref # - overridden + : number, Source, SourceSpectrum # - overridden * : number, SpectralElement # - write to and read from file # - shift all fields # - rotate around the centre # - photons_in_range returns the photons per spectrum in a wavelength range # - image_in_range returns an image of the source for a wavelength range # # old functionality which will be removed: # - project_onto_chip # - apply_optical_train # # old structure –> new structure: # - all data held in 6 arrays # –> new dicts for fields, spectrum # field can be a Table or an ImageHDU # spectrum is a SourceSpectrum # # Use cases: # image + spectrum # images + spectra # table + spectrum # table + spectra # # table columns = x, y, spec_id, weight # table meta keywords = x_unit, y_unit # # image header keywords = WCS, SPEC_ID, WEIGHT # [WCS = CRPIXn, CRVALn = (0,0), CTYPEn, CDn_m, NAXISn, CUNITn

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, **kwargs)[source]

Bases: SourceBase

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:
filenamestr
lamnp.array

[um] Wavelength bins of length (m)

spectralist of synphot.SourceSpectra

[ph/s/cm2/AA]

x, ynp.array

[arcsec] coordinates of where the emitting files are relative to the centre of the field of view

refnp.array

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

weightnp.array

A weighting to scale the relevant spectrum for each position

tableastropy.Table
image_hdufits.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

fluxastropy.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

See also

synphot

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

Attributes:
fieldslist

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

spectralist of synphot.SourceSpectrum objects

List of spectra associated with the fields

metadict

Dictionary of extra information about the source

add_bandpass(bandpass)[source]
append(source_to_add)[source]
property cube_fields

List of fields that are defined through three-dimensional cubes

dump(filename)[source]

Save to filename as a pickle

fluxes(wave_min, wave_max, **kwargs)[source]
image(wave_min, wave_max, **kwargs)[source]
property image_fields

List of fields that are defined through two-dimensional images

image_in_range(wave_min, wave_max, pixel_scale=<Quantity 1. arcsec>, layers=None, area=None, spline_order=1, sub_pixel=False)[source]
classmethod load(filename)[source]

Load :class:’.Source’ object from filename

make_copy()[source]
photons_in_range(wave_min, wave_max, area=None, indexes=None)[source]
Parameters:
wave_minfloat, u.Quantity

[um]

wave_maxfloat, u.Quantity

[um]

areafloat, u.Quantity, optional

[m2]

indexeslist of integers, optional
Returns:
countsu.Quantity list

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

plot()[source]

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.

rotate(angle, offset=None, layers=None)[source]
shift(dx=0, dy=0, layers=None)[source]

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

Parameters:
dx, dyfloat

[arcsec]

layerslist of ints

which .fields entries to shift

property table_fields

List of fields that are defined through tables