simcado.spectral module¶
Classes for spectral curves
-
class
simcado.spectral.
TransmissionCurve
(filename=None, lam=None, val=None, **kwargs)[source]¶ Bases:
object
Very basic class to either read in a text file for a transmission curve or take two vectors to make a transmission curve
- Parameters
- filenamestr, optional
The path to the file containing wavelength and transmission data where the first column is wavelength in [um] and the second is the transmission coefficient between [0,1].
Alternatively this data can be passed directly. If filename is not provided,
lam=
andval=
must be passed- lamarray, optional
[um] Wavelength bins in a 1D numpy array of length n
- valarray, optional
[0 .. 1] The transmission coefficients
- Returns
- TransmissionCurve object
-
filter_table
(self)[source]¶ Returns the filter properties as a astropy.table
Notes
ONLY works if filter files have the SimCADO header format
The following keywords should be in the header:
author source date_created date_modified status type center width blue_cutoff red_cutoff
-
normalize
(self, val=1.0, mode='integral')[source]¶ Normalize the spectral curve
- Parameters
- valfloat, optional
The value to normalise to. Default is 1.
- modestr, optional
- “integral” normalizes the integral over the defined
wavelength range to val (default: 1.)
- “maximum” normalizes the maximum over the defined
wavelength range to val (default: 1.)
-
plot
(self, **kwargs)[source]¶ Plot the transmission curve on the current axis
The method accepts matplotlib.pyplot keywords.
-
resample
(self, bins, action='average', use_edges=False, min_step=None, use_default_lam=False)[source]¶ Resamples both the wavelength and value vectors to an even grid. In order to avoid losing spectral information, the TransmissionCurve resamples down to a resolution of ‘min_step’ (default: 0.01nm) before resampling again up to the given sampling vector defined by ‘bins’.
- Parameters
- binsfloat or array of floats
- [um]: float - taken to mean the width of bins on an even grid
- array - the centres of the spectral bins
the edges of the spectral bins if use_edges = True
- actionstr, optional
[‘average’,’sum’] How to rebin the spectral curve. If ‘sum’, then the curve is normalised against the integrated value of the original curve. If ‘average’, the average value per bin becomes the value for each bin.
- use_edgesbool, optional
[False, True] True if the array passed in ‘bins’ describes the edges of the wavelength bins. Default is False
- min_stepfloat, optional
[um] default=1E-4, the step size for the down-sample
- use_default_lambool, optional
Default is False. If True,
bins
is ignored and the default wavelength range is used as the resampling grid.
-
class
simcado.spectral.
EmissionCurve
(filename=None, **kwargs)[source]¶ Bases:
simcado.spectral.TransmissionCurve
Class for emission curves
Create an emission curve from a file or from wavelength and flux vectors. In the latter case, the keywords lam and val have to be specified.
- Parameters
- - filename: string with the path to the transmission curve file where
the first column is wavelength in [um] and the second is the transmission coefficient between [0,1]
- - lam: [um] 1D numpy array of length n
- - val: 1D numpy array of length n
- - res: [um] float with the desired spectral resolution
- - pix_res: [arcsec] float of int for the field of view for each pixel
- - area: [m2] float or int for the collecting area of M1
- - units: string or astropy.unit for calculating the number of photons
per voxel
- Return values are in [ph/s/voxel]
Examples
>>> from simcado.spectral import EmissionCurve >>> >>> ec_1 = EmissionCurve("emission_curve.dat") >>> lam = np.arange(0.7, 1.5, 0.05) >>> flux = 1. - 0.2 * wave**2 # power-law spectrum >>> ec_2 = EmissionCurve(lam=lam, val=flux)
-
convert_to_photons
(self)[source]¶ Do the conversion to photons/s/voxel by using the val_unit, lam, area and exptime keywords. If not given, make some assumptions.
-
class
simcado.spectral.
BlackbodyCurve
(lam, temp, **kwargs)[source]¶ Bases:
simcado.spectral.EmissionCurve
Blackbody emission curve
- Parameters
- lam1D np.ndarray
[um] the centres of the wavelength bins
- tempfloat
[deg C] float for the average temperature of the blackbody
- pix_resfloat, optional
[arcsec] Default is 0.004. Field of view for each pixel
- areafloat, optional
[m2] Default is 978m2. Area of the emitting surface
- Returns
- EmissionCurve object with units of [ph/s/voxel], i.e. photons per second
per wavelength bin per full area per pixel field of view
-
class
simcado.spectral.
UnityCurve
(lam=array([0.3, 3. ]), val=1, **kwargs)[source]¶ Bases:
simcado.spectral.TransmissionCurve
Constant transmission curve
- Parameters
- - lam [um]: wavelength array
- - val: constant value of transmission (default: 1)
-
simcado.spectral.
get_sky_spectrum
(fname, airmass, return_type=None, **kwargs)[source]¶ Return a spectral curve for the sky for a certain airmass
- Parameters
- fnamestr
the file containing the spectral curves
- airmassfloat, optinal
Default is 1.0. Acceptable values are between 1.0 and 3.0
- return_typestr, optional
[“transmission”, “emission”, None] Default is None. A TransmissionCurve or EmissionCurve object will be returned if desired. If None two arrays are returned: (lam, val)
- **kwargsoptional
kwargs are passed directly onto the TransmissionCurve or EmissionCurve classes
- Returns
- TransmissionCurve or EmissionCurve or (lam, val)
By default lam is in [um] and val [ph/s/m2/um/arcsec2] if val is an emission spectrum
Notes
This function is designed to work with a table of values produced by SkyCalc The column names must begin with lambda and then columns must be named according to the airmass following this pattern: “X1.5” for an airmass of 1.5