Ignore:
Timestamp:
10/04/16 18:20:50 (8 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes/No?

Interface Changes: Yes/No?

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...


Check-in asap modifications from Jim regarding casacore namespace conversion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STLineFinder.cpp

    r3086 r3106  
    4242
    4343using namespace asap;
    44 using namespace casa;
     44using namespace casacore;
    4545using namespace std;
    4646
     
    5757   // The input data to work with. Use reference symantics to avoid
    5858   // an unnecessary copying
    59    const casa::Vector<casa::Float>  &spectrum; // a buffer for the spectrum
    60    const casa::Vector<casa::Bool>   &mask; // associated mask
     59   const casacore::Vector<casacore::Float>  &spectrum; // a buffer for the spectrum
     60   const casacore::Vector<casacore::Bool>   &mask; // associated mask
    6161   const std::pair<int,int>         &edge; // start and stop+1 channels
    6262                                           // to work with
    6363
    6464   // statistics for running box filtering
    65    casa::Float sumf;       // sum of fluxes
    66    casa::Float sumf2;     // sum of squares of fluxes
    67    casa::Float sumch;       // sum of channel numbers (for linear fit)
    68    casa::Float sumch2;     // sum of squares of channel numbers (for linear fit)
    69    casa::Float sumfch;     // sum of flux*(channel number) (for linear fit)
     65   casacore::Float sumf;       // sum of fluxes
     66   casacore::Float sumf2;     // sum of squares of fluxes
     67   casacore::Float sumch;       // sum of channel numbers (for linear fit)
     68   casacore::Float sumch2;     // sum of squares of channel numbers (for linear fit)
     69   casacore::Float sumfch;     // sum of flux*(channel number) (for linear fit)
    7070
    7171   int box_chan_cntr;     // actual number of channels in the box
     
    7373                          // (calculated from boxsize and actual spectrum size)
    7474   // cache for derivative statistics
    75    mutable casa::Bool need2recalculate; // if true, values of the statistics
     75   mutable casacore::Bool need2recalculate; // if true, values of the statistics
    7676                                       // below are invalid
    77    mutable casa::Float linmean;  // a value of the linear fit to the
     77   mutable casacore::Float linmean;  // a value of the linear fit to the
    7878                                 // points in the running box
    79    mutable casa::Float linvariance; // the same for variance
     79   mutable casacore::Float linvariance; // the same for variance
    8080   int cur_channel;       // the number of the current channel
    8181   int start_advance;     // number of channel from which the box can
     
    8585   // set up the object with the references to actual data
    8686   // as well as the number of channels in the running box
    87    RunningBox(const casa::Vector<casa::Float>  &in_spectrum,
    88                  const casa::Vector<casa::Bool>   &in_mask,
     87   RunningBox(const casacore::Vector<casacore::Float>  &in_spectrum,
     88                 const casacore::Vector<casacore::Bool>   &in_mask,
    8989                 const std::pair<int,int>         &in_edge,
    9090                 int in_max_box_nchan);
    9191
    9292   // access to the statistics
    93    const casa::Float& getLinMean() const;
    94    const casa::Float& getLinVariance() const;
    95    casa::Float aboveMean() const;
     93   const casacore::Float& getLinMean() const;
     94   const casacore::Float& getLinVariance() const;
     95   casacore::Float aboveMean() const;
    9696   int getChannel() const;
    9797
     
    104104
    105105   // checking whether there are still elements
    106    casa::Bool haveMore() const;
     106   casacore::Bool haveMore() const;
    107107
    108108   // go to start
     
    136136   // was detected in the previous channels.
    137137   std::pair<int,int> cur_line;
    138    casa::Bool is_detected_before;
     138   casacore::Bool is_detected_before;
    139139   int  min_nchan;                         // A minimum number of consequtive
    140140                                           // channels, which should satisfy
    141141                                           // the detection criterion, to be
    142142                                           // a detection
    143    casa::Float threshold;                  // detection threshold - the
     143   casacore::Float threshold;                  // detection threshold - the
    144144                                           // minimal signal to noise ratio
    145145   std::list<pair<int,int> > &lines;       // list where detections are saved
    146146                                           // (pair: start and stop+1 channel)
    147147   RunningBox *running_box;                // running box filter
    148    casa::Vector<Int> signs;                // An array to store the signs of
     148   casacore::Vector<Int> signs;                // An array to store the signs of
    149149                                           // the value - current mean
    150150                                           // (used to search wings)
    151    casa::Int last_sign;                    // a sign (+1, -1 or 0) of the
     151   casacore::Int last_sign;                    // a sign (+1, -1 or 0) of the
    152152                                           // last point of the detected line
    153153                                           //
     
    163163   LFAboveThreshold(std::list<pair<int,int> > &in_lines,
    164164                    int in_min_nchan = 3,
    165                     casa::Float in_threshold = 5,
     165                    casacore::Float in_threshold = 5,
    166166                    bool use_median = false,
    167167                    int noise_sample_size = -1);
     
    169169
    170170   // replace the detection criterion
    171    void setCriterion(int in_min_nchan, casa::Float in_threshold);
     171   void setCriterion(int in_min_nchan, casacore::Float in_threshold);
    172172
    173173   // return the array with signs of the value-current mean
     
    175175   // This array is updated each time the findLines method is called and
    176176   // is used to search the line wings
    177    const casa::Vector<Int>& getSigns() const;
     177   const casacore::Vector<Int>& getSigns() const;
    178178
    179179   // find spectral lines and add them into list
     
    182182   //    spectrum, mask and edge - reference to the data
    183183   //    max_box_nchan  - number of channels in the running box
    184    void findLines(const casa::Vector<casa::Float> &spectrum,
    185                   const casa::Vector<casa::Bool> &mask,
     184   void findLines(const casacore::Vector<casacore::Float> &spectrum,
     185                  const casacore::Vector<casacore::Bool> &mask,
    186186                  const std::pair<int,int> &edge,
    187187                  int max_box_nchan);
     
    192192   // add a new line to the list, if necessary using processCurLine()
    193193   // detect=true indicates that the current channel satisfies the criterion
    194    void processChannel(Bool detect, const casa::Vector<casa::Bool> &mask);
     194   void processChannel(Bool detect, const casacore::Vector<casacore::Bool> &mask);
    195195
    196196   // process the interval of channels stored in curline
    197197   // if it satisfies the criterion, add this interval as a new line
    198    void processCurLine(const casa::Vector<casa::Bool> &mask);
     198   void processCurLine(const casacore::Vector<casacore::Bool> &mask);
    199199
    200200   // get the sign of runningBox->aboveMean(). The RunningBox pointer
    201201   // should be defined
    202    casa::Int getAboveMeanSign() const;
     202   casacore::Int getAboveMeanSign() const;
    203203};
    204204
     
    457457// set up the object with the references to actual data
    458458// and the number of channels in the running box
    459 RunningBox::RunningBox(const casa::Vector<casa::Float>  &in_spectrum,
    460                        const casa::Vector<casa::Bool>   &in_mask,
     459RunningBox::RunningBox(const casacore::Vector<casacore::Float>  &in_spectrum,
     460                       const casacore::Vector<casacore::Bool>   &in_mask,
    461461                       const std::pair<int,int>         &in_edge,
    462462                       int in_max_box_nchan) :
     
    488488
    489489// access to the statistics
    490 const casa::Float& RunningBox::getLinMean() const
     490const casacore::Float& RunningBox::getLinMean() const
    491491{
    492492  DebugAssert(cur_channel<edge.second, AipsError);
     
    495495}
    496496
    497 const casa::Float& RunningBox::getLinVariance() const
     497const casacore::Float& RunningBox::getLinVariance() const
    498498{
    499499  DebugAssert(cur_channel<edge.second, AipsError);
     
    502502}
    503503
    504 casa::Float RunningBox::aboveMean() const
     504casacore::Float RunningBox::aboveMean() const
    505505{
    506506  DebugAssert(cur_channel<edge.second, AipsError);
     
    561561
    562562// checking whether there are still elements
    563 casa::Bool RunningBox::haveMore() const
     563casacore::Bool RunningBox::haveMore() const
    564564{
    565565   return cur_channel<edge.second;
     
    611611LFAboveThreshold::LFAboveThreshold(std::list<pair<int,int> > &in_lines,
    612612                                   int in_min_nchan,
    613                                    casa::Float in_threshold,
     613                                   casacore::Float in_threshold,
    614614                                   bool use_median,
    615615                                   int noise_sample_size) :
     
    624624
    625625// replace the detection criterion
    626 void LFAboveThreshold::setCriterion(int in_min_nchan, casa::Float in_threshold)
     626void LFAboveThreshold::setCriterion(int in_min_nchan, casacore::Float in_threshold)
    627627{
    628628  min_nchan=in_min_nchan;
     
    632632// get the sign of runningBox->aboveMean(). The RunningBox pointer
    633633// should be defined
    634 casa::Int LFAboveThreshold::getAboveMeanSign() const
     634casacore::Int LFAboveThreshold::getAboveMeanSign() const
    635635{
    636636  const Float buf=running_box->aboveMean();
     
    644644// add a new line to the list, if necessary
    645645void LFAboveThreshold::processChannel(Bool detect,
    646                  const casa::Vector<casa::Bool> &mask)
     646                 const casacore::Vector<casacore::Bool> &mask)
    647647{
    648648  try {
     
    675675// process the interval of channels stored in cur_line
    676676// if it satisfies the criterion, add this interval as a new line
    677 void LFAboveThreshold::processCurLine(const casa::Vector<casa::Bool> &mask)
     677void LFAboveThreshold::processCurLine(const casacore::Vector<casacore::Bool> &mask)
    678678{
    679679  try {
     
    709709// This array is updated each time the findLines method is called and
    710710// is used to search the line wings
    711 const casa::Vector<Int>& LFAboveThreshold::getSigns() const
     711const casacore::Vector<Int>& LFAboveThreshold::getSigns() const
    712712{
    713713  return signs;
     
    715715
    716716// find spectral lines and add them into list
    717 void LFAboveThreshold::findLines(const casa::Vector<casa::Float> &spectrum,
    718                               const casa::Vector<casa::Bool> &mask,
     717void LFAboveThreshold::findLines(const casacore::Vector<casacore::Float> &spectrum,
     718                              const casacore::Vector<casacore::Bool> &mask,
    719719                              const std::pair<int,int> &edge,
    720720                              int max_box_nchan)
     
    905905// in_median    true if median statistics is used as opposed to average of
    906906//              the lowest 80% of deviations (default)
    907 void STLineFinder::setOptions(const casa::Float &in_threshold,
    908                               const casa::Int &in_min_nchan,
    909                               const casa::Int &in_avg_limit,
    910                               const casa::Float &in_box_size,
    911                               const casa::Float &in_noise_box,
    912                               const casa::Bool &in_median)
     907void STLineFinder::setOptions(const casacore::Float &in_threshold,
     908                              const casacore::Int &in_min_nchan,
     909                              const casacore::Int &in_avg_limit,
     910                              const casacore::Float &in_box_size,
     911                              const casacore::Float &in_noise_box,
     912                              const casacore::Bool &in_median)
    913913{
    914914  threshold=in_threshold;
     
    949949int STLineFinder::findLines(const std::vector<bool> &in_mask,
    950950                            const std::vector<int> &in_edge,
    951                             const casa::uInt &whichRow)
     951                            const casacore::uInt &whichRow)
    952952{
    953953  if (useScantable && scan.null())
     
    10961096// spectrum. It uses the Fitter class. This action is required before
    10971097// reducing the spectral resolution if the baseline shape is bad
    1098 void STLineFinder::subtractBaseline(const casa::Vector<casa::Bool> &temp_mask,
    1099                       const casa::Int &order)
     1098void STLineFinder::subtractBaseline(const casacore::Vector<casacore::Bool> &temp_mask,
     1099                      const casacore::Int &order)
    11001100{
    11011101  AlwaysAssert(spectrum.nelements(),AipsError);
     
    11121112  sdf.setExpression("poly",order);
    11131113  if (!sdf.lfit()) return; // fit failed, use old spectrum
    1114   spectrum=casa::Vector<casa::Float>(sdf.getResidual());
     1114  spectrum=casacore::Vector<casacore::Float>(sdf.getResidual());
    11151115}
    11161116
     
    11211121// array specified, rather than the field of this class
    11221122// boxsize - a number of adjacent channels to average
    1123 void STLineFinder::averageAdjacentChannels(casa::Vector<casa::Bool> &mask2update,
    1124                                    const casa::Int &boxsize)
     1123void STLineFinder::averageAdjacentChannels(casacore::Vector<casacore::Bool> &mask2update,
     1124                                   const casacore::Int &boxsize)
    11251125{
    11261126  DebugAssert(mask2update.nelements()==spectrum.nelements(), AipsError);
     
    12661266//                 nothing will be done if it is empty
    12671267// max_box_nchan - channels in the running box for baseline filtering
    1268 void STLineFinder::keepStrongestOnly(const casa::Vector<casa::Bool> &temp_mask,
     1268void STLineFinder::keepStrongestOnly(const casacore::Vector<casacore::Bool> &temp_mask,
    12691269                  std::list<std::pair<int, int> > &lines2update,
    12701270                  int max_box_nchan)
     
    13711371// merged together. Any masked channel stops the extension
    13721372void LFLineListOperations::searchForWings(std::list<std::pair<int, int> > &newlines,
    1373            const casa::Vector<casa::Int> &signs,
    1374            const casa::Vector<casa::Bool> &mask,
     1373           const casacore::Vector<casacore::Int> &signs,
     1374           const casacore::Vector<casacore::Bool> &mask,
    13751375           const std::pair<int,int> &edge)
    13761376{
Note: See TracChangeset for help on using the changeset viewer.