spectrum - Spectrum manipulations¶
Spectrum I/O, multi-roll merge, adaptive continuum fit, emission-line detection and fit.
Warning
All input wavelengths in Å.
Table(name, colX, colY[, ext, keepHdr]) |
Simple FITS table handler. |
Spectrum(name[, varname, keepFits]) |
FITS 1D-spectrum handler. |
SimSpectrum(name[, varname, keepFits]) |
Multi-roll NISP simulated spectrum (Simulations_140425). |
-
inspec.spectrum.get_extension(name, default=0)[source]¶ Return (name, EXT) from ‘name[ext]’, using default ext if unspecified.
-
class
inspec.spectrum.Table(name, colX, colY, ext=1, keepHdr=False)[source]¶ Simple FITS table handler.
colY can be a single column name (self.ny=1) or a tuple of column names (self.ny=len(colY)). If self.ny>1, self.y is a (self.ny, self.npts) 2D-array. ext specifies the extension number or name, which can also be specified in name[ext].
-
class
inspec.spectrum.Spectrum(name, varname=None, keepFits=True)[source]¶ FITS 1D-spectrum handler.
Class to read and manage a spectrum typically from a FITS file (
NAXIS=1), including the associated [co]variance from an extension or an external file.Warning
this is not directly compatible w/ NISP simulated spectrum from
Simulations_140425. SeeSimSpectrum.Spectrum initialization.
-
hasVar¶
-
hasCov¶
-
setKey(keywords=(), **kwargs)[source]¶ Set keywords from
keywords=((key, val[, comment]),)or kwargskey=valorkey=(val, comment).
-
writeto(outName, force=False, hdrOnly=False, keywords=(), **kwargs)[source]¶ Save Spectrum to new FITS-file.
-
classmethod
read_spectrum(arg, keepFits=True)[source]¶ Return an initiated Spectrum from arg=name[, var_name], including proper deciphering of arg.
-
static
get_varname(specname, exists=False)[source]¶ Return variance spectrum name associated to spectrum ‘specname’. Assumes variance spectrum is located in same directory as spectrum. If exists, test if variance file exists or return None.
-
classmethod
from_vecs(x, y, name='', v=None)[source]¶ Initialize spectrum from arbitrary vectors.
Parameters: - x – wavelength array [Å]
- y – signal array [erg/s/cm²/Å]
- name – name of spectrum
- v – variance array
Raises: AssertionError – incompatible vectors or non-uniformly sampled wavelengths
-
classmethod
from_simtables(name, path='', minnpts=3)[source]¶ Read spectrum stored in simulation table “
name.fits” and associated noise table “name_noise.fits”. ReturnNoneif spectrum is too short.Note
valid for
Simulations_140425.
-
plot(ax=None, errorband=False, sgfilter=None, **kwargs)[source]¶ Plot spectrum.
Parameters: - ax – plot axis
- errorband – add errorbands
- sgfilter – Savitzky-Golay filter parameters
(hsize, order) - kwargs – propagated to
plotcommand
Returns: plot axis
-
fracs(xmin, xmax)¶
-
-
class
inspec.spectrum.SimSpectrum(name, varname=None, keepFits=True)[source]¶ Multi-roll NISP simulated spectrum (
Simulations_140425).Warning
Wavelengths in Å, fluxes in 1e-17 erg/s/cm²/Å.
Spectrum initialization.
-
classmethod
from_idx(idx, path='')[source]¶ Read spectra corresponding to index
idx, return{'roll': spectrum}.
-
static
select_refspec(sdict)[source]¶ Select reference spectrum from
sdict = { 'roll': spectrum }.Select reference with most current start % step = 4.8 A
-
classmethod