Changeset 1644 for trunk/python


Ignore:
Timestamp:
10/04/09 00:53:18 (15 years ago)
Author:
Max Voronkov
Message:

line finder: added more options on how the noise is to be estimated. See doc on linefinder.set_options for more info

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asaplinefind.py

    r929 r1644  
    4141
    4242    def set_options(self,threshold=1.7320508075688772,min_nchan=3,
    43         avg_limit=8,box_size=0.2):
     43        avg_limit=8,box_size=0.2,noise_box='all',noise_stat='mean80'):
    4444        """
    4545        Set the parameters of the algorithm
     
    5555                          this parameter can be averaged to search for
    5656                          broad lines. Default is 8.
    57              box_size     A running mean box size specified as a fraction
     57             box_size     A running mean/median box size specified as a fraction
    5858                          of the total spectrum length. Default is 1/5
     59             noise_box    Area of the spectrum used to estimate noise stats
     60                          Both string values and numbers are allowed
     61                          Allowed string values:
     62                             'all' use all the spectrum (default)
     63                             'box' noise box is the same as running mean/median
     64                                   box
     65                          Numeric values are defined as a fraction from the
     66                          spectrum size. Values should be positive.
     67                          (noise_box == box_size has the same effect as
     68                           noise_box = 'box')
     69             noise_stat   Statistics used to estimate noise, allowed values:
     70                              'mean80' use the 80% of the lowest deviations
     71                                       in the noise box (default)
     72                              'median' median of deviations in the noise box
     73                             
    5974        Note:  For bad baselines threshold should be increased,
    6075               and avg_limit decreased (or even switched off completely by
     
    6277               undulations instead of real lines.
    6378        """
    64         self.finder.setoptions(threshold,min_nchan,avg_limit,box_size)
     79        if noise_stat.lower() not in ["mean80",'median']:
     80           raise RuntimeError, "noise_stat argument in linefinder.set_options can only be mean80 or median"
     81        nStat = (noise_stat.lower() == "median")
     82        nBox = -1.
     83        if isinstance(noise_box,str):
     84           if noise_box.lower() not in ['all','box']:
     85              raise RuntimeError, "string-valued noise_box in linefinder.set_options can only be all or box"
     86           if noise_box.lower() == 'box':
     87              nBox = box_size
     88        else:
     89           nBox = float(noise_box)
     90        self.finder.setoptions(threshold,min_nchan,avg_limit,box_size,nBox,nStat)
    6591        return
    6692
Note: See TracChangeset for help on using the changeset viewer.