source: tags/release-1.0.5/src/Detection/detection.hh @ 1455

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

Made changes to the way the columns are dealt with. Now much more resilient
towards low values (eg of flux -- if much below 1 it will change the width
and precision so that enough significant figures are shown).
These changes are also propagated through to the information in the spectral
plots.
The ColSet? class was removed and replaced with a more simple vector<Col>.

File size: 10.6 KB
Line 
1#ifndef DETECTION_H
2#define DETECTION_H
3
4#include <iostream>
5#include <string>
6#include <vector>
7#include <param.hh>
8#ifndef COLUMNS_H
9#include <Detection/columns.hh>
10#endif
11#include <Utils/utils.hh>
12
13using std::string;
14using std::vector;
15using namespace Column;
16
17/**
18 * Voxel class
19 *  A 3-dimensional pixel, with x,y,z position + flux
20 */
21
22class Voxel
23{
24public:
25  Voxel(){};
26  Voxel(long x, long y, long z, float f){ itsX=x; itsY=y; itsZ=z; itsF=f;};
27  virtual ~Voxel(){};
28  friend class Detection;
29  // accessor functions
30  void   setX(long x){itsX = x;};
31  void   setY(long y){itsY = y;};
32  void   setZ(long z){itsZ = z;};
33  void   setF(float f){itsF = f;};
34  void   setXY(long x, long y){itsX = x; itsY = y;};
35  void   setXYZ(long x, long y, long z){itsX = x; itsY = y; itsZ = z;};
36  void   setXYF(long x, long y, float f){itsX = x; itsY = y; itsF = f;};
37  void   setXYZF(long x, long y, long z, float f){itsX = x; itsY = y; itsZ = z; itsF = f;};
38  long   getX(){return itsX;};
39  long   getY(){return itsY;};
40  long   getZ(){return itsZ;};
41  float  getF(){return itsF;};
42  //
43  friend std::ostream& operator<< ( std::ostream& theStream, Voxel& vox);
44  //
45protected:
46  long  itsX;         // x-position of pixel
47  long  itsY;         // y-position of pixel
48  long  itsZ;         // z-position of pixel
49  float itsF;         // flux of pixel
50};
51
52/**
53 * Pixel class
54 *  A 2-dimensional type of voxel, with just x & y position + flux
55 */
56
57
58class Pixel : public Voxel
59{
60public:
61  Pixel(){itsZ=0;};
62  Pixel(long x, long y, float f){ itsX=x; itsY=y; itsF=f; itsZ=0;};
63  virtual ~Pixel(){};
64  // accessor functions
65  void  setXY(long x, long y){itsX = x; itsY = y;};
66  void  setXYF(long x, long y, float f){itsX = x; itsY = y; itsF = f;};
67
68};
69
70/**
71 * Detection class
72 *  A detected object, featuring:
73 *   a vector of voxels, centroid positions, total & peak fluxes
74 *   the possibility of WCS-calculated parameters (RA, Dec, velocity) etc.
75 */
76
77class Detection
78{
79public:
80  Detection(){flagWCS=false; negativeSource = false; flagText="";};
81  Detection(long numPix){vector <Voxel> pix(numPix); flagWCS = false; negativeSource = false;};
82  virtual ~Detection(){};
83
84  void   addPixel(Voxel point){pix.push_back(point);};
85  Voxel  getPixel(long pixNum){return pix[pixNum];};
86  int    getSize(){return pix.size();};
87  int    getSpatialSize();// in detection.cc
88  //
89  long   getX(long pixCount){return pix[pixCount].getX();};
90  void   setX(long pixCount, long x){pix[pixCount].setX(x);};
91  long   getY(long pixCount){return pix[pixCount].getY();};
92  void   setY(long pixCount, long y){pix[pixCount].setY(y);};
93  long   getZ(long pixCount){return pix[pixCount].getZ();};
94  void   setZ(long pixCount, long z){pix[pixCount].setZ(z);};
95  float  getF(long pixCount){return pix[pixCount].getF();};
96  void   setF(long pixCount, float f){pix[pixCount].setF(f);};
97  //
98  long   getXOffset(){return xSubOffset;};
99  void   setXOffset(long o){xSubOffset = o;};
100  long   getYOffset(){return ySubOffset;};
101  void   setYOffset(long o){ySubOffset = o;};
102  long   getZOffset(){return zSubOffset;};
103  void   setZOffset(long o){zSubOffset = o;};
104  //
105  float  getXcentre(){return xcentre;};
106  void   setXcentre(float x){xcentre = x;};
107  float  getYcentre(){return ycentre;};
108  void   setYcentre(float y){ycentre = y;};
109  float  getZcentre(){return zcentre;};
110  void   setCentre(float x, float y){xcentre = x; ycentre = y;};
111  float  getTotalFlux(){return totalFlux;};
112  void   setTotalFlux(float f){totalFlux = f;};
113  float  getIntegFlux(){return intFlux;};
114  void   setIntegFlux(float f){intFlux = f;};
115  float  getPeakFlux(){return peakFlux;};
116  void   setPeakFlux(float f){peakFlux = f;};
117  long   getXPeak(){return xpeak;};
118  void   setXPeak(long x){xpeak = x;};
119  long   getYPeak(){return ypeak;};
120  void   setYPeak(long y){ypeak = y;};
121  long   getZPeak(){return zpeak;};
122  void   setZPeak(long z){zpeak = z;};
123  bool   isNegative(){return negativeSource;};
124  void   setNegative(bool f){negativeSource = f;};
125  string getFlagText(){return flagText;};
126  void   setFlagText(string s){flagText = s;};
127  void   addToFlagText(string s){flagText += s;};
128  //
129  long   getXmin(){return xmin;};
130  long   getYmin(){return ymin;};
131  long   getZmin(){return zmin;};
132  long   getXmax(){return xmax;};
133  long   getYmax(){return ymax;};
134  long   getZmax(){return zmax;};
135  //
136  bool   isWCS(){return flagWCS;};
137  string getName(){return name;};
138  void   setName(string s){name = s;};
139  string getRAs(){return raS;};
140  void   setRAs(string s){raS = s;};
141  string getDecs(){return decS;};
142  void   setDecs(string s){decS = s;};
143  float  getRA(){return ra;};
144  void   setRA(float f){ra = f;};
145  float  getDec(){return dec;};
146  void   setDec(float f){dec = f;};
147  float  getRAWidth(){return raWidth;};
148  void   setRAWidth(float f){raWidth = f;};
149  float  getDecWidth(){return decWidth;};
150  void   setDecWidth(float f){decWidth = f;};
151//   string getLNGtype(){return lngtype;};
152//   void   setLNGtype(string s){lngtype = s;};
153//   string getLATtype(){return lattype;};
154//   void   setLATtype(string s){lattype = s;};
155//   string getZtype(){return ztype;};
156//   void   setZtype(string s){ztype = s;};
157//   float  getNuRest(){return nuRest;};
158//   void   setNuRest(float f){nuRest = f;};
159  float  getVel(){return vel;};
160  void   setVel(float f){vel = f;};
161  float  getVelWidth(){return velWidth;};
162  void   setVelWidth(float f){velWidth = f;};
163  float  getVelMin(){return velMin;};
164  void   setVelMin(float f){velMin = f;};
165  float  getVelMax(){return velMax;};
166  void   setVelMax(float f){velMax = f;};
167  int    getID(){return id;};
168  void   setID(int i){id = i;};
169  //
170  int    getPosPrec(){return posPrec;};
171  void   setPosPrec(int i){posPrec=i;};
172  int    getXYZPrec(){return xyzPrec;};
173  void   setXYZPrec(int i){xyzPrec=i;};
174  int    getFintPrec(){return fintPrec;};
175  void   setFintPrec(int i){fintPrec=i;};
176  int    getFpeakPrec(){return fpeakPrec;};
177  void   setFpeakPrec(int i){fpeakPrec=i;};
178  int    getVelPrec(){return velPrec;};
179  void   setVelPrec(int i){velPrec=i;};
180  //
181  void   addAnObject(Detection &toAdd);
182  void   calcWCSparams(FitsHeader &head);
183  float  getIntegFlux(FitsHeader &head);
184  void   calcParams();
185  void   clearDetection(){this->pix.clear();};
186  void   addOffsets(Param &par);
187  void   SortByZ();   // in Detection/sorting.cc
188  bool   hasEnoughChannels(int minNumber);
189  // Text Output -- all in Detection/outputDetection.cc
190  string outputLabelWCS();
191  string outputLabelPix();
192  string outputLabelInfo();
193  void   outputDetectionTextHeader(std::ostream &stream, vector<Col> columns);
194  void   outputDetectionTextWCS(std::ostream &stream, vector<Col> columns);
195  void   outputDetectionText(std::ostream &stream, vector<Col> columns, int idNumber);
196  // For plotting routines...
197  void   drawBorders(int xoffset, int yoffset);  // in Cubes/drawMomentCutout.cc
198  //
199  friend std::ostream& operator<< ( std::ostream& theStream, Detection& obj);
200  //
201private:
202  vector <Voxel> pix;         // array of pixels
203  float          xcentre;     // x-value of centre pixel of object
204  float          ycentre;     // y-value of centre pixel of object
205  float          zcentre;     // z-value of centre pixel of object
206  long           xmin,xmax;   // min and max x-values of object
207  long           ymin,ymax;   // min and max y-values of object
208  long           zmin,zmax;   // min and max z-values of object
209  // Subsection offsets
210  long           xSubOffset;  // The offset in the x-direction from the subsectioned cube
211  long           ySubOffset;  // The offset in the y-direction from the subsectioned cube
212  long           zSubOffset;  // The offset in the z-direction from the subsectioned cube
213  // Flux related
214  float          totalFlux;   // sum of the fluxes of all the pixels
215  float          intFlux;     // integrated flux --> involves integration over velocity.
216  float          peakFlux;    // maximum flux over all the pixels
217  long           xpeak,ypeak,zpeak; // location of peak flux
218  bool           negativeSource; // is the source defined as a negative feature?
219  string         flagText;    // any warning flags about the quality of the detection.
220  // WCS related
221  int            id;          // ID -- generally number in list
222  string         name;        // IAU-style name (based on position)
223  bool           flagWCS;     // A flag indicating whether the WCS parameters have been set.
224  string         raS;         // Central Right Ascension (or Longitude) in form 12:34:23
225  string         decS;        // Central Declination(or Latitude), in form -12:23:34
226  float          ra;          // Central Right Ascension in degrees
227  float          dec;         // Central Declination in degrees
228  float          raWidth;     // Width of detection in RA direction in arcmin
229  float          decWidth;    // Width of detection in Dec direction in arcmin
230  string         specUnits;   // Units of the spectral dimension
231  string         fluxUnits;   // Units of flux
232  string         intFluxUnits;// Units of integrated flux
233  string         lngtype;     // Type of longitude axis (RA/GLON)
234  string         lattype;     // Type of latitude axis (DEC/GLAT)
235//   string         ztype;            // Type of z-axis (FREQ/VEL/...)
236//   float          nuRest;      // Rest frequency
237  float          vel;         // Central velocity (from zCentre)
238  float          velWidth;    // Full velocity width
239  float          velMin;      // Minimum velocity
240  float          velMax;      // Maximum velocity
241  //  The next four are the precision of values printed in the spectral plots
242  int            posPrec;     // Precision of WCS positional values
243  int            xyzPrec;     // Precision of pixel positional values
244  int            fintPrec;    // Precision of F_int/F_tot values
245  int            fpeakPrec;   // Precision of F_peak values
246  int            velPrec;     // Precision of velocity values.
247
248};
249
250/****************************************************************/
251//////////////////////////////////////////////////////
252// Prototypes for functions that use above classes
253//////////////////////////////////////////////////////
254
255void SortByZ(vector <Detection> &inputList);
256void SortByVel(vector <Detection> &inputList);
257Detection combineObjects(Detection &first, Detection &second);
258vector <Detection> combineLists(vector <Detection> &first, vector <Detection> &second);
259
260bool areClose(Detection &object1, Detection &object2, Param &par);
261void mergeIntoList(Detection &object, vector <Detection> &objList, Param &par);
262void mergeList(vector<Detection> &objList, Param &par);     //in Cubes/Merger.cc
263void finaliseList(vector<Detection> &objList, Param &par);  //in Cubes/Merger.cc
264void ObjectMerger(vector<Detection> &objList, Param &par);  //in Cubes/Merger.cc
265
266// A GENERIC DETECTION TEST  -- in thresholding_functions.cc
267bool isDetection(float value, float mean, float sigma, float cut);
268
269#endif
Note: See TracBrowser for help on using the repository browser.