source: branches/fitshead-branch/Detection/outputDetection.cc @ 1377

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

Large collection of changes. Mostly minor fixes, but major additions are:

  • ability to store flagMW in the recon FITS file
  • slight change to way precision is dealt with in output files
  • improvement to VOTable output
  • generalisation of spectral plotting.

Summary of changes:
duchamp.hh -- added keywords/comments for storing flagMW in FITS files
Utils/wcsFunctions.cc -- minor correction
Cubes/plotting.cc -- minor corrections
Cubes/saveImage.cc -- writing flagMW as header keyword
Cubes/readRecon.cc -- able to read in flagMW. Improved formatting of comments
Cubes/detectionIO.cc -- made VOTable output able to cope with Column

definitions. Added new columns.

Cubes/cubes.hh -- added frontends to wcs-pix functions. Changed prototypes

of some plotting functions.

Cubes/plots.hh -- generalised some functionality of the classes
Cubes/drawMomentCutout.cc -- made a class function
Cubes/outputSpectra.cc -- made a Cube class function that plots a

single spectrum.

param.cc -- improved calling of local variables, and the way units are

dealt with.

docs/example_moment_map.pdf -- new version
docs/cover_image.ps -- new version
docs/example_spectrum.pdf -- new version
docs/cover_image.pdf -- new version
docs/example_moment_map.ps -- new version
docs/example_spectrum.ps -- new version
mainDuchamp.cc -- fixed order of some function calls. Other minor corrections.
ATrous/atrous_2d_reconstruct.cc -- improved speed of loop execution
ATrous/atrous_3d_reconstruct.cc -- improved speed of loop execution
Makefile -- addition of columns.cc
Detection/detection.cc -- minor corrections (removal of commented code)
Detection/outputDetection.cc -- minor change to output style and

precision variable name.

Detection/columns.cc -- use new precision variable
Detection/columns.hh -- new precision variables for position and position

width columns

param.hh -- added prototype for makelower(string) function.

File size: 7.6 KB
Line 
1#include <iostream>
2#include <sstream>
3#include <fstream>
4#include <iomanip>
5#include <string>
6#include <vector>
7#include <stdio.h>
8#include <param.hh>
9#include <Detection/detection.hh>
10#include <Cubes/cubes.hh>
11#include <Utils/utils.hh>
12#include <Detection/columns.hh>
13
14using std::endl;
15using std::setw;
16using std::setfill;
17using std::setprecision;
18 
19using namespace Column;
20
21void outputDetectionTextWCSHeader(std::ostream &stream, ColSet columns)
22{
23  /**
24   * outputDetectionTextWCSHeader
25   *  Prints to a stream the column headers to match the output generated by outputDetectionTextWCS
26   */
27
28  stream << setfill(' ');
29  for(int i=0;i<columns.vec.size();i++) columns.vec[i].dash(stream);
30  stream << endl;
31  for(int i=0;i<columns.vec.size();i++) columns.vec[i].title(stream);
32  stream << endl;
33  for(int i=0;i<columns.vec.size();i++) columns.vec[i].units(stream);
34  stream << endl;
35  for(int i=0;i<columns.vec.size();i++) columns.vec[i].dash(stream);
36  stream << endl;
37
38}
39
40void Detection::outputDetectionTextWCS(std::ostream &stream, ColSet columns)
41{
42  /**
43   * outputDetectionTextWCS
44   *  Prints to a stream the relevant details of a detected object,
45   *  including the WCS parameters, which need to have been calculated.
46   *  If they have not (given by the isWCS() function), then the
47   *  WCS-related outputs are left blank.
48   */
49
50  stream.setf(std::ios::fixed); 
51  columns.vec[0].entry(stream,this->id);
52  columns.vec[1].entry(stream,this->name);
53  stream << setprecision(xyzPrec);
54  columns.vec[2].entry(stream,this->xcentre + this->xSubOffset);
55  columns.vec[3].entry(stream,this->ycentre + this->ySubOffset);
56  columns.vec[4].entry(stream,this->zcentre + this->zSubOffset);
57  if(this->flagWCS){
58    columns.vec[5].entry(stream,this->raS);
59    columns.vec[6].entry(stream,this->decS);
60    stream << setprecision(velPrec);
61    columns.vec[7].entry(stream,this->vel);
62    stream << setprecision(wposPrec);
63    columns.vec[8].entry(stream,this->raWidth);
64    columns.vec[9].entry(stream,this->decWidth);
65    stream << setprecision(velPrec);
66    columns.vec[10].entry(stream,this->velWidth);
67  }
68  else for(int i=5;i<11;i++) columns.vec[i].blank(stream);
69  stream << setprecision(fluxPrec);
70  if(this->flagWCS) columns.vec[11].entry(stream,this->intFlux);
71  else columns.vec[11].entry(stream,this->totalFlux);
72  columns.vec[12].entry(stream,this->peakFlux);
73  columns.vec[13].entry(stream,this->xmin + this->xSubOffset);
74  columns.vec[14].entry(stream,this->xmax + this->xSubOffset);
75  columns.vec[15].entry(stream,this->ymin + this->ySubOffset);
76  columns.vec[16].entry(stream,this->ymax + this->ySubOffset);
77  columns.vec[17].entry(stream,this->zmin + this->zSubOffset);
78  columns.vec[18].entry(stream,this->zmax + this->zSubOffset);
79  columns.vec[19].entry(stream,int(this->pix.size()));
80  columns.vec[20].entry(stream,this->flagText);
81  stream << endl;
82
83}
84
85void outputDetectionTextHeader(std::ostream &stream, ColSet columns)
86{
87  /**
88   * outputDetectionTextHeader
89   *  Prints to a stream the column headers to match the output generated by outputDetectionText
90   */
91
92  stream << setfill(' ');
93  for(int i=0;i<columns.vec.size();i++) columns.vec[i].dash(stream);
94  stream << endl;
95  for(int i=0;i<columns.vec.size();i++) columns.vec[i].title(stream);
96  stream << endl;
97  for(int i=0;i<columns.vec.size();i++) columns.vec[i].units(stream);
98  stream << endl;
99  for(int i=0;i<columns.vec.size();i++) columns.vec[i].dash(stream);
100  stream << endl;
101}
102
103void Detection::outputDetectionText(std::ostream &stream, ColSet columns, int idNumber)
104{
105  /**
106   * outputDetectionText
107   *  Print to a stream the relevant details of a detected object.
108   *  This does not include any WCS parameters, only pixel positions & extent,
109   *    and flux info.
110   *  Also prints a counter, provided as an input.
111   */
112
113  stream << setfill(' ');
114  stream.setf(std::ios::fixed); 
115  columns.vec[0].entry(stream,idNumber);
116  stream << setprecision(xyzPrec);
117  columns.vec[1].entry(stream,this->xcentre + this->xSubOffset);
118  columns.vec[2].entry(stream,this->ycentre + this->ySubOffset);
119  columns.vec[3].entry(stream,this->zcentre + this->zSubOffset);
120  stream << setprecision(fluxPrec);
121  columns.vec[4].entry(stream,this->totalFlux);
122  columns.vec[5].entry(stream,this->peakFlux);
123  columns.vec[6].entry(stream,this->xmin + this->xSubOffset);
124  columns.vec[7].entry(stream,this->xmax + this->xSubOffset);
125  columns.vec[8].entry(stream,this->ymin + this->ySubOffset);
126  columns.vec[9].entry(stream,this->ymax + this->ySubOffset);
127  columns.vec[10].entry(stream,this->zmin + this->zSubOffset);
128  columns.vec[11].entry(stream,this->zmax + this->zSubOffset);
129  columns.vec[12].entry(stream,int(this->pix.size()));
130  stream<<endl;
131
132}
133
134string Detection::outputLabelWCS()
135{
136
137  std::stringstream ss;
138  ss << "#" << setfill('0') << setw(3) << this->id << ": ";
139  ss << this->name ;
140  if(this->getFlagText()!="")
141    ss << " [" << this->getFlagText() << "]   ";
142  else ss<< "   ";
143  ss << setfill(' ');
144  ss << this->raS << ", ";
145  ss << this->decS;
146  ss << setprecision(3);
147  ss.setf(std::ios::fixed);
148  ss << ", " << this->vel << " " << this->specUnits;
149
150  return ss.str();
151
152
153}
154
155
156string Detection::outputLabelInfo()
157{
158  /**
159   * outputLabelInfo
160   *  Prints to a string the widths of the object (in position and velocity),
161   *  as well as the flux information.
162   *  Assumes the WCS parameters of the object have been calculated.
163   *  If they have not (given by the isWCS() function), then the WCS-related outputs
164   *  are left blank.
165   *  Returns the string.
166   */
167
168  std::stringstream ss;
169  ss.setf(std::ios::fixed);
170  if(this->flagWCS){
171    ss << setprecision(2);
172    ss << "w_"          << this->lngtype  <<"="    << this->raWidth;
173    ss << ", w_"        << this->lattype  <<"="    << this->decWidth;
174    ss << setprecision(3);
175    ss << ", w_Vel="    << this->velWidth << " " << this->specUnits;
176    ss << ", F\\dint\\u=" << this->intFlux << " " << this->intFluxUnits;
177    ss << ", F\\dpeak\\u=" << this->peakFlux << " " << this->fluxUnits;
178  }
179  else{
180    ss << "#" << setfill('0') << setw(3) << this->id << ": ";
181    ss << setprecision(3);
182    ss << "F\\dtot\\u=" << this->totalFlux << this->fluxUnits;
183    ss << ", F\\dpeak\\u=" << this->peakFlux << this->fluxUnits;
184  }
185  string output = ss.str();
186
187  return output;
188}
189
190
191string Detection::outputLabelPix()
192{
193  /**
194   * outputLabelPix
195   *  Prints to a string the pixel centres and extents of a detected object.
196   *  Returns the string.
197   */
198
199  std::stringstream ss;
200  ss.setf(std::ios::fixed);
201  // // This is the OLD code -- have improved the formatting below...
202//   ss << this->pix.size() << " Voxels:  ";
203//   ss << setprecision(1) << setfill(' ');
204//   ss       <<setw(5)<< this->xcentre + this->xSubOffset;
205//   ss <<" " <<setw(5)<< this->ycentre + this->ySubOffset;
206//   ss <<" " <<setw(5)<< this->zcentre + this->zSubOffset;
207//   ss <<" ["<<setw(3)<< this->xmin + this->xSubOffset   <<":"<< this->xmax + this->xSubOffset;
208//   ss <<", "<<setw(3)<< this->ymin + this->ySubOffset   <<":"<< this->ymax + this->ySubOffset;
209//   ss <<", "<<setw(3)<< this->zmin + this->zSubOffset   <<":"<< this->zmax + this->zSubOffset << "]";
210  ss << "Centre: ";
211  ss << setprecision(1) << setfill(' ');
212  ss <<"("  << this->xcentre + this->xSubOffset;
213  ss <<", " << this->ycentre + this->ySubOffset;
214  ss <<", " << this->zcentre + this->zSubOffset << ")";
215  ss <<", Size: " << this->pix.size() << " voxels,  ";
216  ss <<"Range: ["<< this->xmin + this->xSubOffset <<":"<< this->xmax + this->xSubOffset;
217  ss <<", "      << this->ymin + this->ySubOffset <<":"<< this->ymax + this->ySubOffset;
218  ss <<", "      << this->zmin + this->zSubOffset <<":"<< this->zmax + this->zSubOffset << "]";
219 
220  return ss.str();
221}
222
223
Note: See TracBrowser for help on using the repository browser.