source: tags/release-0.9/Detection/outputDetection.cc

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

param.cc Made sure the velocity threshold is always

printed when parameters are outputted.

Detection/detection.cc Corrected determination of object name -- was

in the wrong place.

Detection/outputDetection.cc Added space so that F_peak is separated

from F_int.

File size: 8.8 KB
Line 
1#include <iostream>
2#include <sstream>
3#include <fstream>
4#include <iomanip>
5#include <string>
6#include <stdio.h>
7#include <Cubes/cubes.hh>
8#include <Utils/utils.hh>
9
10using std::endl;
11using std::setw;
12using std::setfill;
13using std::setprecision;
14
15void Detection::outputDetectionTextWCS(std::ostream &stream)
16{
17  /**
18   * outputDetectionTextWCS
19   *  Prints to a stream the relevant details of a detected object,
20   *  including the WCS parameters, which need to have been calculated.
21   *  If they have not (given by the isWCS() function), then the WCS-related outputs
22   *  are left blank.
23   */
24
25  stream << setw(5)  << setfill(' ') << this->id;
26  if(this->flagWCS)
27    stream << setw(14)               << this->name;
28  else stream << "              ";
29  stream.setf(std::ios::fixed); 
30  stream <<setprecision(1);
31  stream << setw(6)  << setfill(' ') << this->xcentre + this->xSubOffset;
32  stream << setw(6)                  << this->ycentre + this->ySubOffset;
33  stream << setw(7)                  << this->zcentre + this->zSubOffset;
34  if(this->flagWCS){
35    stream << setw(13)               << this->raS;
36    stream << setw(13)               << this->decS;
37    stream << setprecision(2);
38    stream << setw(8)                << this->raWidth;
39    stream << setw(8)                << this->decWidth;
40    stream << setprecision(3);
41    stream << setw(10)               << this->vel;
42    stream << setw(9)                << this->velWidth;
43  }
44  else stream << "                                                             ";
45  stream << setw(4)                  << this->xmin + this->xSubOffset;
46  stream << setw(4)                  << this->xmax + this->xSubOffset;
47  stream << setw(4)                  << this->ymin + this->ySubOffset;
48  stream << setw(4)                  << this->ymax + this->ySubOffset;
49  stream << setw(5)                  << this->zmin + this->zSubOffset;
50  stream << setw(5)                  << this->zmax + this->zSubOffset;
51  stream << setprecision(4);
52  stream << setw(6)                  << this->pix.size();
53  //   stream << setw(8)                  << this->totalFlux();
54  stream << setw(10)                 << this->intFlux;
55  stream << setw(9)                  << this->peakFlux;
56  stream << endl;
57  resetiosflags(std::ios::fixed);
58
59}
60
61void outputDetectionTextWCSHeader(std::ostream &stream, wcsprm *wcs)
62{
63  /**
64   * outputDetectionTextWCSHeader
65   *  Prints to a stream the column headers to match the output generated by outputDetectionTextWCS
66   */
67
68  string lngtype = wcs->lngtyp;
69  string lattype = wcs->lattyp;
70 
71  stream<<setfill(' ');
72  stream << setw(5)  << "Obj#";
73  stream << setw(14) << "Name";
74  stream << setw(6)  << "X";
75  stream << setw(6)  << "Y";
76  stream << setw(7)  << "Z";
77  stream << setw(13) << lngtype;
78  stream << setw(13) << lattype;
79  stream << setw(8)  << "w_"+lngtype;
80  stream << setw(8)  << "w_"+lattype;
81  stream << setw(10) << "VEL";
82  stream << setw(9)  << "w_VEL";
83  stream << setw(4)  << "X1";
84  stream << setw(4)  << "X2";
85  stream << setw(4)  << "Y1";
86  stream << setw(4)  << "Y2";
87  stream << setw(5)  << "Z1";
88  stream << setw(5)  << "Z2";
89  stream << setw(6)  << "Npix";
90  stream << setw(10) << "F_tot";
91  stream << setw(9)  << "F_peak";
92  stream<<endl;
93  stream<<setfill('-')<<setw(5+14+6+6+7+13+13+8+8+10+9+4+4+4+4+5+5+6+10+9)<<'-';
94  stream<<endl;
95
96}
97
98void Detection::outputDetectionText(std::ostream &stream, int idNumber)
99{
100  /**
101   * outputDetectionText
102   *  Print to a stream the relevant details of a detected object.
103   *  This does not include any WCS parameters, only pixel positions & extent, and flux info.
104   *  Also prints a counter, provided as an input.
105   */
106
107  stream<<setw(5) <<setfill(' ')<< idNumber;
108  stream.setf(std::ios::fixed); 
109  stream<<setfill(' ') << setprecision(1);
110  stream<<setw(6) << this->xcentre + this->xSubOffset;
111  stream<<setw(6) << this->ycentre + this->ySubOffset;
112  stream<<setw(7) << this->zcentre + this->zSubOffset;
113  stream<<setw(4) << this->xmin + this->xSubOffset;
114  stream<<setw(4) << this->xmax + this->xSubOffset;
115  stream<<setw(4) << this->ymin + this->ySubOffset;
116  stream<<setw(4) << this->ymax + this->ySubOffset;
117  stream<<setw(5) << this->zmin + this->zSubOffset;
118  stream<<setw(5) << this->zmax + this->zSubOffset;   
119  stream<<setprecision(4);
120  stream<<setw(6) << this->pix.size();
121  stream<<setw(10)<< this->totalFlux;
122  stream<<setw(9) << this->peakFlux; 
123  stream<<endl;
124  resetiosflags(std::ios::fixed);
125
126}
127
128void outputDetectionTextHeader(std::ostream &stream)
129{
130  /**
131   * outputDetectionTextHeader
132   *  Prints to a stream the column headers to match the output generated by outputDetectionText
133   */
134
135  stream<<setfill(' ');
136  stream<<setw(5)<<"Obj#";
137  stream<<setw(6)<<"X";
138  stream<<setw(6)<<"Y";
139  stream<<setw(7)<<"Z";
140  stream<<setw(4)<<"X1";
141  stream<<setw(4)<<"X2";
142  stream<<setw(4)<<"Y1";
143  stream<<setw(4)<<"Y2";
144  stream<<setw(5)<<"Z1";
145  stream<<setw(5)<<"Z2";
146  stream<<setw(6)<<"Npix";
147  stream<<setw(10)<<"F_tot";
148  stream<<setw(9)<<"F_peak";
149  stream<<endl;
150  stream<<setfill('-')<<setw(4+6+6+7+4+4+4+4+5+5+6+10+9)<<'-';
151  stream<<endl;
152}
153
154void Detection::outputDetectionText(int idNumber)
155{
156  /**
157   * outputDetectionText
158   *  Print to std::cout the relevant details of a detected object.
159   *  This does not include any WCS parameters, only pixel positions & extent, and flux info.
160   *  Also prints a counter, provided as an input.
161   */
162
163  std::cout<<setw(5)<<setfill('0')<<idNumber;
164  std::cout.setf(std::ios::fixed); 
165  std::cout<<setfill(' ')<<setprecision(1);
166  std::cout<<setw(6) << this->xcentre + this->xSubOffset;
167  std::cout<<setw(6) << this->ycentre + this->ySubOffset;
168  std::cout<<setw(7) << this->zcentre + this->zSubOffset;
169  std::cout<<setw(4) << this->xmin + this->xSubOffset;   
170  std::cout<<setw(4) << this->xmax + this->xSubOffset;   
171  std::cout<<setw(4) << this->ymin + this->ySubOffset;   
172  std::cout<<setw(4) << this->ymax + this->ySubOffset;   
173  std::cout<<setw(5) << this->zmin + this->zSubOffset;   
174  std::cout<<setw(5) << this->zmax + this->zSubOffset;   
175  std::cout<<setprecision(4);
176  std::cout<<setw(6) << this->pix.size();       
177  std::cout<<setw(10)<< this->totalFlux;       
178  std::cout<<setw(9) << this->peakFlux; 
179  std::cout<<endl;
180  resetiosflags(std::ios::fixed);
181
182}
183
184void outputDetectionTextHeader()
185{
186  /**
187   * outputDetectionTextHeader
188   *  Prints to std::cout the column headers to match the output generated by outputDetectionText
189   */
190
191  std::cout<<setfill(' ');
192  std::cout<<setw(5)<<"Obj#";
193  std::cout<<setw(6)<<"Xcent";
194  std::cout<<setw(6)<<"Ycent";
195  std::cout<<setw(7)<<"Zcent";
196  std::cout<<setw(4)<<"X1";
197  std::cout<<setw(4)<<"X2";
198  std::cout<<setw(4)<<"Y1";
199  std::cout<<setw(4)<<"Y2";
200  std::cout<<setw(5)<<"Z1";
201  std::cout<<setw(5)<<"Z2";
202  std::cout<<setw(6)<<"Npix";
203  std::cout<<setw(10)<<"F_tot";
204  std::cout<<setw(9)<<"F_peak";
205  std::cout<<endl;
206  for(int i=0;i<4+6+6+7+4+4+4+4+5+5+6+10+9;i++) std::cout<<'-';
207  std::cout<<endl;
208
209}
210
211string Detection::outputLabelWCS()
212{
213
214  std::stringstream ss;
215  ss << "#" << setfill('0') << setw(3) << this->id << ": ";
216  ss << setfill(' ');
217  ss << this->raS << ", ";
218  ss << this->decS;
219  ss << setprecision(3);
220  ss.setf(std::ios::fixed);
221  ss << ", Vel=" << this->vel <<"km/s";
222
223  return ss.str();
224
225
226}
227
228
229string Detection::outputLabelPix()
230{
231  /**
232   * outputLabelPix
233   *  Prints to a string the pixel centres and extents of a detected object.
234   *  Returns the string.
235   */
236
237  std::stringstream ss;
238  ss.setf(std::ios::fixed);
239  ss << setprecision(1) << setfill(' ');
240  ss       <<setw(5)<< this->xcentre + this->xSubOffset;
241  ss <<" " <<setw(5)<< this->ycentre + this->ySubOffset;
242  ss <<" " <<setw(5)<< this->zcentre + this->zSubOffset;
243  ss <<" ["<<setw(3)<< this->xmin + this->xSubOffset   <<":"<< this->xmax + this->xSubOffset;
244  ss <<", "<<setw(3)<< this->ymin + this->ySubOffset   <<":"<< this->ymax + this->ySubOffset;
245  ss <<", "<<setw(3)<< this->zmin + this->zSubOffset   <<":"<< this->zmax + this->zSubOffset << "]";
246 
247  return ss.str();
248}
249
250
251
252string Detection::outputLabelInfo()
253{
254  /**
255   * outputLabelInfo
256   *  Prints to a string the widths of the object (in position and velocity),
257   *  as well as the flux information.
258   *  Assumes the WCS parameters of the object have been calculated.
259   *  If they have not (given by the isWCS() function), then the WCS-related outputs
260   *  are left blank.
261   *  Returns the string.
262   */
263
264  std::stringstream ss;
265  ss << setprecision(3);
266  ss.setf(std::ios::fixed);
267  if(this->flagWCS){
268    ss << "w_"          << this->lngtype  <<"="    << this->raWidth;
269    ss << ", w_"        << this->lattype  <<"="    << this->decWidth;
270    ss << ", w_Vel="    << this->velWidth <<"km/s";
271    ss << ", F\\dT\\u=" << this->intFlux;
272  }
273  else
274    ss << "F\\dT\\u="   << this->intFlux;
275  //ss << ", F\\dT\\u=" << this->totalFlux;
276  ss   << ", F\\dP\\u=" << this->peakFlux;
277  string output = ss.str();
278
279  return output;
280}
281
Note: See TracBrowser for help on using the repository browser.