source: trunk/src/mainRrose.cc @ 221

Last change on this file since 221 was 221, checked in by Matthew Whiting, 17 years ago

More documentation being added to source code, with a new file (src/Utils/Hanning.cc) added as well.

File size: 2.7 KB
Line 
1#include <iostream>
2#include <fstream>
3#include <string>
4#include <cpgplot.h>
5#include <math.h>
6#include <unistd.h>
7#include <time.h>
8
9#include <duchamp.hh>
10#include <param.hh>
11#include <Detection/detection.hh>
12#include <Cubes/cubes.hh>
13#include <Utils/utils.hh>
14#include <ATrous/atrous.hh>
15
16using std::ifstream;
17using std::string;
18
19Filter reconFilter;
20
21int main(int argc, char * argv[])
22{
23
24  string paramFile,fitsfile,temp;
25  Cube *cube = new Cube;
26
27  if(cube->getopts(argc,argv)==FAILURE) return FAILURE;
28
29  if(cube->pars().getImageFile().empty()){
30    std::stringstream errmsg;
31    errmsg << "No input image has been given!\n"
32           << "Use the imageFile parameter in "
33           << paramFile << " to specify the FITS file.\nExiting...\n";
34    duchampError("Duchamp", errmsg.str());
35    return FAILURE;
36  }
37
38  if(cube->pars().getFlagSubsection()){
39    // make sure the subsection is OK.
40    if(cube->pars().verifySubsection() == FAILURE){
41      duchampError("Duchamp",
42                   "Unable to use the subsection provided.\nExiting...\n");
43      return FAILURE;
44    }
45  }     
46
47  std::cout << "Opening image: "
48            << cube->pars().getFullImageFile() << std::endl;
49
50  if( cube->getCube() == FAILURE){
51    std::stringstream errmsg;
52    errmsg << "Unable to open image file "
53           << cube->pars().getFullImageFile()
54           << "\nExiting...\n";
55    duchampError("Duchamp", errmsg.str());
56    return FAILURE;
57  }
58  else std::cout << "Opened successfully." << std::endl;
59
60  // Read in any saved arrays that are in FITS files on disk.
61  cube->readSavedArrays();
62
63
64  ifstream logfile(cube->pars().getLogFile().c_str());
65 
66  if(!logfile.is_open()){
67    std::cerr << "\aUnable to open file "
68              << cube->pars().getLogFile() << "\nExiting...\n";
69    return 1;
70  }
71
72  // read down until first Detection # line
73  cube->setCubeStats();
74  std::cerr << "Reading from logfile : " << cube->pars().getLogFile() << "\n";
75  while(getline(logfile,temp), temp.substr(0,11)!="Detection #"){ }
76  int xpix, ypix, zpix;
77  float fpix;
78  while(!logfile.eof()){
79    Detection obj;
80    while(getline(logfile,temp), temp.substr(0,3)!="---"){
81      std::stringstream ss;
82      ss.str(temp);
83      ss >> xpix >> ypix >> zpix >> fpix;
84      Voxel vox(xpix,ypix,zpix,fpix);
85      obj.addPixel(vox);
86    }
87    obj.setOffsets(cube->pars());
88    obj.calcParams();
89    if(obj.getSize()>0) cube->addObject(obj);
90    getline(logfile,temp); // reads next line -- should be Detection #...
91    if(temp.substr(0,4)=="----") getline(logfile,temp);
92  }
93
94  std::cout<<"Final object count = "<<cube->getNumObj()<<std::endl;
95
96  cube->calcObjectWCSparams();
97  cube->setObjectFlags();
98
99  if((cube->getDimZ()>1) && (cube->getNumObj()>0)){
100    std::cout << "Plotting the individual spectra... " << std::flush;
101    cube->outputSpectra();
102    std::cout << "done.\n";
103  }
104
105}
Note: See TracBrowser for help on using the repository browser.