source: tags/release-0.9.2/Detection/detection.hh @ 1323

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

Added code to produce warning flags for detections: for either edge location
or negative enclosed flux. Summary of changes:
Cubes/cubes.cc -- three new routines
Cubes/cubes.hh -- prototypes for new routines. New isBlank functions.
Detection/outputDetection.cc -- output of warning flags.
mainDuchamp.cc -- calling of new routines. Other minor changes.
docs/Guide.tex -- explanation of new warning flags. Other minor changes.
docs/example_spectrum.pdf -- shows the new formatting.
docs/example_spectrum.ps -- ditto
InputComplete? -- all values are now the same as the default param values

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