source: tags/release-0.9.2/Detection/outputDetection.cc @ 1455

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

Some minor fixes to the spectral plots to aid readability and consistency
of presentation.
Some minor edits to the Guide.

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