source: branches/pixel-map-branch/src/mainRrose.cc @ 1441

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