source: trunk/src/Detection/spectrumDetect.cc @ 167

Last change on this file since 167 was 137, checked in by Matthew Whiting, 18 years ago

Again, a large number of changes to commit:
Cubes/cubes.cc -- added destructors for DataArray?, Image and Cube.

fixed typo in Image::saveArray.

Cubes/cubes.hh -- destructors changed.
Cubes/drawMomentCutout.cc -- Added call to drawBlankEdges, which required

changing how the image array was set up. Now make
use of an isGood array.

Cubes/Merger?.cc -- made new functions mergeList and finaliseList that do a lot

of the work, acting just on the Detection vector.
Cube::Merger() now is mostly a front-end to these primitive
functions.

Cubes/ReadAndSearch?.cc -- new function that reads in FITS array piecemeal and

searches in each piece. For large files that are too
big to read in all at once.

param.cc -- added an explicit copy constructor to Param class.
Detection/spectrumDetect.cc -- fixed typos (pix. instead of pix->)
Detection/outputDetection.cc -- added test to outputDetectionText for number

of columns in ColSet?

Detection/columns.cc -- added push_back statements that had been left out.
Detection/detection.hh -- added prototypes for new merging functions
param.hh -- prototype for copy constructor of Param.

File size: 2.0 KB
Line 
1/**
2 *  spectrumDetect.cc
3 *
4 * A detection algorithm that searches in a single 1-D spectrum.
5 *
6 * INPUTS:
7 *    image     -- an Image object, containing a 1-D image that has been
8 *                 processed such that its pValue array is defined.
9 * OUTPUTS:
10 *   The detection and mask arrays in image will be filled, according to
11 *   the location of the objects in the image.
12 *
13 */
14
15#include <Cubes/cubes.hh>
16#include <vector>
17
18enum STATUS { NONOBJECT, OBJECT };
19
20void Image::spectrumDetect()
21{
22  STATUS status;
23//   vector <Detection> *obj = new vector <Detection>;
24  Detection *obj = new Detection;
25  Pixel *pix = new Pixel;
26  bool isObject;
27
28  status = NONOBJECT;
29  for(int pos=0;pos<(this->axisDim[0]+1);pos++){
30
31//     isObject=false;
32//     if(pos<this->axisDim[0]){
33//       pix->setXYF(pos, 0, this->array[pos] );
34//       isObject = this->isDetection(pos,0);
35//     }
36
37//     if(isObject){
38//       if(status != OBJECT){
39//      status = OBJECT;
40//      obj->resize(obj->size()+1);
41//       }
42//       obj->back().addPixel(*pix);
43//     }
44//     else if(obj->size()>0){
45//       if(obj->back().getSize() >= this->minSize){ // is it big enough?
46//      obj->back().calcParams(); // work out midpoints, fluxes etc
47//      this->addObject(obj->back());  // add to list.
48//      this->maskObject(obj->back());
49//       }
50//       obj->pop_back();
51//       status = NONOBJECT;
52//     }
53
54    ////////////////////////////////////////////////////
55
56
57    isObject=false;
58    if(pos<this->axisDim[0]){
59      pix->setXYF(pos, 0, this->array[pos] );
60      isObject = this->isDetection(pos,0);
61    }
62
63    if(isObject){
64      if(status != OBJECT){
65        status = OBJECT;
66      }
67      obj->addPixel(*pix);
68    }
69    else{
70      if(status == OBJECT){ // if we were on an object and have left
71        if(obj->getSize() >= this->minSize){ // if it's big enough
72          obj->calcParams(); // work out midpoints, fluxes etc
73          this->addObject(*obj);  // add to list.
74          this->maskObject(*obj);
75        }
76        obj->clearDetection();
77      }
78      status = NONOBJECT;
79    }
80
81
82  }
83
84  // clean up and remove declared arrays
85  delete obj,pix;
86}
Note: See TracBrowser for help on using the repository browser.