source: branches/fitshead-branch/Detection/detection.hh @ 1441

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

Large set of changes, mostly affecting the output:
Cubes/plotting.cc -- Added test for whether the device opened, so the plot is

not done if there is no device. Also added a
"Calculating maps..." statement for user's info when
/xs is used.

Cubes/detectionIO.cc -- New calls to set up the columns correctly before output
Cubes/cubes.hh -- added ColSet? objects to the Cube class
Cubes/plots.hh -- changed return type of the setUpPlot routines so you can

tell if the requested device did not open.

Cubes/getImage.cc -- fixed bug re. location of wcsfree(wcs);
param.cc -- Corrected bugs in calculating units in FitsHeader?.

Improved output of parameters, to include the relevant parameter
for an input file.

Detection/outputDetection.cc -- Improved output function using the new

Column classes.

Detection/columns.cc -- Definition and setup of columns for output.
Detection/detection.hh -- changed prototypes for output functions.
Detection/columns.hh -- Definition of Column namespace.

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