source: branches/pixel-map-branch/src/Cubes/smoothCube.cc

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

Mainly changes to improve the execution speed and reliability of the searching:

  • Changed the extractSpectrum & extractImage functions, so that they don't call saveArray, but rather just write directly to the flux array.
  • In the searching functions, moved the definitions of spectrum and channelImage (the Image objects) out of the loops over pixels/channels. This way they are only defined once, rather than each time round the loop.
  • Fixed a bug so that the full number of individual detections in the 1D case are reported, rather than the number after the mergeIntoList has done its job.
  • When Merger prints out the counter/size information, the counter number now starts at 1, not 0 (more sensible when comparing to the size).
  • Otherwise, minor presentation tweaks.
File size: 2.1 KB
Line 
1#include <Cubes/cubes.hh>
2#include <Utils/feedback.hh>
3#include <Utils/Hanning.hh>
4
5
6void Cube::SmoothSearch()
7{
8  /**
9   * The Cube is first smoothed, using Cube::SmoothCube().
10   * It is then searched, using searchReconArray()
11   * The resulting object list is stored in the Cube, and outputted
12   *  to the log file if the user so requests.
13   */
14 
15  this->SmoothCube();
16  if(this->par.isVerbose()) std::cout << "  ";
17
18  this->setCubeStats();
19
20  if(this->par.isVerbose()) std::cout << "  Searching... " << std::flush;
21 
22  this->objectList = search3DArray(this->axisDim,this->recon,
23                                   this->par,this->Stats);
24
25  if(this->par.isVerbose()) std::cout << "  Updating detection map... "
26                                      << std::flush;
27  this->updateDetectMap();
28  if(this->par.isVerbose()) std::cout << "Done.\n";
29
30  if(this->par.getFlagLog()){
31    if(this->par.isVerbose())
32      std::cout << "  Logging intermediate detections... " << std::flush;
33    this->logDetectionList();
34    if(this->par.isVerbose()) std::cout << "Done.\n";
35  }
36 
37
38}
39
40
41void Cube::SmoothCube()
42{
43  /**
44   *   A function that smooths each spectrum in the cube using the
45   *    Hanning smoothing function. The degree of smoothing is given
46   *    by the parameter hannWidth.
47   */
48
49  Hanning::Hanning hann(this->par.getHanningWidth());
50 
51  long xySize = this->axisDim[0]*this->axisDim[1];
52  long zdim = this->axisDim[2];
53
54  float *spectrum = new float[this->axisDim[2]];
55
56  ProgressBar bar;
57  if(this->par.isVerbose()) {
58    std::cout<<"  Smoothing... ";
59    bar.init(xySize);
60  }
61
62  for(int pix=0;pix<xySize;pix++){
63
64    if( this->par.isVerbose() ) bar.update(pix+1);
65   
66    for(int z=0;z<zdim;z++){
67      if(this->isBlank(z*xySize+pix)) spectrum[z]=0.;
68      else spectrum[z] = this->array[z*xySize+pix];
69    }
70
71    float *smoothed = hann.smooth(spectrum,zdim);
72
73    for(int z=0;z<zdim;z++){
74      if(this->isBlank(z*xySize+pix))
75        this->recon[z*xySize+pix]=this->array[z*xySize+pix];
76      else
77        this->recon[z*xySize+pix] = smoothed[z];
78    }
79    delete [] smoothed;
80  }
81  this->reconExists = true;
82  if(this->par.isVerbose()) bar.fillSpace("All Done.\n");
83
84  delete [] spectrum;
85
86}
87
Note: See TracBrowser for help on using the repository browser.