[3] | 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 | long getSize(){return pix.size();}; |
---|
| 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 getPeakFlux(){return peakFlux;}; |
---|
| 111 | void setPeakFlux(float f){peakFlux = f;}; |
---|
| 112 | float getIntegFlux(){return intFlux;}; |
---|
| 113 | void setIntegFlux(float f){intFlux = f;}; |
---|
| 114 | // |
---|
| 115 | long getXmin(){return xmin;}; |
---|
| 116 | long getYmin(){return ymin;}; |
---|
| 117 | long getZmin(){return zmin;}; |
---|
| 118 | long getXmax(){return xmax;}; |
---|
| 119 | long getYmax(){return ymax;}; |
---|
| 120 | long getZmax(){return zmax;}; |
---|
| 121 | // |
---|
| 122 | bool isWCS(){return flagWCS;}; |
---|
| 123 | string getName(){return name;}; |
---|
| 124 | void setName(string s){name = s;}; |
---|
| 125 | string getRAs(){return raS;}; |
---|
| 126 | void setRAs(string s){raS = s;}; |
---|
| 127 | string getDecs(){return decS;}; |
---|
| 128 | void setDecs(string s){decS = s;}; |
---|
| 129 | float getRA(){return ra;}; |
---|
| 130 | void setRA(float f){ra = f;}; |
---|
| 131 | float getDec(){return dec;}; |
---|
| 132 | void setDec(float f){dec = f;}; |
---|
| 133 | float getRAWidth(){return raWidth;}; |
---|
| 134 | void setRAWidth(float f){raWidth = f;}; |
---|
| 135 | float getDecWidth(){return decWidth;}; |
---|
| 136 | void setDecWidth(float f){decWidth = f;}; |
---|
| 137 | float getLNGRatio(){return lngRatio;}; |
---|
| 138 | void setLNGRatio(float f){lngRatio = f;}; |
---|
| 139 | string getLNGtype(){return lngtype;}; |
---|
| 140 | void setLNGtype(string s){lngtype = s;}; |
---|
| 141 | string getLATtype(){return lattype;}; |
---|
| 142 | void setLATtype(string s){lattype = s;}; |
---|
| 143 | string getZtype(){return ztype;}; |
---|
| 144 | void setZtype(string s){ztype = s;}; |
---|
| 145 | float getNuRest(){return nuRest;}; |
---|
| 146 | void setNuRest(float f){nuRest = f;}; |
---|
| 147 | float getVel(){return vel;}; |
---|
| 148 | void setVel(float f){vel = f;}; |
---|
| 149 | float getVelWidth(){return velWidth;}; |
---|
| 150 | void setVelWidth(float f){velWidth = f;}; |
---|
| 151 | float getVelMin(){return velMin;}; |
---|
| 152 | void setVelMin(float f){velMin = f;}; |
---|
| 153 | float getVelMax(){return velMax;}; |
---|
| 154 | void setVelMax(float f){velMax = f;}; |
---|
| 155 | int getID(){return id;}; |
---|
| 156 | void setID(int i){id = i;}; |
---|
| 157 | // |
---|
| 158 | void addAnObject(Detection &toAdd); |
---|
| 159 | void calcWCSparams(wcsprm *wcs); |
---|
| 160 | float getIntegFlux(wcsprm *wcs); |
---|
| 161 | void calcParams(); |
---|
| 162 | void clearDetection(){this->pix.clear();}; |
---|
| 163 | void addOffsets(Param &par); |
---|
| 164 | void SortByZ(); // in Detection/sorting.cc |
---|
| 165 | bool hasEnoughChannels(int minNumber); |
---|
| 166 | // Text Output -- all in Detection/outputDetection.cc |
---|
| 167 | string outputLabelWCS(); |
---|
| 168 | string outputLabelPix(); |
---|
| 169 | string outputLabelInfo(); |
---|
| 170 | void outputDetectionTextWCS(std::ostream &stream); |
---|
| 171 | void outputDetectionText(std::ostream &stream, int idNumber); |
---|
| 172 | void outputDetectionText(int idNumber); |
---|
| 173 | // For plotting routines... |
---|
| 174 | void drawBorders(int xoffset, int yoffset); // in Cubes/drawMomentCutout.cc |
---|
| 175 | // |
---|
| 176 | friend std::ostream& operator<< ( std::ostream& theStream, Detection& obj); |
---|
| 177 | // |
---|
| 178 | private: |
---|
| 179 | vector <Voxel> pix; // array of pixels |
---|
| 180 | float xcentre; // x-value of centre pixel of object |
---|
| 181 | float ycentre; // y-value of centre pixel of object |
---|
| 182 | float zcentre; // z-value of centre pixel of object |
---|
| 183 | long xmin,xmax; // min and max x-values of object |
---|
| 184 | long ymin,ymax; // min and max y-values of object |
---|
| 185 | long zmin,zmax; // min and max z-values of object |
---|
| 186 | // Subsection offsets |
---|
| 187 | long xSubOffset; // The offset in the x-direction from the subsectioned cube |
---|
| 188 | long ySubOffset; // The offset in the y-direction from the subsectioned cube |
---|
| 189 | long zSubOffset; // The offset in the z-direction from the subsectioned cube |
---|
| 190 | // Flux related |
---|
| 191 | float totalFlux; // sum of the fluxes of all the pixels |
---|
| 192 | float peakFlux; // maximum flux over all the pixels |
---|
| 193 | float intFlux; // integrated flux --> involves integration over velocity. |
---|
| 194 | // |
---|
| 195 | int id; // ID -- generally number in list |
---|
| 196 | string name; // IAU-style name (based on position) |
---|
| 197 | bool flagWCS; // A flag indicating whether the WCS parameters have been set. |
---|
| 198 | string raS; // Central Right Ascension (or Longitude) in form 12:34:23 |
---|
| 199 | string decS; // Central Declination(or Latitude), in form -12:23:34 |
---|
| 200 | float ra; // Central Right Ascension in degrees |
---|
| 201 | float dec; // Central Declination in degrees |
---|
| 202 | float raWidth; // Width of detection in RA direction |
---|
| 203 | float decWidth; // Width of detection in Dec direction |
---|
| 204 | float lngRatio; // Ratio of longitude/RA in decimal units to degrees value (=15. for RA case) |
---|
| 205 | string lngtype; // Type of longitude axis (RA/GALLNG) |
---|
| 206 | string lattype; // Type of latitude axis (Dec/GALLAT) |
---|
| 207 | string ztype; // Type of z-axis (FREQ/VEL/...) |
---|
| 208 | float nuRest; // Rest frequency |
---|
| 209 | float vel; // Central velocity (from zCentre) |
---|
| 210 | float velWidth; // Full velocity width |
---|
| 211 | float velMin; // Minimum velocity |
---|
| 212 | float velMax; // Maximum velocity |
---|
| 213 | |
---|
| 214 | }; |
---|
| 215 | |
---|
| 216 | /****************************************************************/ |
---|
| 217 | ////////////////////////////////////////////////////// |
---|
| 218 | // Prototypes for functions that use above classes |
---|
| 219 | ////////////////////////////////////////////////////// |
---|
| 220 | |
---|
| 221 | void outputDetectionTextWCSHeader(std::ostream &stream, wcsprm *wcs); |
---|
| 222 | void outputDetectionTextHeader(std::ostream &stream); |
---|
| 223 | void outputDetectionTextHeader(); |
---|
| 224 | |
---|
| 225 | void SortByZ(vector <Detection> &inputList); |
---|
| 226 | void SortByVel(vector <Detection> &inputList); |
---|
| 227 | Detection combineObjects(Detection &first, Detection &second); |
---|
| 228 | vector <Detection> combineLists(vector <Detection> &first, vector <Detection> &second); |
---|
| 229 | |
---|
| 230 | bool areClose(Detection &object1, Detection &object2, Param &par); |
---|
| 231 | void mergeIntoList(Detection &object, vector <Detection> &objList, Param &par); |
---|
| 232 | |
---|
| 233 | #endif |
---|