[docs]classSingleSpec:def__init__(self,frequency,signal,unit_freq='nm',unit_signal='OD'):""" Class for working with steady state spectra. Parameters ---------- frequency : ndarray The frequencies of the spectrum signal : ndarray Array containing the signal. unit_freq : str Unit type of the frequencies. unit_signal : str Unit type of the signal. """assert(frequency.shape[0]==signal.shape[0])idx=np.argsort(frequency)self.x=frequency[idx]self.y=signal[idx,...]self.unit_freq=unit_freqself.unit_signal=unit_signalself.back=np.zeros_like(self.x)self.fi=dv.make_fi(self.x)self.plot=SingleSpecPlotter(self)
[docs]defsubtract_const(self,region:tuple):""" Subtracts a constant background. The background is calculated by taking the mean signal in the designated region. Parameters ---------- region : tuple of two floats The borders of the region. """a,b=regioni1,i2=self.fi(a),self.fi(b)self.back-=self.y[i1:i2,...].mean(0)
[docs]defcut(self,region,invert_sel=True):""" Cuts part of the spectrum away. Parameters ---------- region : tuple of floats Defines the region to be cutted away. invert_sel : bool If `True`, the cutted region is inverted. Returns ------- SingleSpec Cut spectra. """a,b=regioni1,i2=self.fi(a),self.fi(b)new_x,new_y=self.x[i1:i2],self.y[i1:i2,...]returnSingleSpec(new_x,new_y,self.unit_freq,self.unit_signal)