[3] | 1 | #ifndef DETECTION_H |
---|
| 2 | #define DETECTION_H |
---|
| 3 | |
---|
| 4 | #include <iostream> |
---|
| 5 | #include <string> |
---|
| 6 | #include <vector> |
---|
| 7 | #include <param.hh> |
---|
[103] | 8 | #ifndef COLUMNS_H |
---|
| 9 | #include <Detection/columns.hh> |
---|
| 10 | #endif |
---|
[3] | 11 | #include <Utils/utils.hh> |
---|
| 12 | |
---|
| 13 | using std::string; |
---|
| 14 | using std::vector; |
---|
[103] | 15 | using namespace Column; |
---|
[3] | 16 | |
---|
| 17 | /** |
---|
| 18 | * Voxel class |
---|
| 19 | * A 3-dimensional pixel, with x,y,z position + flux |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | class Voxel |
---|
| 23 | { |
---|
| 24 | public: |
---|
| 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 | // |
---|
| 45 | protected: |
---|
| 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 | |
---|
| 58 | class Pixel : public Voxel |
---|
| 59 | { |
---|
| 60 | public: |
---|
| 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 | |
---|
| 77 | class Detection |
---|
| 78 | { |
---|
| 79 | public: |
---|
[187] | 80 | Detection(){ |
---|
| 81 | flagWCS=false; negativeSource = false; flagText=""; |
---|
| 82 | xcentre = ycentre = zcentre = totalFlux = peakFlux = 0.; |
---|
| 83 | xmin=xmax=ymin=ymax=zmin=zmax=0; |
---|
| 84 | }; |
---|
| 85 | Detection(long numPix){ |
---|
| 86 | vector <Voxel> pix(numPix); flagWCS = false; negativeSource = false; |
---|
| 87 | }; |
---|
[3] | 88 | virtual ~Detection(){}; |
---|
| 89 | |
---|
| 90 | void addPixel(Voxel point){pix.push_back(point);}; |
---|
| 91 | Voxel getPixel(long pixNum){return pix[pixNum];}; |
---|
[16] | 92 | int getSize(){return pix.size();}; |
---|
| 93 | int getSpatialSize();// in detection.cc |
---|
[3] | 94 | // |
---|
| 95 | long getX(long pixCount){return pix[pixCount].getX();}; |
---|
| 96 | void setX(long pixCount, long x){pix[pixCount].setX(x);}; |
---|
| 97 | long getY(long pixCount){return pix[pixCount].getY();}; |
---|
| 98 | void setY(long pixCount, long y){pix[pixCount].setY(y);}; |
---|
| 99 | long getZ(long pixCount){return pix[pixCount].getZ();}; |
---|
| 100 | void setZ(long pixCount, long z){pix[pixCount].setZ(z);}; |
---|
| 101 | float getF(long pixCount){return pix[pixCount].getF();}; |
---|
| 102 | void setF(long pixCount, float f){pix[pixCount].setF(f);}; |
---|
| 103 | // |
---|
| 104 | long getXOffset(){return xSubOffset;}; |
---|
| 105 | void setXOffset(long o){xSubOffset = o;}; |
---|
| 106 | long getYOffset(){return ySubOffset;}; |
---|
| 107 | void setYOffset(long o){ySubOffset = o;}; |
---|
| 108 | long getZOffset(){return zSubOffset;}; |
---|
| 109 | void setZOffset(long o){zSubOffset = o;}; |
---|
| 110 | // |
---|
| 111 | float getXcentre(){return xcentre;}; |
---|
| 112 | void setXcentre(float x){xcentre = x;}; |
---|
| 113 | float getYcentre(){return ycentre;}; |
---|
| 114 | void setYcentre(float y){ycentre = y;}; |
---|
| 115 | float getZcentre(){return zcentre;}; |
---|
| 116 | void setCentre(float x, float y){xcentre = x; ycentre = y;}; |
---|
| 117 | float getTotalFlux(){return totalFlux;}; |
---|
| 118 | void setTotalFlux(float f){totalFlux = f;}; |
---|
[62] | 119 | float getIntegFlux(){return intFlux;}; |
---|
| 120 | void setIntegFlux(float f){intFlux = f;}; |
---|
[3] | 121 | float getPeakFlux(){return peakFlux;}; |
---|
| 122 | void setPeakFlux(float f){peakFlux = f;}; |
---|
[45] | 123 | long getXPeak(){return xpeak;}; |
---|
| 124 | void setXPeak(long x){xpeak = x;}; |
---|
| 125 | long getYPeak(){return ypeak;}; |
---|
| 126 | void setYPeak(long y){ypeak = y;}; |
---|
| 127 | long getZPeak(){return zpeak;}; |
---|
| 128 | void setZPeak(long z){zpeak = z;}; |
---|
[191] | 129 | float getPeakSNR(){return peakSNR;}; |
---|
| 130 | void setPeakSNR(float f){peakSNR=f;}; |
---|
[62] | 131 | bool isNegative(){return negativeSource;}; |
---|
| 132 | void setNegative(bool f){negativeSource = f;}; |
---|
[87] | 133 | string getFlagText(){return flagText;}; |
---|
| 134 | void setFlagText(string s){flagText = s;}; |
---|
| 135 | void addToFlagText(string s){flagText += s;}; |
---|
[3] | 136 | // |
---|
| 137 | long getXmin(){return xmin;}; |
---|
| 138 | long getYmin(){return ymin;}; |
---|
| 139 | long getZmin(){return zmin;}; |
---|
| 140 | long getXmax(){return xmax;}; |
---|
| 141 | long getYmax(){return ymax;}; |
---|
| 142 | long getZmax(){return zmax;}; |
---|
| 143 | // |
---|
| 144 | bool isWCS(){return flagWCS;}; |
---|
| 145 | string getName(){return name;}; |
---|
| 146 | void setName(string s){name = s;}; |
---|
| 147 | string getRAs(){return raS;}; |
---|
| 148 | void setRAs(string s){raS = s;}; |
---|
| 149 | string getDecs(){return decS;}; |
---|
| 150 | void setDecs(string s){decS = s;}; |
---|
| 151 | float getRA(){return ra;}; |
---|
| 152 | void setRA(float f){ra = f;}; |
---|
| 153 | float getDec(){return dec;}; |
---|
| 154 | void setDec(float f){dec = f;}; |
---|
| 155 | float getRAWidth(){return raWidth;}; |
---|
| 156 | void setRAWidth(float f){raWidth = f;}; |
---|
| 157 | float getDecWidth(){return decWidth;}; |
---|
| 158 | void setDecWidth(float f){decWidth = 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 | // |
---|
[144] | 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;}; |
---|
[191] | 180 | int getSNRPrec(){return snrPrec;}; |
---|
| 181 | void setSNRPrec(int i){snrPrec=i;}; |
---|
[144] | 182 | // |
---|
[3] | 183 | void addAnObject(Detection &toAdd); |
---|
[129] | 184 | void calcWCSparams(FitsHeader &head); |
---|
| 185 | float getIntegFlux(FitsHeader &head); |
---|
[3] | 186 | void calcParams(); |
---|
| 187 | void clearDetection(){this->pix.clear();}; |
---|
| 188 | void addOffsets(Param &par); |
---|
| 189 | void SortByZ(); // in Detection/sorting.cc |
---|
| 190 | bool hasEnoughChannels(int minNumber); |
---|
| 191 | // Text Output -- all in Detection/outputDetection.cc |
---|
| 192 | string outputLabelWCS(); |
---|
| 193 | string outputLabelPix(); |
---|
| 194 | string outputLabelInfo(); |
---|
[144] | 195 | void outputDetectionTextHeader(std::ostream &stream, vector<Col> columns); |
---|
| 196 | void outputDetectionTextWCS(std::ostream &stream, vector<Col> columns); |
---|
[187] | 197 | void outputDetectionText(std::ostream &stream, vector<Col> columns, |
---|
| 198 | int idNumber); |
---|
[3] | 199 | // For plotting routines... |
---|
[187] | 200 | void drawBorders(int xoffset, int yoffset); // in Cubes/drawMomentCutout.cc |
---|
[3] | 201 | // |
---|
| 202 | friend std::ostream& operator<< ( std::ostream& theStream, Detection& obj); |
---|
| 203 | // |
---|
| 204 | private: |
---|
| 205 | vector <Voxel> pix; // array of pixels |
---|
| 206 | float xcentre; // x-value of centre pixel of object |
---|
| 207 | float ycentre; // y-value of centre pixel of object |
---|
| 208 | float zcentre; // z-value of centre pixel of object |
---|
| 209 | long xmin,xmax; // min and max x-values of object |
---|
| 210 | long ymin,ymax; // min and max y-values of object |
---|
| 211 | long zmin,zmax; // min and max z-values of object |
---|
| 212 | // Subsection offsets |
---|
[187] | 213 | long xSubOffset; // The x-offset from the subsectioned cube |
---|
| 214 | long ySubOffset; // The y-offset from the subsectioned cube |
---|
| 215 | long zSubOffset; // The z-offset from the subsectioned cube |
---|
[3] | 216 | // Flux related |
---|
| 217 | float totalFlux; // sum of the fluxes of all the pixels |
---|
[187] | 218 | float intFlux; // integrated flux |
---|
| 219 | // --> involves integration over velocity. |
---|
[3] | 220 | float peakFlux; // maximum flux over all the pixels |
---|
[45] | 221 | long xpeak,ypeak,zpeak; // location of peak flux |
---|
[191] | 222 | float peakSNR; // signal-to-noise ratio at peak |
---|
[187] | 223 | bool negativeSource; // is the source a negative feature? |
---|
| 224 | string flagText; // any warning flags about the quality of |
---|
| 225 | // the detection. |
---|
[62] | 226 | // WCS related |
---|
[3] | 227 | int id; // ID -- generally number in list |
---|
| 228 | string name; // IAU-style name (based on position) |
---|
[187] | 229 | bool flagWCS; // A flag indicating whether the WCS parameters |
---|
| 230 | // have been set. |
---|
| 231 | string raS; // Central Right Ascension (or Longitude) in |
---|
| 232 | // form 12:34:23 |
---|
| 233 | string decS; // Central Declination(or Latitude), in |
---|
| 234 | // form -12:23:34 |
---|
[3] | 235 | float ra; // Central Right Ascension in degrees |
---|
| 236 | float dec; // Central Declination in degrees |
---|
[20] | 237 | float raWidth; // Width of detection in RA direction in arcmin |
---|
| 238 | float decWidth; // Width of detection in Dec direction in arcmin |
---|
[103] | 239 | string specUnits; // Units of the spectral dimension |
---|
| 240 | string fluxUnits; // Units of flux |
---|
| 241 | string intFluxUnits;// Units of integrated flux |
---|
[38] | 242 | string lngtype; // Type of longitude axis (RA/GLON) |
---|
| 243 | string lattype; // Type of latitude axis (DEC/GLAT) |
---|
[3] | 244 | float vel; // Central velocity (from zCentre) |
---|
| 245 | float velWidth; // Full velocity width |
---|
| 246 | float velMin; // Minimum velocity |
---|
| 247 | float velMax; // Maximum velocity |
---|
[144] | 248 | // The next four are the precision of values printed in the spectral plots |
---|
| 249 | int posPrec; // Precision of WCS positional values |
---|
| 250 | int xyzPrec; // Precision of pixel positional values |
---|
| 251 | int fintPrec; // Precision of F_int/F_tot values |
---|
| 252 | int fpeakPrec; // Precision of F_peak values |
---|
| 253 | int velPrec; // Precision of velocity values. |
---|
[191] | 254 | int snrPrec; // Precision of S/N_max values. |
---|
[3] | 255 | |
---|
| 256 | }; |
---|
| 257 | |
---|
| 258 | /****************************************************************/ |
---|
| 259 | ////////////////////////////////////////////////////// |
---|
| 260 | // Prototypes for functions that use above classes |
---|
| 261 | ////////////////////////////////////////////////////// |
---|
| 262 | |
---|
| 263 | void SortByZ(vector <Detection> &inputList); |
---|
| 264 | void SortByVel(vector <Detection> &inputList); |
---|
| 265 | Detection combineObjects(Detection &first, Detection &second); |
---|
[187] | 266 | vector <Detection> combineLists(vector <Detection> &first, |
---|
| 267 | vector <Detection> &second); |
---|
[3] | 268 | |
---|
| 269 | bool areClose(Detection &object1, Detection &object2, Param &par); |
---|
| 270 | void mergeIntoList(Detection &object, vector <Detection> &objList, Param &par); |
---|
[187] | 271 | void mergeList(vector<Detection> &objList, Param &par); //in Cubes/Merger.cc |
---|
| 272 | void finaliseList(vector<Detection> &objList, Param &par); //in Cubes/Merger.cc |
---|
| 273 | void ObjectMerger(vector<Detection> &objList, Param &par); //in Cubes/Merger.cc |
---|
[3] | 274 | |
---|
[56] | 275 | |
---|
[3] | 276 | #endif |
---|