source: trunk/Detection/detection.hh @ 20

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

Added a function to write a Karma annotation file. Needed new parameters and
function declaration, and added comments in the Guide as well.
Guide also had VOTable and results examples updated.

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