fisspy/read/read_factory.py
def _waveCalibration(self, simpleWaveCalib= True, absScale= True,
                         **kwargs):
        """
        Wavelength calibration

        If SimpleWvCalib is True, the wavelength is calibrated by using information in header.
        If absScale is True, the central wavelength is set to be wavelength in the lab frame,
        but if absScale is False, the central wavelength is set to be zero.
        """
        method = kwargs.pop('method', True)
        if simpleWaveCalib:
            self.lamb0 = self.header['crval1']
            if absScale:
                self.centralWavelength = self.header['crval1']
                return (np.arange(self.nwv) -
                        self.header['crpix1']) * self.header['cdelt1'] + self.header['crval1']
            else:
                self.centralWavelength = 0
                return (np.arange(self.nwv) -
                        self.header['crpix1']) * self.header['cdelt1']
        else:
            if method:
                if self.band == '6562':
                    line=np.array([6561.097,6564.206])
                    lamb0=6562.817
                    dldw=0.019182
                elif self.band == '8542':
                    line=np.array([8540.817,8546.222])
                    lamb0=8542.090
                    dldw=-0.026252
                elif self.band == '5889':
                    line=np.array([5889.951,5892.898])
                    lamb0=5889.9509
                    dldw=0.016847
                elif self.band == '5434':
                    line=np.array([5434.524,5436.596])
                    lamb0=5434.5235
                    dldw=-0.016847
            else:
                if self.band == '6562':
                    line=np.array([6562.817,6559.580])
                    lamb0=6562.817
                    dldw=0.019182
                elif self.band == '8542':
                    line=np.array([8542.089,8537.930])
                    lamb0=8542.090
                    dldw=-0.026252

        w = np.arange(self.nwv)
        wl = np.zeros(2)
        wc = self.refProfile[20:self.nwv-20].argmin() + 20
        lamb = (w - wc) * dldw + lamb0

        for i in range(2):
            mask = np.abs(lamb - line[i]) <= 0.3
            wtmp = w[mask]
            ptmp = conv(self.refProfile[mask], [-1, 2, -1], 'same')
            mask2 = ptmp[1:-1].argmin() + 1
            try:
                wtmp = wtmp[mask2-3:mask2+4]
                ptmp = ptmp[mask2-3:mask2+4]
            except:
                raise ValueError('Fail to wavelength calibration\n'
                'please change the method %s to %s' %(repr(method), repr(not method)))
            c = np.polyfit(wtmp - np.median(wtmp), ptmp, 2)
            wl[i] = np.median(wtmp) - c[1]/(2*c[0])

        dldw = (line[1] - line[0])/(wl[1] - wl[0])
        wc = wl[0] - (line[0] - lamb0)/dldw
        return (w - wc) * dldw

        Wavelength calibration

        If SimpleWvCalib is True, the wavelength is calibrated by using information in header.
        If absScale is True, the central wavelength is set to be wavelength in the lab frame,
        but if absScale is False, the central wavelength is set to be zero.
        
Wavelength calibration
If SimpleWvCalib is True, the wavelength is calibrated by using information in header.
If absScale is True, the central wavelength is set to be wavelength in the lab frame,
but if absScale is False, the central wavelength is set to be zero.
Wavelength calibration If SimpleWvCalib is True the wavelength is calibrated by using information in header . If absScale is True the central wavelength is set to be wavelength in the lab frame but if absScale is False the central wavelength is set to be zero .
def _waveCalibration(self, simpleWaveCalib= True, absScale= True,
                         **kwargs):
        method = kwargs.pop('method', True)
        if simpleWaveCalib:
            self.lamb0 = self.header['crval1']
            if absScale:
                self.centralWavelength = self.header['crval1']
                return (np.arange(self.nwv) -
                        self.header['crpix1']) * self.header['cdelt1'] + self.header['crval1']
            else:
                self.centralWavelength = 0
                return (np.arange(self.nwv) -
                        self.header['crpix1']) * self.header['cdelt1']
        else:
            if method:
                if self.band == '6562':
                    line=np.array([6561.097,6564.206])
                    lamb0=6562.817
                    dldw=0.019182
                elif self.band == '8542':
                    line=np.array([8540.817,8546.222])
                    lamb0=8542.090
                    dldw=-0.026252
                elif self.band == '5889':
                    line=np.array([5889.951,5892.898])
                    lamb0=5889.9509
                    dldw=0.016847
                elif self.band == '5434':
                    line=np.array([5434.524,5436.596])
                    lamb0=5434.5235
                    dldw=-0.016847
            else:
                if self.band == '6562':
                    line=np.array([6562.817,6559.580])
                    lamb0=6562.817
                    dldw=0.019182
                elif self.band == '8542':
                    line=np.array([8542.089,8537.930])
                    lamb0=8542.090
                    dldw=-0.026252
        w = np.arange(self.nwv)
        wl = np.zeros(2)
        wc = self.refProfile[20:self.nwv-20].argmin() + 20
        lamb = (w - wc) * dldw + lamb0
        for i in range(2):
            mask = np.abs(lamb - line[i]) <= 0.3
            wtmp = w[mask]
            ptmp = conv(self.refProfile[mask], [-1, 2, -1], 'same')
            mask2 = ptmp[1:-1].argmin() + 1
            try:
                wtmp = wtmp[mask2-3:mask2+4]
                ptmp = ptmp[mask2-3:mask2+4]
            except:
                raise ValueError('Fail to wavelength calibration\n'
                'please change the method %s to %s' %(repr(method), repr(not method)))
            c = np.polyfit(wtmp - np.median(wtmp), ptmp, 2)
            wl[i] = np.median(wtmp) - c[1]/(2*c[0])
        dldw = (line[1] - line[0])/(wl[1] - wl[0])
        wc = wl[0] - (line[0] - lamb0)/dldw
        return (w - wc) * dldw
def _waveCalibration ( self , simpleWaveCalib = True , absScale = True , ** kwargs ) : method = kwargs . pop ( 'method' , True ) if simpleWaveCalib : self . lamb0 = self . header [ 'crval1' ] if absScale : self . centralWavelength = self . header [ 'crval1' ] return ( np . arange ( self . nwv ) - self . header [ 'crpix1' ] ) * self . header [ 'cdelt1' ] + self . header [ 'crval1' ] else : self . centralWavelength = 0 return ( np . arange ( self . nwv ) - self . header [ 'crpix1' ] ) * self . header [ 'cdelt1' ] else : if method : if self . band == '6562' : line = np . array ( [ 6561.097 , 6564.206 ] ) lamb0 = 6562.817 dldw = 0.019182 elif self . band == '8542' : line = np . array ( [ 8540.817 , 8546.222 ] ) lamb0 = 8542.090 dldw = - 0.026252 elif self . band == '5889' : line = np . array ( [ 5889.951 , 5892.898 ] ) lamb0 = 5889.9509 dldw = 0.016847 elif self . band == '5434' : line = np . array ( [ 5434.524 , 5436.596 ] ) lamb0 = 5434.5235 dldw = - 0.016847 else : if self . band == '6562' : line = np . array ( [ 6562.817 , 6559.580 ] ) lamb0 = 6562.817 dldw = 0.019182 elif self . band == '8542' : line = np . array ( [ 8542.089 , 8537.930 ] ) lamb0 = 8542.090 dldw = - 0.026252 w = np . arange ( self . nwv ) wl = np . zeros ( 2 ) wc = self . refProfile [ 20 : self . nwv - 20 ] . argmin ( ) + 20 lamb = ( w - wc ) * dldw + lamb0 for i in range ( 2 ) : mask = np . abs ( lamb - line [ i ] ) <= 0.3 wtmp = w [ mask ] ptmp = conv ( self . refProfile [ mask ] , [ - 1 , 2 , - 1 ] , 'same' ) mask2 = ptmp [ 1 : - 1 ] . argmin ( ) + 1 try : wtmp = wtmp [ mask2 - 3 : mask2 + 4 ] ptmp = ptmp [ mask2 - 3 : mask2 + 4 ] except : raise ValueError ( 'Fail to wavelength calibration\n' 'please change the method %s to %s' % ( repr ( method ) , repr ( not method ) ) ) c = np . polyfit ( wtmp - np . median ( wtmp ) , ptmp , 2 ) wl [ i ] = np . median ( wtmp ) - c [ 1 ] / ( 2 * c [ 0 ] ) dldw = ( line [ 1 ] - line [ 0 ] ) / ( wl [ 1 ] - wl [ 0 ] ) wc = wl [ 0 ] - ( line [ 0 ] - lamb0 ) / dldw return ( w - wc ) * dldw
Wavelength calibration
If SimpleWvCalib is True, the wavelength is calibrated by using information in header.
Wavelength calibration If SimpleWvCalib is True the wavelength is calibrated by using information in header .
"""
        Wavelength calibration

        If SimpleWvCalib is True, the wavelength is calibrated by using information in header.
        If absScale is True, the central wavelength is set to be wavelength in the lab frame,
        but if absScale is False, the central wavelength is set to be zero.
        """
self
simpleWaveCalib
absScale