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

Last change on this file since 1441 was 224, checked in by Matthew Whiting, 17 years ago
  • Main change is to correct the problem reported in ticket #4, so that the velocity units are correctly dealt with. This entailed:
    • Changing the way wcssptr is called in FitsIO/wcsIO.cc, so that it is called when there is no CUNIT3 keyword, as well as when the type is different to that desired.
    • Changing the way fixUnits() will deal with missing units -- hopefully this will now not occur, and the error message has been changed accordingly.

Other changes include:

  • Making a new file cubes_extended.cc, that has those functions from cubes.cc that require external functions. This enables simpler compilation of test programs.
  • An additional clause in dataIO.cc to set the null value when the BLANK keyword is not present. However, this remains commented out, as I don't think it is necessary at this point, and there is a question about whether it is correct.
  • Other minor typo fixes.
File size: 3.0 KB
Line 
1#include <unistd.h>
2#include <iostream>
3#include <iomanip>
4#include <vector>
5#include <algorithm>
6#include <string>
7#include <math.h>
8
9#include <wcs.h>
10
11#include <duchamp.hh>
12#include <param.hh>
13#include <Cubes/cubes.hh>
14#include <Detection/detection.hh>
15#include <Detection/columns.hh>
16#include <Utils/utils.hh>
17#include <Utils/mycpgplot.hh>
18#include <Utils/Statistics.hh>
19using namespace Column;
20using namespace mycpgplot;
21using namespace Statistics;
22
23void Cube::sortDetections()
24{
25  /**
26   *  A front end to the sort-by functions.
27   *  If there is a good WCS, the detection list is sorted by velocity.
28   *  Otherwise, it is sorted by increasing z-pixel value.
29   *  The ID numbers are then re-calculated.
30   */
31 
32  if(this->head.isWCS()) SortByVel(this->objectList);
33  else SortByZ(this->objectList);
34  for(int i=0; i<this->objectList.size();i++) this->objectList[i].setID(i+1);
35
36}
37//--------------------------------------------------------------------
38
39void Cube::readSavedArrays()
40{
41  /**
42   *  This function reads in reconstructed and/or smoothed arrays that have
43   *   been saved on disk in FITS files.
44   *  To do this it calls the functions Cube::readReconCube() and
45   *   Cube::readSmoothCube().
46   *  The Param set is consulted to determine which of these arrays are needed.
47   */
48
49  // If the reconstructed array is to be read in from disk
50  if( this->par.getFlagReconExists() && this->par.getFlagATrous() ){
51    std::cout << "Reading reconstructed array: "<<std::endl;
52    if( this->readReconCube() == FAILURE){
53      std::stringstream errmsg;
54      errmsg <<"Could not read in existing reconstructed array.\n"
55             <<"Will perform reconstruction using assigned parameters.\n";
56      duchampWarning("Duchamp", errmsg.str());
57      this->par.setFlagReconExists(false);
58    }
59    else std::cout << "Reconstructed array available.\n";
60  }
61
62  if( this->par.getFlagSmoothExists() && this->par.getFlagSmooth() ){
63    std::cout << "Reading Hanning-smoothed array: "<<std::endl;
64    if( this->readSmoothCube() == FAILURE){
65      std::stringstream errmsg;
66      errmsg <<"Could not read in existing smoothed array.\n"
67             <<"Will smooth the cube using assigned parameters.\n";
68      duchampWarning("Duchamp", errmsg.str());
69      this->par.setFlagSmoothExists(false);
70    }
71    else std::cout << "Smoothed array available.\n";
72  }
73   
74}
75
76//--------------------------------------------------------------------
77
78void Cube::plotBlankEdges()
79{
80  /**
81   *  A front end to the drawBlankEdges() function. This draws the lines
82   *   indicating the extent of the non-BLANK region of the cube in the
83   *   PGPLOT colour MAGENTA (from the namespace mycpgplot), using the Cube's
84   *   arrays and dimensions.
85   *
86   *  Note that a PGPLOT device needs to be open. This is only done if the
87   *   appropriate Param parameter is set.
88   */
89  if(this->par.drawBlankEdge()){
90    int colour;
91    cpgqci(&colour);
92    cpgsci(MAGENTA);
93    drawBlankEdges(this->array,this->axisDim[0],this->axisDim[1],this->par);
94    cpgsci(colour);
95  }
96}
97//--------------------------------------------------------------------
98
Note: See TracBrowser for help on using the repository browser.