Exemple #1
0
    def measure_ew(self, flg=1, initial_guesses=None, nsig=3.):
        """ Measures the observer frame equivalent width

        Note this requires self.limits to be initialized
        Default is simple boxcar integration.
        Observer frame, not rest-frame (use measure_restew()
        for rest-frame).

        It sets these attributes:
           * self.attrib['EW', 'sig_EW']:
             The EW and error in observer frame

        Parameters
        ----------
        flg : int
            * 1 -- Boxcar integration (default)
            * 2 -- Gaussian fit
        initial_guesses : tuple of floats [None]
          If a model is chosen (e.g. flg=2, Gaussian) a tuple of
          (amplitude, mean, stddev) can be specified.
        nsig : float, optional
          Number of sigma for flagging

        """
        # Cut spectrum
        fx, sig, xdict = self.cut_spec(normalize=True)
        wv = xdict['wave']
        # Check that there is sufficient data
        if len(fx) <= 1:
            warnings.warn("Spectrum does not cover {:g}".format(self.wrest))
            self.attrib['EW'] = 0.
            self.attrib['sig_EW'] = -1
            return

        # Calculate
        if flg == 1:  # Boxcar
            EW, sig_EW = lau.box_ew((wv, fx, sig))
        elif flg == 2:  #Gaussian
            EW, sig_EW = lau.gaussian_ew((wv, fx, sig),
                                         self.ltype,
                                         initial_guesses=initial_guesses)
        else:
            raise ValueError(
                'measure_ew: Not ready for this flag {:d}'.format(flg))

        # Fill
        self.attrib['EW'] = EW
        self.attrib['sig_EW'] = sig_EW

        # Flagging
        if EW > (sig_EW * nsig):
            self.attrib['flag_EW'] = 1
        else:
            self.attrib['flag_EW'] = 3
Exemple #2
0
    def measure_ew(self, flg=1, initial_guesses=None, nsig=3.):
        """ Measures the observer frame equivalent width

        Note this requires self.limits to be initialized
        Default is simple boxcar integration.
        Observer frame, not rest-frame (use measure_restew()
        for rest-frame).

        It sets these attributes:
           * self.attrib['EW', 'sig_EW']:
             The EW and error in observer frame

        Parameters
        ----------
        flg : int
            * 1 -- Boxcar integration (default)
            * 2 -- Gaussian fit
        initial_guesses : tuple of floats [None]
          If a model is chosen (e.g. flg=2, Gaussian) a tuple of
          (amplitude, mean, stddev) can be specified.
        nsig : float, optional
          Number of sigma for flagging

        """
        # Cut spectrum
        fx, sig, xdict = self.cut_spec(normalize=True)
        wv = xdict['wave']
        # Check that there is sufficient data
        if len(fx) <= 1:
            warnings.warn("Spectrum does not cover {:g}".format(self.wrest))
            self.attrib['EW'] = 0.
            self.attrib['sig_EW'] = -1
            return

        # Calculate
        if flg == 1: # Boxcar
            EW, sig_EW = lau.box_ew( (wv, fx, sig) )
        elif flg == 2: #Gaussian
            EW, sig_EW = lau.gaussian_ew( (wv, fx, sig), self.ltype, initial_guesses=initial_guesses)
        else:
            raise ValueError('measure_ew: Not ready for this flag {:d}'.format(flg))

        # Fill
        self.attrib['EW'] = EW
        self.attrib['sig_EW'] = sig_EW

        # Flagging
        if EW > (sig_EW * nsig):
            self.attrib['flag_EW'] = 1
        else:
            self.attrib['flag_EW'] = 3
Exemple #3
0
    def measure_ew(self, flg=1, initial_guesses=None):
        """  EW calculation
        Default is simple boxcar integration
        Observer frame, not rest-frame (use measure_restew below)
          wvlim must be set!
          spec must be set!

        Parameters
        ----------
        flg: int, optional
          1: Boxcar integration
          2: Gaussian fit
        
        initial_guesses, optional: tuple of floats
          if a model is chosen (e.g. flg=2, Gaussian) a tuple of (amplitude, mean, stddev)
          can be specified. 

        Fills:
        -------
        self.attrib[ 'EW', 'sigEW' ] : 
          EW and error in observer frame
        """
        reload(lau)
        # Cut spectrum
        fx, sig, xdict = self.cut_spec(normalize=True)
        wv = xdict['wave']

        # Calculate
        if flg == 1: # Boxcar
            EW, sigEW = lau.box_ew( (wv, fx, sig) )
        elif flg == 2: #Gaussian
            EW, sigEW = lau.gaussian_ew( (wv, fx, sig), self.ltype, initial_guesses=initial_guesses)
        else:
            raise ValueError('measure_ew: Not ready for this flag {:d}'.format(flg))

        # Fill
        self.attrib['EW'] = EW 
        self.attrib['sigEW'] = sigEW 
Exemple #4
0
    def measure_ew(self, flg=1, initial_guesses=None):
        """ Measures the observer frame equivalent width

        Note this requires the keys `wvlim` and `spec` in analy to
        be set! Default is simple boxcar integration.
        Observer frame, not rest-frame (use measure_restew()
        for rest-frame).

        It sets these attributes:
           * self.attrib['EW', 'sig_EW']:
             The EW and error in observer frame

        Parameters
        ----------
        flg : int
            * 1 -- Boxcar integration (default)
            * 2 -- Gaussian fit
        initial_guesses : tuple of floats [None]
          If a model is chosen (e.g. flg=2, Gaussian) a tuple of
          (amplitude, mean, stddev) can be specified.

        """
        # Cut spectrum
        fx, sig, xdict = self.cut_spec(normalize=True)
        wv = xdict['wave']

        # Calculate
        if flg == 1: # Boxcar
            EW, sig_EW = lau.box_ew( (wv, fx, sig) )
        elif flg == 2: #Gaussian
            EW, sig_EW = lau.gaussian_ew( (wv, fx, sig), self.ltype, initial_guesses=initial_guesses)
        else:
            raise ValueError('measure_ew: Not ready for this flag {:d}'.format(flg))

        # Fill
        self.attrib['EW'] = EW 
        self.attrib['sig_EW'] = sig_EW