1 | #include <duchamp/FitsIO/ReadExistingRecon.hh> |
---|
2 | #include <duchamp/duchamp.hh> |
---|
3 | #include <duchamp/Cubes/cubes.hh> |
---|
4 | |
---|
5 | namespace duchamp { |
---|
6 | |
---|
7 | ReadExistingRecon::ReadExistingRecon(): |
---|
8 | ReadExisting() |
---|
9 | { |
---|
10 | } |
---|
11 | |
---|
12 | ReadExistingRecon::ReadExistingRecon(Cube *cube): |
---|
13 | ReadExisting(cube) |
---|
14 | { |
---|
15 | } |
---|
16 | |
---|
17 | ReadExistingRecon::ReadExistingRecon(const ReadExistingRecon &other) |
---|
18 | { |
---|
19 | this->operator=(other); |
---|
20 | } |
---|
21 | |
---|
22 | ReadExistingRecon::ReadExistingRecon(const ReadExisting &base) |
---|
23 | { |
---|
24 | this->operator=(base); |
---|
25 | } |
---|
26 | |
---|
27 | ReadExistingRecon& ReadExistingRecon::operator= (const ReadExistingRecon& other) |
---|
28 | { |
---|
29 | if(this==&other) return *this; |
---|
30 | ((ReadExisting &) *this) = other; |
---|
31 | return *this; |
---|
32 | } |
---|
33 | |
---|
34 | ReadExistingRecon& ReadExistingRecon::operator= (const ReadExisting& base) |
---|
35 | { |
---|
36 | if(this==&base) return *this; |
---|
37 | ((ReadExisting &) *this) = base; |
---|
38 | return *this; |
---|
39 | } |
---|
40 | |
---|
41 | OUTCOME ReadExistingRecon::checkPars() |
---|
42 | { |
---|
43 | if(!this->itsCube->pars().getFlagReconExists()){ |
---|
44 | DUCHAMPWARN("readReconCube", |
---|
45 | "reconExists flag is not set. Not reading anything in!"); |
---|
46 | return FAILURE; |
---|
47 | } |
---|
48 | else if(!this->itsCube->pars().getFlagATrous()){ |
---|
49 | DUCHAMPWARN("readReconCube", |
---|
50 | "flagATrous is not set. Don't need to read in recon array!"); |
---|
51 | return FAILURE; |
---|
52 | } |
---|
53 | return SUCCESS; |
---|
54 | } |
---|
55 | |
---|
56 | OUTCOME ReadExistingRecon::checkFile() |
---|
57 | { |
---|
58 | OUTCOME result=FAILURE; |
---|
59 | int exists,status=0; |
---|
60 | std::string reconFile = this->itsCube->pars().outputReconFile(); |
---|
61 | |
---|
62 | if(this->itsCube->pars().getReconFile() == "") |
---|
63 | DUCHAMPWARN("readReconCube", "ReconFile not specified. Working out name from parameters."); |
---|
64 | |
---|
65 | fits_file_exists(reconFile.c_str(),&exists,&status); |
---|
66 | if(exists<=0){ |
---|
67 | fits_report_error(stderr, status); |
---|
68 | DUCHAMPERROR("readReconCube","ReconFile " << reconFile << " not present."); |
---|
69 | this->itsCube->pars().setFlagReconExists(false); |
---|
70 | result = FAILURE; |
---|
71 | } |
---|
72 | else{ |
---|
73 | result=SUCCESS; |
---|
74 | this->itsCube->pars().setReconFile(reconFile); |
---|
75 | } |
---|
76 | |
---|
77 | this->itsFilename = reconFile; |
---|
78 | return result; |
---|
79 | |
---|
80 | } |
---|
81 | |
---|
82 | OUTCOME ReadExistingRecon::checkHeaders() |
---|
83 | { |
---|
84 | OUTCOME result=SUCCESS; |
---|
85 | if(this->itsFptr==0){ |
---|
86 | DUCHAMPERROR("readReconCube","FITS file not open"); |
---|
87 | result=FAILURE; |
---|
88 | } |
---|
89 | else{ |
---|
90 | unsigned int scaleMin; |
---|
91 | int filterCode,reconDim; |
---|
92 | float snrRecon; |
---|
93 | char *comment = new char[80]; |
---|
94 | int status = 0; |
---|
95 | fits_read_key(this->itsFptr, TINT, (char *)keyword_reconDim.c_str(), |
---|
96 | &reconDim, comment, &status); |
---|
97 | if(reconDim != this->itsCube->pars().getReconDim()){ |
---|
98 | DUCHAMPERROR("readReconCube", "reconDim keyword in reconFile (" << reconDim << ") does not match that requested (" << this->itsCube->pars().getReconDim() << ")."); |
---|
99 | result = FAILURE; |
---|
100 | } |
---|
101 | status = 0; |
---|
102 | fits_read_key(this->itsFptr, TINT, (char *)keyword_filterCode.c_str(), |
---|
103 | &filterCode, comment, &status); |
---|
104 | if(filterCode != this->itsCube->pars().getFilterCode()){ |
---|
105 | DUCHAMPERROR("readReconCube", "filterCode keyword in reconFile (" << filterCode << ") does not match that requested (" << this->itsCube->pars().getFilterCode() << ")."); |
---|
106 | result = FAILURE; |
---|
107 | } |
---|
108 | status = 0; |
---|
109 | fits_read_key(this->itsFptr, TFLOAT, (char *)keyword_snrRecon.c_str(), |
---|
110 | &snrRecon, comment, &status); |
---|
111 | if(snrRecon != this->itsCube->pars().getAtrousCut()){ |
---|
112 | DUCHAMPERROR("readReconCube", "snrRecon keyword in reconFile (" << snrRecon << ") does not match that requested (" << this->itsCube->pars().getAtrousCut() << ")."); |
---|
113 | result = FAILURE; |
---|
114 | } |
---|
115 | status = 0; |
---|
116 | fits_read_key(this->itsFptr, TINT, (char *)keyword_scaleMin.c_str(), |
---|
117 | &scaleMin, comment, &status); |
---|
118 | if(scaleMin != this->itsCube->pars().getMinScale()){ |
---|
119 | DUCHAMPERROR("readReconCube", "scaleMin keyword in reconFile (" << scaleMin << ") does not match that requested (" << this->itsCube->pars().getMinScale() << ")."); |
---|
120 | result = FAILURE; |
---|
121 | } |
---|
122 | |
---|
123 | } |
---|
124 | |
---|
125 | return result; |
---|
126 | |
---|
127 | } |
---|
128 | |
---|
129 | OUTCOME ReadExistingRecon::readFromFile() |
---|
130 | { |
---|
131 | OUTCOME result = this->ReadExisting::readFromFile(); |
---|
132 | if(result == SUCCESS){ |
---|
133 | // We don't want to write out the recon or resid files at the end |
---|
134 | this->itsCube->pars().setFlagOutputRecon(false); |
---|
135 | this->itsCube->pars().setFlagOutputResid(false); |
---|
136 | } |
---|
137 | return result; |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | } |
---|