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 | |
---|
11 | using std::string; |
---|
12 | using std::vector; |
---|
13 | //using std::ostream; |
---|
14 | |
---|
15 | /** |
---|
16 | * Voxel class |
---|
17 | * A 3-dimensional pixel, with x,y,z position + flux |
---|
18 | */ |
---|
19 | |
---|
20 | class Voxel |
---|
21 | { |
---|
22 | public: |
---|
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 | // |
---|
43 | protected: |
---|
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 | |
---|
56 | class Pixel : public Voxel |
---|
57 | { |
---|
58 | public: |
---|
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 | |
---|
75 | class Detection |
---|
76 | { |
---|
77 | public: |
---|
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 | string getLNGtype(){return lngtype;}; |
---|
139 | void setLNGtype(string s){lngtype = s;}; |
---|
140 | string getLATtype(){return lattype;}; |
---|
141 | void setLATtype(string s){lattype = s;}; |
---|
142 | string getZtype(){return ztype;}; |
---|
143 | void setZtype(string s){ztype = s;}; |
---|
144 | float getNuRest(){return nuRest;}; |
---|
145 | void setNuRest(float f){nuRest = f;}; |
---|
146 | float getVel(){return vel;}; |
---|
147 | void setVel(float f){vel = f;}; |
---|
148 | float getVelWidth(){return velWidth;}; |
---|
149 | void setVelWidth(float f){velWidth = f;}; |
---|
150 | float getVelMin(){return velMin;}; |
---|
151 | void setVelMin(float f){velMin = f;}; |
---|
152 | float getVelMax(){return velMax;}; |
---|
153 | void setVelMax(float f){velMax = f;}; |
---|
154 | int getID(){return id;}; |
---|
155 | void setID(int i){id = i;}; |
---|
156 | // |
---|
157 | void addAnObject(Detection &toAdd); |
---|
158 | void calcWCSparams(wcsprm *wcs); |
---|
159 | float getIntegFlux(wcsprm *wcs); |
---|
160 | void calcParams(); |
---|
161 | void clearDetection(){this->pix.clear();}; |
---|
162 | void addOffsets(Param &par); |
---|
163 | void SortByZ(); // in Detection/sorting.cc |
---|
164 | bool hasEnoughChannels(int minNumber); |
---|
165 | // Text Output -- all in Detection/outputDetection.cc |
---|
166 | string outputLabelWCS(); |
---|
167 | string outputLabelPix(); |
---|
168 | string outputLabelInfo(); |
---|
169 | void outputDetectionTextWCS(std::ostream &stream); |
---|
170 | void outputDetectionText(std::ostream &stream, int idNumber); |
---|
171 | void outputDetectionText(int idNumber); |
---|
172 | // For plotting routines... |
---|
173 | void drawBorders(int xoffset, int yoffset); // in Cubes/drawMomentCutout.cc |
---|
174 | // |
---|
175 | friend std::ostream& operator<< ( std::ostream& theStream, Detection& obj); |
---|
176 | // |
---|
177 | private: |
---|
178 | vector <Voxel> pix; // array of pixels |
---|
179 | float xcentre; // x-value of centre pixel of object |
---|
180 | float ycentre; // y-value of centre pixel of object |
---|
181 | float zcentre; // z-value of centre pixel of object |
---|
182 | long xmin,xmax; // min and max x-values of object |
---|
183 | long ymin,ymax; // min and max y-values of object |
---|
184 | long zmin,zmax; // min and max z-values of object |
---|
185 | // Subsection offsets |
---|
186 | long xSubOffset; // The offset in the x-direction from the subsectioned cube |
---|
187 | long ySubOffset; // The offset in the y-direction from the subsectioned cube |
---|
188 | long zSubOffset; // The offset in the z-direction from the subsectioned cube |
---|
189 | // Flux related |
---|
190 | float totalFlux; // sum of the fluxes of all the pixels |
---|
191 | float peakFlux; // maximum flux over all the pixels |
---|
192 | float intFlux; // integrated flux --> involves integration over velocity. |
---|
193 | // |
---|
194 | int id; // ID -- generally number in list |
---|
195 | string name; // IAU-style name (based on position) |
---|
196 | bool flagWCS; // A flag indicating whether the WCS parameters have been set. |
---|
197 | string raS; // Central Right Ascension (or Longitude) in form 12:34:23 |
---|
198 | string decS; // Central Declination(or Latitude), in form -12:23:34 |
---|
199 | float ra; // Central Right Ascension in degrees |
---|
200 | float dec; // Central Declination in degrees |
---|
201 | float raWidth; // Width of detection in RA direction in arcmin |
---|
202 | float decWidth; // Width of detection in Dec direction in arcmin |
---|
203 | string lngtype; // Type of longitude axis (RA/GLON) |
---|
204 | string lattype; // Type of latitude axis (DEC/GLAT) |
---|
205 | string ztype; // Type of z-axis (FREQ/VEL/...) |
---|
206 | float nuRest; // Rest frequency |
---|
207 | float vel; // Central velocity (from zCentre) |
---|
208 | float velWidth; // Full velocity width |
---|
209 | float velMin; // Minimum velocity |
---|
210 | float velMax; // Maximum velocity |
---|
211 | |
---|
212 | }; |
---|
213 | |
---|
214 | /****************************************************************/ |
---|
215 | ////////////////////////////////////////////////////// |
---|
216 | // Prototypes for functions that use above classes |
---|
217 | ////////////////////////////////////////////////////// |
---|
218 | |
---|
219 | void outputDetectionTextWCSHeader(std::ostream &stream, wcsprm *wcs); |
---|
220 | void outputDetectionTextHeader(std::ostream &stream); |
---|
221 | void outputDetectionTextHeader(); |
---|
222 | |
---|
223 | void SortByZ(vector <Detection> &inputList); |
---|
224 | void SortByVel(vector <Detection> &inputList); |
---|
225 | Detection combineObjects(Detection &first, Detection &second); |
---|
226 | vector <Detection> combineLists(vector <Detection> &first, vector <Detection> &second); |
---|
227 | |
---|
228 | bool areClose(Detection &object1, Detection &object2, Param &par); |
---|
229 | void mergeIntoList(Detection &object, vector <Detection> &objList, Param &par); |
---|
230 | |
---|
231 | #endif |
---|