source: trunk/src/Cubes/cubes_extended.cc @ 326

Last change on this file since 326 was 316, checked in by Matthew Whiting, 17 years ago
  • Centralised the definitions of the various colours used in the graphical output.
  • Removed the function Cube::plotBlankEdges(), replacing it with direct calls to drawBlankEdges, using a defined colour.
File size: 3.8 KB
Line 
1// -----------------------------------------------------------------------
2// cubes_extended.cc: Extra member functions for the Cube class, that
3//                    depend on extra classes.
4// -----------------------------------------------------------------------
5// Copyright (C) 2006, Matthew Whiting, ATNF
6//
7// This program is free software; you can redistribute it and/or modify it
8// under the terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 2 of the License, or (at your
10// option) any later version.
11//
12// Duchamp is distributed in the hope that it will be useful, but WITHOUT
13// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15// for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Duchamp; if not, write to the Free Software Foundation,
19// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
20//
21// Correspondence concerning Duchamp may be directed to:
22//    Internet email: Matthew.Whiting [at] atnf.csiro.au
23//    Postal address: Dr. Matthew Whiting
24//                    Australia Telescope National Facility, CSIRO
25//                    PO Box 76
26//                    Epping NSW 1710
27//                    AUSTRALIA
28// -----------------------------------------------------------------------
29#include <unistd.h>
30#include <iostream>
31#include <iomanip>
32#include <vector>
33#include <algorithm>
34#include <string>
35#include <math.h>
36
37#include <wcs.h>
38
39#include <duchamp.hh>
40#include <param.hh>
41#include <fitsHeader.hh>
42#include <Cubes/cubes.hh>
43#include <Detection/detection.hh>
44#include <Detection/columns.hh>
45#include <Utils/utils.hh>
46#include <Utils/mycpgplot.hh>
47#include <Utils/Statistics.hh>
48using namespace Column;
49using namespace mycpgplot;
50using namespace Statistics;
51
52void Cube::sortDetections()
53{
54  /**
55   *  A front end to the sort-by functions.
56   *  If there is a good WCS, the detection list is sorted by velocity.
57   *  Otherwise, it is sorted by increasing z-pixel value.
58   *  The ID numbers are then re-calculated.
59   */
60 
61  if(this->head.isWCS()) SortByVel(*this->objectList);
62  else SortByZ(*this->objectList);
63  for(int i=0; i<this->objectList->size();i++)
64    this->objectList->at(i).setID(i+1);
65
66}
67//--------------------------------------------------------------------
68
69void Cube::readSavedArrays()
70{
71  /**
72   *  This function reads in reconstructed and/or smoothed arrays that have
73   *   been saved on disk in FITS files.
74   *  To do this it calls the functions Cube::readReconCube() and
75   *   Cube::readSmoothCube().
76   *  The Param set is consulted to determine which of these arrays are needed.
77   */
78
79  // If the reconstructed array is to be read in from disk
80  if( this->par.getFlagReconExists() && this->par.getFlagATrous() ){
81    std::cout << "Reading reconstructed array: "<<std::endl;
82    if( this->readReconCube() == FAILURE){
83      std::stringstream errmsg;
84      errmsg <<"Could not read in existing reconstructed array.\n"
85             <<"Will perform reconstruction using assigned parameters.\n";
86      duchampWarning("Duchamp", errmsg.str());
87      this->par.setFlagReconExists(false);
88    }
89    else std::cout << "Reconstructed array available.\n";
90  }
91
92  if( this->par.getFlagSmoothExists() && this->par.getFlagSmooth() ){
93    std::cout << "Reading smoothed array: "<<std::endl;
94    if( this->readSmoothCube() == FAILURE){
95      std::stringstream errmsg;
96      errmsg <<"Could not read in existing smoothed array.\n"
97             <<"Will smooth the cube using assigned parameters.\n";
98      duchampWarning("Duchamp", errmsg.str());
99      this->par.setFlagSmoothExists(false);
100    }
101    else std::cout << "Smoothed array available.\n";
102  }
103   
104}
105
106//--------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.