source: trunk/src/mainRrose.cc @ 236

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

Put the Voxel and Pixel classes into their own file voxel.hh and voxel.cc, and adjusted the #include statements of the necessary files. Also added them into the Makefile.

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