casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
Public Member Functions | Private Member Functions | Private Attributes
asap.simplelinefinder.simplelinefinder Class Reference

List of all members.

Public Member Functions

def __init__
def writeLog
def invertChannelSelection
def channelRange
def rms
def median
def find_lines

Private Member Functions

def _absvalComp
def _mergeIntervals
def _splitIntervals

Private Attributes

 _median
 _rms

Detailed Description

    A simplified class to search for spectral features. The algorithm assumes that the bandpass
    is taken out perfectly and no spectral channels are flagged (except some edge channels).
    It works with a list or tuple rather than a scantable and returns the channel pairs.
    There is an optional feature to attempt to split the detected lines into components, although
    it should be used with caution. This class is largely intended to be used with scripts.

    The fully featured version of the algorithm working with scantables is called linefinder.

Definition at line 34 of file simplelinefinder.py.


Constructor & Destructor Documentation

   Initialize the class.

Definition at line 45 of file simplelinefinder.py.


Member Function Documentation

def asap.simplelinefinder.simplelinefinder._absvalComp (   self,
  x,
  y 
) [private]
   A helper method to compare x and y by absolute value (to do sorting)

   x - first value
   y - second value

   return -1,0 or 1 depending on the result of comparison

Definition at line 144 of file simplelinefinder.py.

Referenced by asap.simplelinefinder.simplelinefinder.find_lines().

def asap.simplelinefinder.simplelinefinder._mergeIntervals (   self,
  lines,
  spc 
) [private]
   A helper method to merge intervals.

   lines - list of tuples with first and last channels of all intervals
   spc - spectrum (to be able to test whether adjacent intervals have the
   same sign.

Definition at line 179 of file simplelinefinder.py.

References asap.simplelinefinder.simplelinefinder._median.

Referenced by asap.simplelinefinder.simplelinefinder.find_lines().

def asap.simplelinefinder.simplelinefinder._splitIntervals (   self,
  lines,
  spc,
  threshold = 3,
  minchan = 3 
) [private]
   A helper method used in the spectral line detection routine. It splits given intervals
   into a number of "spectral lines". Each line is characterised by a single extremum.
   Noise is dealt with by taking into account only those extrema, where a difference with
   respect to surrounding spectral points exceeds threshold times rms (stored inside this
   class, so the main body of the line detection should be executed first) and there are
   at least minchan such points.

Definition at line 199 of file simplelinefinder.py.

References asap.simplelinefinder.simplelinefinder.writeLog().

Referenced by asap.simplelinefinder.simplelinefinder.find_lines().

def asap.simplelinefinder.simplelinefinder.channelRange (   self,
  spc,
  vel_range 
)
   A helper method which works on a tuple with abcissa/flux vectors (i.e. as returned by uvSpectrum). It
   allows to convert supplied velocity range into the channel range.

   spc - tuple with the spectrum (first is the vector of abcissa values, second is the spectrum itself)
   vel_range - a 2-element tuple with start and stop velocity of the range

   return: a 2-element tuple with channels
   Note, if supplied range is completely outside the spectrum, an empty tuple will be returned

Definition at line 101 of file simplelinefinder.py.

References tests.test_imcontsub.list, and irc_cs_task_regression.max.

def asap.simplelinefinder.simplelinefinder.find_lines (   self,
  spc,
  threshold = 3,
  edge = 0,
  minchan = 3,
  tailsearch = True,
  splitFeatures = False 
)
   A simple spectral line detection routine, which assumes that bandpass has been
   taken out perfectly and no channels are flagged within the spectrum. A detection
   is reported if consequtive minchan number of channels is consistently above or
   below the median value. The threshold is given in terms of the rms calculated
   using 80% of the lowest data points by the absolute value (with respect to median)

   spc - a list or tuple with the spectrum, no default
   threshold - detection threshold, default is 3 sigma, see above for the definition
   edge - if non-zero, this number of spectral channels will be rejected at the edge.
    Default is not to do any rejection.
   minchan -  minimum number of consequitive channels exceeding threshold to claim the
        detection, default is 3.
   tailsearch - if True (default), the algorithm attempts to widen each line until
        its flux crosses the median. It merges lines if necessary. Set this
        option off if you need to split the lines according to some criterion
   splitFeatures - if True, the algorithm attempts to split each detected spectral feature into
        a number of spectral lines (just one local extremum). The default action is
        not to do it (may give an adverse results if the noise is high)

   This method returns a list of tuples each containing start and stop 0-based channel
   number of every detected line. Empty list if nothing has been detected.

   Note. The median and rms about this median is stored inside this class and can
   be obtained with rms and median methods.

Definition at line 240 of file simplelinefinder.py.

References asap.simplelinefinder.simplelinefinder._absvalComp(), asap.simplelinefinder.simplelinefinder._median, asap.simplelinefinder.simplelinefinder._mergeIntervals(), asap.simplelinefinder.simplelinefinder._rms, asap.simplelinefinder.simplelinefinder._splitIntervals(), tests.test_imcontsub.list, and asap.simplelinefinder.simplelinefinder.writeLog().

def asap.simplelinefinder.simplelinefinder.invertChannelSelection (   self,
  nchan,
  chans,
  edge = (0,0 
)
   This method converts a tuple with channel ranges to a tuple which covers all channels
   not selected by the original tuple (optionally edge channels can be discarded)

   nchan - number of channels in the spectrum.
   chans - tuple (with even number of elements) containing start and stop channel for all selected ranges
   edge - one number or two element tuple (separate values for two ends) defining how many channels to reject

   return:  a tuple with inverted channel selection
   Note, at this stage channel ranges are assumed to be sorted and without overlap

Definition at line 58 of file simplelinefinder.py.

   Return the median of the last spectrum passed to find_lines.
   Note, this method throws an exception if find_lines has never been called.

Definition at line 170 of file simplelinefinder.py.

References asap.simplelinefinder.simplelinefinder._median.

   Return rms scatter of the spectral points (with respect to the median) calculated
   during last find_lines call. Note, this method throws an exception if
   find_lines has never been called.

Definition at line 160 of file simplelinefinder.py.

References asap.simplelinefinder.simplelinefinder._rms.

   Write user defined string into log file

Definition at line 52 of file simplelinefinder.py.

Referenced by asap.simplelinefinder.simplelinefinder._splitIntervals(), and asap.simplelinefinder.simplelinefinder.find_lines().


Member Data Documentation


The documentation for this class was generated from the following file: