aosss.blocks package¶
Submodules¶
aosss.blocks.basic module¶
-
class
aosss.blocks.basic.
GroupBlock
¶ Bases:
aosss.blocks.basic._SpectrumListBlock
Blocks whose output have only one spectrum (abbreviated “MDB”)
The “merge down” idea is that output from these blocks have only one spectrum (still stored as a spectrum list though)
This class has no gear and exists for grouping purposes only
-
class
aosss.blocks.basic.
SpectrumBlock
¶ Bases:
aosss.blocks.basic._SpectrumBlock
Spectrum-To-Spectrum
-
use
(inp)¶
-
-
class
aosss.blocks.basic.
SpectrumListBlock
¶ Bases:
aosss.blocks.basic._SpectrumListBlock
Blocks whose output have the same number of spectra as the input (abbreviated “SpectrumListBlock”)
-
class
aosss.blocks.basic.
ToScalar
¶ Bases:
aosss.blocks.basic._SpectrumBlock
Ancestor for Spectrum Blocks whose output is a scalar (abbreviated “SpToSca”)
aosss.blocks.gb module¶
-
class
aosss.blocks.gb.
GB_UseNumPyFunc
(func=<function std>)¶ Bases:
aosss.blocks.basic.GroupBlock
Output contains single spectrum whose y-vector is calculated using a numpy function
The numpy function must be able to operate on the first axis, e.g., np.mean(), np.std()
-
class
aosss.blocks.gb.
GB_SNR
(continua=None)¶ Bases:
aosss.blocks.basic.GroupBlock
Calculates the GB_SNR(lambda) = Power_signal(lambda)/Power_noise(lambda)
Warning Don’t use this block, empirical SNR is usually calculated per spectrum, as reinforced by EC and BLB (using IRAF procedure, which is Amplitude_RMS/std
Parameters: continua – SpectrumList containing the continua that will be used as the “signal” level. If not passed, will be calculated from the input spectra using a SB_Rubberband(True) block References
aosss.blocks.sb module¶
-
class
aosss.blocks.sb.
SB_Rubberband
(flag_upper=True)¶ Bases:
aosss.blocks.basic.SpectrumBlock
Convex polygonal line (aka “rubberband”)
Parameters: flag_upper=True – whether to stretch rubberband from above the spectrum; otherwise, stretches line from below Stretches a polygonal line from below/above the spectrum. The vertices of this multi-segment line will touch “troughs” of the spectrum without crossing the spectrum
This was inspired on – but is not equivalent to – OPUS Rubberband baseline correction [1]. However, this one is parameterless, whereas OPUS RBBC asks for a number of points
References
[1] Bruker Optik GmbH, OPUS 5 Reference Manual. Ettlingen: Bruker, 2004.
-
class
aosss.blocks.sb.
SB_AddNoise
(std=1.0)¶ Bases:
aosss.blocks.basic.SpectrumBlock
Adds normally distributed (Gaussian) random noise
Parameters: std=1. – standard deviation of Gaussian noise
-
class
aosss.blocks.sb.
SB_FNuToFLambda
¶ Bases:
aosss.blocks.sb.SB_ConvertYUnit
Flux-nu to flux-lambda conversion. Assumes the wavelength axis is in angstrom
- Formula:
f_lambda = f_nu*(nu/lambda) = f_nu*c/lambda**2
- where
- lambda is the wavelength in cm, c is the speed of light in cm/s f_lambda has irrelevant unit for this purpose
-
class
aosss.blocks.sb.
SB_FLambdaToFNu
¶ Bases:
aosss.blocks.sb.SB_ConvertYUnit
Flux-nu to flux-lambda conversion. Assumes the wavelength axis is in angstrom
- Formula:
- f_nu = f_lambda*(lambda/nu) = f_lambda*lambda**2/c
-
class
aosss.blocks.sb.
SB_ElementWise
(func)¶ Bases:
aosss.blocks.basic.SpectrumBlock
Applies specified function to spectrum flux
Parameters: func – a function that takes a vector (_i.e._, NumPy 1-D array) as input. It must return vector of same dimension as input.NumPy ufunc’s are suited for this. .. rubric:: Examples
np.square np.exp
- It also be a lambda using list comprehension, for example:
- lambda v: [x**2 for x in v]
-
class
aosss.blocks.sb.
SB_Extend
(fraction=0.1, flag_left=True, flag_right=False, fill_mode='poly_baseline')¶ Bases:
aosss.blocks.basic.SpectrumBlock
Extends to left and/or right side
Parameters: - fraction – amount relative to number of points. Note that this applies individually to left and right (see below)
- flag_left – whether to extend by fraction to left
- flag_right – whether to extend by fraction to right
- fill_mode='poly_baseline' –
how to fill the new points. Valid values: ‘poly_baseline’: The y-value (left/right) to use is found by using a “coarse”
2nd-order polynomial baseline. The baseline is “coarse” because it does not allow for many iterations until the baseline is found’zero’: Fills with zero
Examples
SB_Extend(.1, True, True) # if original has 100 points, resulting will have 120 points
SB_Extend(.1, True, False) # if original has 100 points, resulting will have 110 points
-
class
aosss.blocks.sb.
SB_Cut
(l0, lf)¶ Bases:
aosss.blocks.basic.SpectrumBlock
Cuts spectrum given a wavelength interval
Parameters: - l0 – initial wavelength
- lf – final wavelength
-
class
aosss.blocks.sb.
SB_Normalize
(method='01')¶ Bases:
aosss.blocks.basic.SpectrumBlock
Normalizes spectrum according to specified method
Parameters: -- (method) – “01”: normalizes between 0 and 1 “1”: scales to have maximum at 1, keeping the 0 where it is
-
class
aosss.blocks.sb.
SB_ConvertYUnit
(new_unit)¶ Bases:
aosss.blocks.basic.SpectrumBlock
Converts y-axis unit
Parameters: new_unit – astropy.units.unit or str
-
class
aosss.blocks.sb.
SB_Add
(value=0.0)¶ Bases:
aosss.blocks.basic.SpectrumBlock
Adds constant value to y-values
Parameters: value –
-
class
aosss.blocks.sb.
SB_Mul
(value=1.0)¶ Bases:
aosss.blocks.basic.SpectrumBlock
Multiplies y-values by constant value
Parameters: value –
-
class
aosss.blocks.sb.
SB_MulByLambda
¶ Bases:
aosss.blocks.basic.SpectrumBlock
Multiplies each y-point by its wavelength
-
class
aosss.blocks.sb.
SB_DivByLambda
¶ Bases:
aosss.blocks.basic.SpectrumBlock
Divides each y-point by its wavelength
aosss.blocks.slb module¶
-
class
aosss.blocks.slb.
SLB_UseSpectrumBlock
(sblock=None)¶ Bases:
aosss.blocks.basic.SpectrumListBlock
Calls sblock.use() for each individual spectrum
-
class
aosss.blocks.slb.
SLB_ExtractContinua
¶ Bases:
aosss.blocks.basic.SpectrumListBlock
Calculates upper envelopes and subtracts mean(noise std)
aosss.blocks.toscalar module¶
-
class
aosss.blocks.toscalar.
ToScalar_SNR
(llzero, llfin)¶ Bases:
aosss.blocks.basic.ToScalar
Calculates Signal-to-noise ratio (SNR) using a part of the “signal” (i.e. the spectrum)
- Formula: SNR = sqrt((y_**2)) / std(y_),
Note this has been tested to be consistent with IRAF SNR calculation
Note It is assumed that the “signal” is stationary within [llzero, llfin] meaning that the mean and variance of the “signal” is the same for all points within this region (more precisely “weak-sense stationary” (https://en.wikipedia.org/wiki/Stationary_process#Weak_or_wide-sense_stationarity))
-
class
aosss.blocks.toscalar.
ToScalar_Magnitude
(band_name, system='stdflux', zero_point=0.0, flag_force_band_range=False)¶ Bases:
aosss.blocks.basic.ToScalar
Calculates the magnitude of a spectrum
- Args:
band_name: U/B/V/R/I/Y/J/H/K/L/M/N/Q system: reference magnitude system.
- Choices:
- “stdflux”: literature reference values for bands U,B,V,R,I,J,H,K only “vega”: uses the Vega star spectrum as a reference “ab”: AB[solute] magnitude system
- zero_point: subtracts this value from the calculated magnitude to implement some desired
- correction.
- flag_force_band_range: (default: False) if set, will consider that the spectrum
- extends over the full range of the band even if it is narrower than that
-
class
aosss.blocks.toscalar.
ToScalar_UseNumPyFunc
(func=<function mean>)¶ Bases:
aosss.blocks.basic.ToScalar
Reduces spectrum y-vector to scalar using a numpy function, e.g., np.mean(), np.std()