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> |
---|
19 | using namespace Column; |
---|
20 | using namespace mycpgplot; |
---|
21 | using namespace Statistics; |
---|
22 | |
---|
23 | void 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 | |
---|
39 | void 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 | |
---|
78 | void 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 | |
---|