1 | #include <iostream> |
---|
2 | #include <iomanip> |
---|
3 | #include <fstream> |
---|
4 | #include <sstream> |
---|
5 | #include <string> |
---|
6 | #include <math.h> |
---|
7 | #include <wcs.h> |
---|
8 | #include <wcsunits.h> |
---|
9 | #include <param.hh> |
---|
10 | #include <config.h> |
---|
11 | #include <duchamp.hh> |
---|
12 | #include <Utils/utils.hh> |
---|
13 | |
---|
14 | // Define funtion to print bools as words, in case the compiler doesn't |
---|
15 | // recognise the setf(ios::boolalpha) command... |
---|
16 | #ifdef HAVE_STDBOOL_H |
---|
17 | string stringize(bool b){ |
---|
18 | std::stringstream ss; |
---|
19 | ss.setf(std::ios::boolalpha); |
---|
20 | ss << b; |
---|
21 | return ss.str(); |
---|
22 | } |
---|
23 | #else |
---|
24 | string stringize(bool b){ |
---|
25 | std::string output; |
---|
26 | if(b) output="true"; |
---|
27 | else output="false"; |
---|
28 | return output; |
---|
29 | } |
---|
30 | #endif |
---|
31 | |
---|
32 | using std::setw; |
---|
33 | using std::endl; |
---|
34 | |
---|
35 | /****************************************************************/ |
---|
36 | /////////////////////////////////////////////////// |
---|
37 | //// Functions for FitsHeader class: |
---|
38 | /////////////////////////////////////////////////// |
---|
39 | |
---|
40 | FitsHeader::FitsHeader() |
---|
41 | { |
---|
42 | this->wcs = (struct wcsprm *)malloc(sizeof(struct wcsprm)); |
---|
43 | this->wcs->flag=-1; |
---|
44 | wcsini(true, 3, this->wcs); |
---|
45 | this->wcsIsGood = false; |
---|
46 | this->nwcs = 0; |
---|
47 | this->scale=1.; |
---|
48 | this->offset=0.; |
---|
49 | this->power=1.; |
---|
50 | this->fluxUnits="counts"; |
---|
51 | } |
---|
52 | |
---|
53 | FitsHeader::FitsHeader(const FitsHeader& h) |
---|
54 | { |
---|
55 | this->wcs = (struct wcsprm *)malloc(sizeof(struct wcsprm)); |
---|
56 | this->wcs->flag=-1; |
---|
57 | wcsini(true, h.wcs->naxis, this->wcs); |
---|
58 | wcscopy(true, h.wcs, this->wcs); |
---|
59 | wcsset(this->wcs); |
---|
60 | this->nwcs = h.nwcs; |
---|
61 | this->wcsIsGood = h.wcsIsGood; |
---|
62 | this->spectralUnits = h.spectralUnits; |
---|
63 | this->fluxUnits = h.fluxUnits; |
---|
64 | this->intFluxUnits = h.intFluxUnits; |
---|
65 | this->beamSize = h.beamSize; |
---|
66 | this->bmajKeyword = h.bmajKeyword; |
---|
67 | this->bminKeyword = h.bminKeyword; |
---|
68 | this->blankKeyword = h.blankKeyword; |
---|
69 | this->bzeroKeyword = h.bzeroKeyword; |
---|
70 | this->bscaleKeyword = h.bscaleKeyword; |
---|
71 | this->scale = h.scale; |
---|
72 | this->offset = h.offset; |
---|
73 | this->power = h.power; |
---|
74 | } |
---|
75 | |
---|
76 | FitsHeader& FitsHeader::operator= (const FitsHeader& h) |
---|
77 | { |
---|
78 | this->wcs = (struct wcsprm *)malloc(sizeof(struct wcsprm)); |
---|
79 | this->wcs->flag=-1; |
---|
80 | wcsini(true, h.wcs->naxis, this->wcs); |
---|
81 | wcscopy(true, h.wcs, this->wcs); |
---|
82 | wcsset(this->wcs); |
---|
83 | this->nwcs = h.nwcs; |
---|
84 | this->wcsIsGood = h.wcsIsGood; |
---|
85 | this->spectralUnits = h.spectralUnits; |
---|
86 | this->fluxUnits = h.fluxUnits; |
---|
87 | this->intFluxUnits = h.intFluxUnits; |
---|
88 | this->beamSize = h.beamSize; |
---|
89 | this->bmajKeyword = h.bmajKeyword; |
---|
90 | this->bminKeyword = h.bminKeyword; |
---|
91 | this->blankKeyword = h.blankKeyword; |
---|
92 | this->bzeroKeyword = h.bzeroKeyword; |
---|
93 | this->bscaleKeyword = h.bscaleKeyword; |
---|
94 | this->scale = h.scale; |
---|
95 | this->offset = h.offset; |
---|
96 | this->power = h.power; |
---|
97 | } |
---|
98 | |
---|
99 | void FitsHeader::setWCS(struct wcsprm *w) |
---|
100 | { |
---|
101 | /** |
---|
102 | * FitsHeader::setWCS(struct wcsprm) |
---|
103 | * A function that assigns the wcs parameters, and runs |
---|
104 | * wcsset to set it up correctly. |
---|
105 | * Performs a check to see if the WCS is good (by looking at |
---|
106 | * the lng and lat wcsprm parameters), and sets the wcsIsGood |
---|
107 | * flag accordingly. |
---|
108 | */ |
---|
109 | wcscopy(true, w, this->wcs); |
---|
110 | wcsset(this->wcs); |
---|
111 | if( (w->lng!=-1) && (w->lat!=-1) ) this->wcsIsGood = true; |
---|
112 | } |
---|
113 | |
---|
114 | struct wcsprm *FitsHeader::getWCS() |
---|
115 | { |
---|
116 | /** |
---|
117 | * FitsHeader::getWCS() |
---|
118 | * A function that returns a wcsprm object corresponding to the WCS. |
---|
119 | */ |
---|
120 | struct wcsprm *wNew = (struct wcsprm *)malloc(sizeof(struct wcsprm)); |
---|
121 | wNew->flag=-1; |
---|
122 | wcsini(true, this->wcs->naxis, wNew); |
---|
123 | wcscopy(true, this->wcs, wNew); |
---|
124 | wcsset(wNew); |
---|
125 | return wNew; |
---|
126 | } |
---|
127 | |
---|
128 | int FitsHeader::wcsToPix(const double *world, double *pix){ |
---|
129 | return wcsToPixSingle(this->wcs, world, pix);} |
---|
130 | int FitsHeader::wcsToPix(const double *world, double *pix, const int npts){ |
---|
131 | return wcsToPixMulti(this->wcs, world, pix, npts);} |
---|
132 | int FitsHeader::pixToWCS(const double *pix, double *world){ |
---|
133 | return pixToWCSSingle(this->wcs, pix, world);} |
---|
134 | int FitsHeader::pixToWCS(const double *pix, double *world, const int npts){ |
---|
135 | return pixToWCSMulti(this->wcs, pix,world, npts);} |
---|
136 | |
---|
137 | double FitsHeader::pixToVel(double &x, double &y, double &z) |
---|
138 | { |
---|
139 | double vel; |
---|
140 | if(this->wcsIsGood){ |
---|
141 | double *pix = new double[3]; |
---|
142 | double *world = new double[3]; |
---|
143 | pix[0] = x; pix[1] = y; pix[2] = z; |
---|
144 | pixToWCSSingle(this->wcs,pix,world); |
---|
145 | vel = this->specToVel(world[2]); |
---|
146 | delete [] pix; |
---|
147 | delete [] world; |
---|
148 | } |
---|
149 | else vel = z; |
---|
150 | return vel; |
---|
151 | } |
---|
152 | |
---|
153 | double* FitsHeader::pixToVel(double &x, double &y, double *zarray, int size) |
---|
154 | { |
---|
155 | double *newzarray = new double[size]; |
---|
156 | if(this->wcsIsGood){ |
---|
157 | double *pix = new double[size*3]; |
---|
158 | for(int i=0;i<size;i++){ |
---|
159 | pix[3*i] = x; |
---|
160 | pix[3*i+1] = y; |
---|
161 | pix[3*i+2] = zarray[i]; |
---|
162 | } |
---|
163 | double *world = new double[size*3]; |
---|
164 | pixToWCSMulti(this->wcs,pix,world,size); |
---|
165 | delete [] pix; |
---|
166 | for(int i=0;i<size;i++) newzarray[i] = this->specToVel(world[3*i+2]); |
---|
167 | delete [] world; |
---|
168 | } |
---|
169 | else{ |
---|
170 | for(int i=0;i<size;i++) newzarray[i] = zarray[i]; |
---|
171 | } |
---|
172 | return newzarray; |
---|
173 | } |
---|
174 | |
---|
175 | double FitsHeader::specToVel(const double &coord) |
---|
176 | { |
---|
177 | double vel; |
---|
178 | if(power==1.0) vel = coord*this->scale + this->offset; |
---|
179 | else vel = pow( (coord*this->scale + this->offset), this->power); |
---|
180 | return vel; |
---|
181 | } |
---|
182 | |
---|
183 | double FitsHeader::velToSpec(const float &velocity) |
---|
184 | { |
---|
185 | // return velToCoord(this->wcs,velocity,this->spectralUnits);}; |
---|
186 | return (pow(velocity, 1./this->power) - this->offset) / this->scale;} |
---|
187 | |
---|
188 | string FitsHeader::getIAUName(double ra, double dec) |
---|
189 | { |
---|
190 | if(strcmp(this->wcs->lngtyp,"RA")==0) |
---|
191 | return getIAUNameEQ(ra, dec, this->wcs->equinox); |
---|
192 | else |
---|
193 | return getIAUNameGAL(ra, dec); |
---|
194 | } |
---|
195 | |
---|
196 | void FitsHeader::fixUnits(Param &par) |
---|
197 | { |
---|
198 | // define spectral units from the param set |
---|
199 | this->spectralUnits = par.getSpectralUnits(); |
---|
200 | |
---|
201 | double sc=1.; |
---|
202 | double of=0.; |
---|
203 | double po=1.;; |
---|
204 | if(this->wcsIsGood){ |
---|
205 | int flag = wcsunits( this->wcs->cunit[this->wcs->spec], |
---|
206 | this->spectralUnits.c_str(), |
---|
207 | &sc, &of, &po); |
---|
208 | if(flag>0){ |
---|
209 | std::stringstream errmsg; |
---|
210 | errmsg << "WCSUNITS Error, Code = " << flag |
---|
211 | << ": "<< wcsunits_errmsg[flag]; |
---|
212 | if(flag==10) errmsg << "\nTried to get conversion from '" |
---|
213 | << this->wcs->cunit[this->wcs->spec] << "' to '" |
---|
214 | << this->spectralUnits.c_str() << "'\n"; |
---|
215 | this->spectralUnits = this->wcs->cunit[this->wcs->spec]; |
---|
216 | if(this->spectralUnits==""){ |
---|
217 | errmsg << |
---|
218 | "Spectral units not specified. Setting them to 'XX' for clarity.\n"; |
---|
219 | this->spectralUnits = "XX"; |
---|
220 | } |
---|
221 | duchampError("fixUnits", errmsg.str()); |
---|
222 | |
---|
223 | } |
---|
224 | } |
---|
225 | this->scale = sc; |
---|
226 | this->offset= of; |
---|
227 | this->power = po; |
---|
228 | |
---|
229 | // Work out the integrated flux units, based on the spectral units. |
---|
230 | // If flux is per beam, trim the /beam from the flux units and multiply |
---|
231 | // by the spectral units. |
---|
232 | // Otherwise, just muliply by the spectral units. |
---|
233 | if(this->fluxUnits.size()>0){ |
---|
234 | if(this->fluxUnits.substr(this->fluxUnits.size()-5, |
---|
235 | this->fluxUnits.size() ) == "/beam"){ |
---|
236 | this->intFluxUnits = this->fluxUnits.substr(0,this->fluxUnits.size()-5) |
---|
237 | +" " +this->spectralUnits; |
---|
238 | } |
---|
239 | else this->intFluxUnits = this->fluxUnits + " " + this->spectralUnits; |
---|
240 | } |
---|
241 | |
---|
242 | } |
---|
243 | |
---|
244 | /****************************************************************/ |
---|
245 | /////////////////////////////////////////////////// |
---|
246 | //// Accessor Functions for Parameter class: |
---|
247 | /////////////////////////////////////////////////// |
---|
248 | Param::Param(){ |
---|
249 | /** |
---|
250 | * Param() |
---|
251 | * Default intial values for the parameters. |
---|
252 | * imageFile has no default value! |
---|
253 | */ |
---|
254 | // Input files |
---|
255 | this->imageFile = ""; |
---|
256 | this->flagSubsection = false; |
---|
257 | this->subsection = "[*,*,*]"; |
---|
258 | this->flagReconExists = false; |
---|
259 | this->reconFile = ""; |
---|
260 | // Output files |
---|
261 | this->flagLog = true; |
---|
262 | this->logFile = "duchamp-Logfile.txt"; |
---|
263 | this->outFile = "duchamp-Results.txt"; |
---|
264 | this->spectraFile = "duchamp-Spectra.ps"; |
---|
265 | this->flagOutputRecon = false; |
---|
266 | this->flagOutputResid = false; |
---|
267 | this->flagVOT = false; |
---|
268 | this->votFile = "duchamp-Results.xml"; |
---|
269 | this->flagKarma = false; |
---|
270 | this->karmaFile = "duchamp-Results.ann"; |
---|
271 | this->flagMaps = true; |
---|
272 | this->detectionMap = "duchamp-DetectionMap.ps"; |
---|
273 | this->momentMap = "duchamp-MomentMap.ps"; |
---|
274 | this->flagXOutput = true; |
---|
275 | // Cube related parameters |
---|
276 | this->flagBlankPix = true; |
---|
277 | this->blankPixValue = -8.00061; |
---|
278 | this->blankKeyword = 1; |
---|
279 | this->bscaleKeyword = -8.00061; |
---|
280 | this->bzeroKeyword = 0.; |
---|
281 | this->flagUsingBlank = false; |
---|
282 | this->flagMW = false; |
---|
283 | this->maxMW = 112; |
---|
284 | this->minMW = 75; |
---|
285 | this->numPixBeam = 10.; |
---|
286 | this->flagUsingBeam = false; |
---|
287 | // Trim-related |
---|
288 | this->flagTrimmed = false; |
---|
289 | this->borderLeft = 0; |
---|
290 | this->borderRight = 0; |
---|
291 | this->borderBottom = 0; |
---|
292 | this->borderTop = 0; |
---|
293 | // Subsection offsets |
---|
294 | this->sizeOffsets = 0; |
---|
295 | this->xSubOffset = 0; |
---|
296 | this->ySubOffset = 0; |
---|
297 | this->zSubOffset = 0; |
---|
298 | // Baseline related |
---|
299 | this->flagBaseline = false; |
---|
300 | // Detection-related |
---|
301 | this->flagNegative = false; |
---|
302 | // Object growth |
---|
303 | this->flagGrowth = false; |
---|
304 | this->growthCut = 2.; |
---|
305 | // FDR analysis |
---|
306 | this->flagFDR = false; |
---|
307 | this->alphaFDR = 0.01; |
---|
308 | // Other detection |
---|
309 | this->snrCut = 3.; |
---|
310 | this->threshold = 0.; |
---|
311 | this->flagUserThreshold = false; |
---|
312 | // Hanning Smoothing |
---|
313 | this->flagSmooth = false; |
---|
314 | this->hanningWidth = 5; |
---|
315 | // A trous reconstruction parameters |
---|
316 | this->flagATrous = true; |
---|
317 | this->reconDim = 3; |
---|
318 | this->scaleMin = 1; |
---|
319 | this->snrRecon = 4.; |
---|
320 | this->filterCode = 1; |
---|
321 | // Volume-merging parameters |
---|
322 | this->flagAdjacent = true; |
---|
323 | this->threshSpatial = 3.; |
---|
324 | this->threshVelocity = 7.; |
---|
325 | this->minChannels = 3; |
---|
326 | this->minPix = 2; |
---|
327 | // Input-Output related |
---|
328 | this->spectralMethod = "peak"; |
---|
329 | this->borders = true; |
---|
330 | this->blankEdge = true; |
---|
331 | this->verbose = true; |
---|
332 | this->spectralUnits = "km/s"; |
---|
333 | }; |
---|
334 | |
---|
335 | Param::Param (const Param& p) |
---|
336 | { |
---|
337 | this->imageFile = p.imageFile; |
---|
338 | this->flagSubsection = p.flagSubsection; |
---|
339 | this->subsection = p.subsection; |
---|
340 | this->flagReconExists = p.flagReconExists; |
---|
341 | this->reconFile = p.reconFile; |
---|
342 | this->flagLog = p.flagLog; |
---|
343 | this->logFile = p.logFile; |
---|
344 | this->outFile = p.outFile; |
---|
345 | this->spectraFile = p.spectraFile; |
---|
346 | this->flagOutputRecon = p.flagOutputRecon; |
---|
347 | this->flagOutputResid = p.flagOutputResid; |
---|
348 | this->flagVOT = p.flagVOT; |
---|
349 | this->votFile = p.votFile; |
---|
350 | this->flagKarma = p.flagKarma; |
---|
351 | this->karmaFile = p.karmaFile; |
---|
352 | this->flagMaps = p.flagMaps; |
---|
353 | this->detectionMap = p.detectionMap; |
---|
354 | this->momentMap = p.momentMap; |
---|
355 | this->flagXOutput = p.flagXOutput; |
---|
356 | this->flagBlankPix = p.flagBlankPix; |
---|
357 | this->blankPixValue = p.blankPixValue; |
---|
358 | this->blankKeyword = p.blankKeyword; |
---|
359 | this->bscaleKeyword = p.bscaleKeyword; |
---|
360 | this->bzeroKeyword = p.bzeroKeyword; |
---|
361 | this->flagUsingBlank = p.flagUsingBlank; |
---|
362 | this->flagMW = p.flagMW; |
---|
363 | this->maxMW = p.maxMW; |
---|
364 | this->minMW = p.minMW; |
---|
365 | this->numPixBeam = p.numPixBeam; |
---|
366 | this->flagTrimmed = p.flagTrimmed; |
---|
367 | this->borderLeft = p.borderLeft; |
---|
368 | this->borderRight = p.borderRight; |
---|
369 | this->borderBottom = p.borderBottom; |
---|
370 | this->borderTop = p.borderTop; |
---|
371 | this->sizeOffsets = p.sizeOffsets; |
---|
372 | if(this->sizeOffsets>0) |
---|
373 | for(int i=0;i<this->sizeOffsets;i++) this->offsets[i] = p.offsets[i]; |
---|
374 | this->xSubOffset = p.xSubOffset; |
---|
375 | this->ySubOffset = p.ySubOffset; |
---|
376 | this->zSubOffset = p.zSubOffset; |
---|
377 | this->flagBaseline = p.flagBaseline; |
---|
378 | this->flagNegative = p.flagNegative; |
---|
379 | this->flagGrowth = p.flagGrowth; |
---|
380 | this->growthCut = p.growthCut; |
---|
381 | this->flagFDR = p.flagFDR; |
---|
382 | this->alphaFDR = p.alphaFDR; |
---|
383 | this->snrCut = p.snrCut; |
---|
384 | this->threshold = p.threshold; |
---|
385 | this->flagUserThreshold = p.threshold; |
---|
386 | this->flagSmooth = p.flagSmooth; |
---|
387 | this->hanningWidth = p.hanningWidth; |
---|
388 | this->flagATrous = p.flagATrous; |
---|
389 | this->reconDim = p.reconDim; |
---|
390 | this->scaleMin = p.scaleMin; |
---|
391 | this->snrRecon = p.snrRecon; |
---|
392 | this->filterCode = p.filterCode; |
---|
393 | this->flagAdjacent = p.flagAdjacent; |
---|
394 | this->threshSpatial = p.threshSpatial; |
---|
395 | this->threshVelocity = p.threshVelocity; |
---|
396 | this->minChannels = p.minChannels; |
---|
397 | this->minPix = p.minPix; |
---|
398 | this->spectralMethod = p.spectralMethod; |
---|
399 | this->borders = p.borders; |
---|
400 | this->verbose = p.verbose; |
---|
401 | this->spectralUnits = p.spectralUnits; |
---|
402 | } |
---|
403 | |
---|
404 | Param& Param::operator= (const Param& p) |
---|
405 | { |
---|
406 | this->imageFile = p.imageFile; |
---|
407 | this->flagSubsection = p.flagSubsection; |
---|
408 | this->subsection = p.subsection; |
---|
409 | this->flagReconExists = p.flagReconExists; |
---|
410 | this->reconFile = p.reconFile; |
---|
411 | this->flagLog = p.flagLog; |
---|
412 | this->logFile = p.logFile; |
---|
413 | this->outFile = p.outFile; |
---|
414 | this->spectraFile = p.spectraFile; |
---|
415 | this->flagOutputRecon = p.flagOutputRecon; |
---|
416 | this->flagOutputResid = p.flagOutputResid; |
---|
417 | this->flagVOT = p.flagVOT; |
---|
418 | this->votFile = p.votFile; |
---|
419 | this->flagKarma = p.flagKarma; |
---|
420 | this->karmaFile = p.karmaFile; |
---|
421 | this->flagMaps = p.flagMaps; |
---|
422 | this->detectionMap = p.detectionMap; |
---|
423 | this->momentMap = p.momentMap; |
---|
424 | this->flagXOutput = p.flagXOutput; |
---|
425 | this->flagBlankPix = p.flagBlankPix; |
---|
426 | this->blankPixValue = p.blankPixValue; |
---|
427 | this->blankKeyword = p.blankKeyword; |
---|
428 | this->bscaleKeyword = p.bscaleKeyword; |
---|
429 | this->bzeroKeyword = p.bzeroKeyword; |
---|
430 | this->flagUsingBlank = p.flagUsingBlank; |
---|
431 | this->flagMW = p.flagMW; |
---|
432 | this->maxMW = p.maxMW; |
---|
433 | this->minMW = p.minMW; |
---|
434 | this->numPixBeam = p.numPixBeam; |
---|
435 | this->flagTrimmed = p.flagTrimmed; |
---|
436 | this->borderLeft = p.borderLeft; |
---|
437 | this->borderRight = p.borderRight; |
---|
438 | this->borderBottom = p.borderBottom; |
---|
439 | this->borderTop = p.borderTop; |
---|
440 | this->sizeOffsets = p.sizeOffsets; |
---|
441 | if(this->sizeOffsets>0) |
---|
442 | for(int i=0;i<this->sizeOffsets;i++) this->offsets[i] = p.offsets[i]; |
---|
443 | this->xSubOffset = p.xSubOffset; |
---|
444 | this->ySubOffset = p.ySubOffset; |
---|
445 | this->zSubOffset = p.zSubOffset; |
---|
446 | this->flagBaseline = p.flagBaseline; |
---|
447 | this->flagNegative = p.flagNegative; |
---|
448 | this->flagGrowth = p.flagGrowth; |
---|
449 | this->growthCut = p.growthCut; |
---|
450 | this->flagFDR = p.flagFDR; |
---|
451 | this->alphaFDR = p.alphaFDR; |
---|
452 | this->snrCut = p.snrCut; |
---|
453 | this->threshold = p.threshold; |
---|
454 | this->flagUserThreshold = p.threshold; |
---|
455 | this->flagSmooth = p.flagSmooth; |
---|
456 | this->hanningWidth = p.hanningWidth; |
---|
457 | this->flagATrous = p.flagATrous; |
---|
458 | this->reconDim = p.reconDim; |
---|
459 | this->scaleMin = p.scaleMin; |
---|
460 | this->snrRecon = p.snrRecon; |
---|
461 | this->filterCode = p.filterCode; |
---|
462 | this->flagAdjacent = p.flagAdjacent; |
---|
463 | this->threshSpatial = p.threshSpatial; |
---|
464 | this->threshVelocity = p.threshVelocity; |
---|
465 | this->minChannels = p.minChannels; |
---|
466 | this->minPix = p.minPix; |
---|
467 | this->spectralMethod = p.spectralMethod; |
---|
468 | this->borders = p.borders; |
---|
469 | this->verbose = p.verbose; |
---|
470 | this->spectralUnits = p.spectralUnits; |
---|
471 | } |
---|
472 | |
---|
473 | /****************************************************************/ |
---|
474 | /////////////////////////////////////////////////// |
---|
475 | //// Other Functions using the Parameter class: |
---|
476 | /////////////////////////////////////////////////// |
---|
477 | |
---|
478 | inline string makelower( string s ) |
---|
479 | { |
---|
480 | // "borrowed" from Matt Howlett's 'fred' |
---|
481 | string out = ""; |
---|
482 | for( int i=0; i<s.size(); ++i ) { |
---|
483 | out += tolower(s[i]); |
---|
484 | } |
---|
485 | return out; |
---|
486 | } |
---|
487 | |
---|
488 | inline bool boolify( string s ) |
---|
489 | { |
---|
490 | /** |
---|
491 | * bool boolify(string) |
---|
492 | * Convert a string to a bool variable |
---|
493 | * "1" and "true" get converted to true |
---|
494 | * "0" and "false" (and anything else) get converted to false |
---|
495 | */ |
---|
496 | if((s=="1") || (makelower(s)=="true")) return true; |
---|
497 | else if((s=="0") || (makelower(s)=="false")) return false; |
---|
498 | else return false; |
---|
499 | } |
---|
500 | |
---|
501 | inline string readSval(std::stringstream& ss) |
---|
502 | { |
---|
503 | string val; ss >> val; return val; |
---|
504 | } |
---|
505 | |
---|
506 | inline bool readFlag(std::stringstream& ss) |
---|
507 | { |
---|
508 | string val; ss >> val; return boolify(val); |
---|
509 | } |
---|
510 | |
---|
511 | inline float readFval(std::stringstream& ss) |
---|
512 | { |
---|
513 | float val; ss >> val; return val; |
---|
514 | } |
---|
515 | |
---|
516 | inline int readIval(std::stringstream& ss) |
---|
517 | { |
---|
518 | int val; ss >> val; return val; |
---|
519 | } |
---|
520 | |
---|
521 | int Param::readParams(string paramfile) |
---|
522 | { |
---|
523 | |
---|
524 | std::ifstream fin(paramfile.c_str()); |
---|
525 | if(!fin.is_open()) return FAILURE; |
---|
526 | string line; |
---|
527 | while( !std::getline(fin,line,'\n').eof()){ |
---|
528 | |
---|
529 | if(line[0]!='#'){ |
---|
530 | std::stringstream ss; |
---|
531 | ss.str(line); |
---|
532 | string arg; |
---|
533 | ss >> arg; |
---|
534 | arg = makelower(arg); |
---|
535 | if(arg=="imagefile") this->imageFile = readSval(ss); |
---|
536 | if(arg=="flagsubsection") this->flagSubsection = readFlag(ss); |
---|
537 | if(arg=="subsection") this->subsection = readSval(ss); |
---|
538 | if(arg=="flagreconexists") this->flagReconExists = readFlag(ss); |
---|
539 | if(arg=="reconfile") this->reconFile = readSval(ss); |
---|
540 | |
---|
541 | if(arg=="flaglog") this->flagLog = readFlag(ss); |
---|
542 | if(arg=="logfile") this->logFile = readSval(ss); |
---|
543 | if(arg=="outfile") this->outFile = readSval(ss); |
---|
544 | if(arg=="spectrafile") this->spectraFile = readSval(ss); |
---|
545 | if(arg=="flagoutputrecon") this->flagOutputRecon = readFlag(ss); |
---|
546 | if(arg=="flagoutputresid") this->flagOutputResid = readFlag(ss); |
---|
547 | if(arg=="flagvot") this->flagVOT = readFlag(ss); |
---|
548 | if(arg=="votfile") this->votFile = readSval(ss); |
---|
549 | if(arg=="flagkarma") this->flagKarma = readFlag(ss); |
---|
550 | if(arg=="karmafile") this->karmaFile = readSval(ss); |
---|
551 | if(arg=="flagmaps") this->flagMaps = readFlag(ss); |
---|
552 | if(arg=="detectionmap") this->detectionMap = readSval(ss); |
---|
553 | if(arg=="momentmap") this->momentMap = readSval(ss); |
---|
554 | if(arg=="flagxoutput") this->flagXOutput = readFlag(ss); |
---|
555 | |
---|
556 | if(arg=="flagnegative") this->flagNegative = readFlag(ss); |
---|
557 | if(arg=="flagblankpix") this->flagBlankPix = readFlag(ss); |
---|
558 | if(arg=="blankpixvalue") this->blankPixValue = readFval(ss); |
---|
559 | if(arg=="flagmw") this->flagMW = readFlag(ss); |
---|
560 | if(arg=="maxmw") this->maxMW = readIval(ss); |
---|
561 | if(arg=="minmw") this->minMW = readIval(ss); |
---|
562 | if(arg=="beamsize") this->numPixBeam = readFval(ss); |
---|
563 | |
---|
564 | if(arg=="flagbaseline") this->flagBaseline = readFlag(ss); |
---|
565 | if(arg=="minpix") this->minPix = readIval(ss); |
---|
566 | if(arg=="flaggrowth") this->flagGrowth = readFlag(ss); |
---|
567 | if(arg=="growthcut") this->growthCut = readFval(ss); |
---|
568 | |
---|
569 | if(arg=="flagfdr") this->flagFDR = readFlag(ss); |
---|
570 | if(arg=="alphafdr") this->alphaFDR = readFval(ss); |
---|
571 | |
---|
572 | if(arg=="snrcut") this->snrCut = readFval(ss); |
---|
573 | if(arg=="threshold"){ |
---|
574 | this->threshold = readFval(ss); |
---|
575 | this->flagUserThreshold = true; |
---|
576 | } |
---|
577 | |
---|
578 | if(arg=="flagsmooth") this->flagSmooth = readFlag(ss); |
---|
579 | if(arg=="hanningwidth") this->hanningWidth = readIval(ss); |
---|
580 | |
---|
581 | if(arg=="flagatrous") this->flagATrous = readFlag(ss); |
---|
582 | if(arg=="recondim") this->reconDim = readIval(ss); |
---|
583 | if(arg=="scalemin") this->scaleMin = readIval(ss); |
---|
584 | if(arg=="snrrecon") this->snrRecon = readFval(ss); |
---|
585 | if(arg=="filtercode") this->filterCode = readIval(ss); |
---|
586 | |
---|
587 | if(arg=="flagadjacent") this->flagAdjacent = readFlag(ss); |
---|
588 | if(arg=="threshspatial") this->threshSpatial = readFval(ss); |
---|
589 | if(arg=="threshvelocity") this->threshVelocity = readFval(ss); |
---|
590 | if(arg=="minchannels") this->minChannels = readIval(ss); |
---|
591 | |
---|
592 | if(arg=="spectralmethod") this->spectralMethod=makelower(readSval(ss)); |
---|
593 | if(arg=="spectralunits") this->spectralUnits=makelower(readSval(ss)); |
---|
594 | if(arg=="drawborders") this->borders = readFlag(ss); |
---|
595 | if(arg=="drawblankedges") this->blankEdge = readFlag(ss); |
---|
596 | if(arg=="verbose") this->verbose = readFlag(ss); |
---|
597 | } |
---|
598 | } |
---|
599 | if(this->flagSmooth) this->flagATrous = false; |
---|
600 | return SUCCESS; |
---|
601 | } |
---|
602 | |
---|
603 | |
---|
604 | std::ostream& operator<< ( std::ostream& theStream, Param& par) |
---|
605 | { |
---|
606 | // Only show the [blankPixValue] bit if we are using the parameter |
---|
607 | // otherwise we have read it from the FITS header. |
---|
608 | string blankParam = ""; |
---|
609 | if(par.getFlagUsingBlank()) blankParam = "[blankPixValue]"; |
---|
610 | string beamParam = ""; |
---|
611 | if(par.getFlagUsingBeam()) beamParam = "[beamSize]"; |
---|
612 | |
---|
613 | // BUG -- can get error: `boolalpha' is not a member of type `ios' -- old compilers: gcc 2.95.3? |
---|
614 | // theStream.setf(std::ios::boolalpha); |
---|
615 | theStream.setf(std::ios::left); |
---|
616 | theStream <<"---- Parameters ----"<<endl; |
---|
617 | theStream << std::setfill('.'); |
---|
618 | const int widthText = 38; |
---|
619 | const int widthPar = 18; |
---|
620 | if(par.getFlagSubsection()) |
---|
621 | theStream<<setw(widthText)<<"Image to be analysed" |
---|
622 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]" |
---|
623 | <<" = " <<resetiosflags(std::ios::right) |
---|
624 | <<(par.getImageFile()+par.getSubsection()) <<endl; |
---|
625 | else |
---|
626 | theStream<<setw(widthText)<<"Image to be analysed" |
---|
627 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]" |
---|
628 | <<" = " <<resetiosflags(std::ios::right) |
---|
629 | <<par.getImageFile() <<endl; |
---|
630 | if(par.getFlagReconExists() && par.getFlagATrous()){ |
---|
631 | theStream<<setw(widthText)<<"Reconstructed array exists?" |
---|
632 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[reconExists]" |
---|
633 | <<" = " <<resetiosflags(std::ios::right) |
---|
634 | <<stringize(par.getFlagReconExists())<<endl; |
---|
635 | theStream<<setw(widthText)<<"FITS file containing reconstruction" |
---|
636 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[reconFile]" |
---|
637 | <<" = " <<resetiosflags(std::ios::right) |
---|
638 | <<par.getReconFile() <<endl; |
---|
639 | } |
---|
640 | theStream <<setw(widthText)<<"Intermediate Logfile" |
---|
641 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[logFile]" |
---|
642 | <<" = " <<resetiosflags(std::ios::right) |
---|
643 | <<par.getLogFile() <<endl; |
---|
644 | theStream <<setw(widthText)<<"Final Results file" |
---|
645 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[outFile]" |
---|
646 | <<" = " <<resetiosflags(std::ios::right) |
---|
647 | <<par.getOutFile() <<endl; |
---|
648 | theStream <<setw(widthText)<<"Spectrum file" |
---|
649 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[spectraFile]" |
---|
650 | <<" = " <<resetiosflags(std::ios::right) |
---|
651 | <<par.getSpectraFile() <<endl; |
---|
652 | if(par.getFlagVOT()){ |
---|
653 | theStream<<setw(widthText)<<"VOTable file" |
---|
654 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[votFile]" |
---|
655 | <<" = " <<resetiosflags(std::ios::right) |
---|
656 | <<par.getVOTFile() <<endl; |
---|
657 | } |
---|
658 | if(par.getFlagKarma()){ |
---|
659 | theStream<<setw(widthText)<<"Karma annotation file" |
---|
660 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[karmaFile]" |
---|
661 | <<" = " <<resetiosflags(std::ios::right) |
---|
662 | |
---|
663 | <<par.getKarmaFile() <<endl; |
---|
664 | } |
---|
665 | if(par.getFlagMaps()){ |
---|
666 | theStream<<setw(widthText)<<"0th Moment Map" |
---|
667 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[momentMap]" |
---|
668 | <<" = " <<resetiosflags(std::ios::right) |
---|
669 | <<par.getMomentMap() <<endl; |
---|
670 | theStream<<setw(widthText)<<"Detection Map" |
---|
671 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[detectionMap]" |
---|
672 | <<" = " <<resetiosflags(std::ios::right) |
---|
673 | <<par.getDetectionMap() <<endl; |
---|
674 | } |
---|
675 | theStream <<setw(widthText)<<"Display a map in a pgplot xwindow?" |
---|
676 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagXOutput]" |
---|
677 | <<" = " <<resetiosflags(std::ios::right) |
---|
678 | <<stringize(par.getFlagXOutput()) <<endl; |
---|
679 | if(par.getFlagATrous()){ |
---|
680 | theStream<<setw(widthText)<<"Saving reconstructed cube?" |
---|
681 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagoutputrecon]" |
---|
682 | <<" = " <<resetiosflags(std::ios::right) |
---|
683 | <<stringize(par.getFlagOutputRecon())<<endl; |
---|
684 | theStream<<setw(widthText)<<"Saving residuals from reconstruction?" |
---|
685 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagoutputresid]" |
---|
686 | <<" = " <<resetiosflags(std::ios::right) |
---|
687 | <<stringize(par.getFlagOutputResid())<<endl; |
---|
688 | } |
---|
689 | theStream <<"------"<<endl; |
---|
690 | theStream <<setw(widthText)<<"Searching for Negative features?" |
---|
691 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagNegative]" |
---|
692 | <<" = " <<resetiosflags(std::ios::right) |
---|
693 | <<stringize(par.getFlagNegative()) <<endl; |
---|
694 | theStream <<setw(widthText)<<"Fixing Blank Pixels?" |
---|
695 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagBlankPix]" |
---|
696 | <<" = " <<resetiosflags(std::ios::right) |
---|
697 | <<stringize(par.getFlagBlankPix()) <<endl; |
---|
698 | if(par.getFlagBlankPix()){ |
---|
699 | theStream<<setw(widthText)<<"Blank Pixel Value" |
---|
700 | <<setw(widthPar)<<setiosflags(std::ios::right)<< blankParam |
---|
701 | <<" = " <<resetiosflags(std::ios::right) |
---|
702 | <<par.getBlankPixVal() <<endl; |
---|
703 | } |
---|
704 | theStream <<setw(widthText)<<"Removing Milky Way channels?" |
---|
705 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagMW]" |
---|
706 | <<" = " <<resetiosflags(std::ios::right) |
---|
707 | <<stringize(par.getFlagMW()) <<endl; |
---|
708 | if(par.getFlagMW()){ |
---|
709 | theStream<<setw(widthText)<<"Milky Way Channels" |
---|
710 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[minMW - maxMW]" |
---|
711 | <<" = " <<resetiosflags(std::ios::right) |
---|
712 | <<par.getMinMW() |
---|
713 | <<"-" <<par.getMaxMW() <<endl; |
---|
714 | } |
---|
715 | theStream <<setw(widthText)<<"Beam Size (pixels)" |
---|
716 | <<setw(widthPar)<<setiosflags(std::ios::right)<< beamParam |
---|
717 | <<" = " <<resetiosflags(std::ios::right) |
---|
718 | <<par.getBeamSize() <<endl; |
---|
719 | theStream <<setw(widthText)<<"Removing baselines before search?" |
---|
720 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagBaseline]" |
---|
721 | <<" = " <<resetiosflags(std::ios::right) |
---|
722 | <<stringize(par.getFlagBaseline()) <<endl; |
---|
723 | theStream <<setw(widthText)<<"Minimum # Pixels in a detection" |
---|
724 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[minPix]" |
---|
725 | <<" = " <<resetiosflags(std::ios::right) |
---|
726 | <<par.getMinPix() <<endl; |
---|
727 | theStream <<setw(widthText)<<"Minimum # Channels in a detection" |
---|
728 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[minChannels]" |
---|
729 | <<" = " <<resetiosflags(std::ios::right) |
---|
730 | <<par.getMinChannels() <<endl; |
---|
731 | theStream <<setw(widthText)<<"Growing objects after detection?" |
---|
732 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagGrowth]" |
---|
733 | <<" = " <<resetiosflags(std::ios::right) |
---|
734 | <<stringize(par.getFlagGrowth()) <<endl; |
---|
735 | if(par.getFlagGrowth()) { |
---|
736 | theStream<<setw(widthText)<<"SNR Threshold for growth" |
---|
737 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[growthCut]" |
---|
738 | <<" = " <<resetiosflags(std::ios::right) |
---|
739 | <<par.getGrowthCut() <<endl; |
---|
740 | } |
---|
741 | theStream <<setw(widthText)<<"Hanning-smoothing each spectrum first?" |
---|
742 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagSmooth]" |
---|
743 | <<" = " <<resetiosflags(std::ios::right) |
---|
744 | <<stringize(par.getFlagSmooth()) <<endl; |
---|
745 | if(par.getFlagSmooth()) |
---|
746 | theStream<<setw(widthText)<<"Width of hanning filter" |
---|
747 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[hanningWidth]" |
---|
748 | <<" = " <<resetiosflags(std::ios::right) |
---|
749 | <<par.getHanningWidth() <<endl; |
---|
750 | theStream <<setw(widthText)<<"Using A Trous reconstruction?" |
---|
751 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagATrous]" |
---|
752 | <<" = " <<resetiosflags(std::ios::right) |
---|
753 | <<stringize(par.getFlagATrous()) <<endl; |
---|
754 | if(par.getFlagATrous()){ |
---|
755 | theStream<<setw(widthText)<<"Number of dimensions in reconstruction" |
---|
756 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[reconDim]" |
---|
757 | <<" = " <<resetiosflags(std::ios::right) |
---|
758 | <<par.getReconDim() <<endl; |
---|
759 | theStream<<setw(widthText)<<"Minimum scale in reconstruction" |
---|
760 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[scaleMin]" |
---|
761 | <<" = " <<resetiosflags(std::ios::right) |
---|
762 | <<par.getMinScale() <<endl; |
---|
763 | theStream<<setw(widthText)<<"SNR Threshold within reconstruction" |
---|
764 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[snrRecon]" |
---|
765 | <<" = " <<resetiosflags(std::ios::right) |
---|
766 | <<par.getAtrousCut() <<endl; |
---|
767 | theStream<<setw(widthText)<<"Filter being used for reconstruction" |
---|
768 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[filterCode]" |
---|
769 | <<" = " <<resetiosflags(std::ios::right) |
---|
770 | <<par.getFilterCode() |
---|
771 | << " (" << par.getFilterName() << ")" <<endl; |
---|
772 | } |
---|
773 | theStream <<setw(widthText)<<"Using FDR analysis?" |
---|
774 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagFDR]" |
---|
775 | <<" = " <<resetiosflags(std::ios::right) |
---|
776 | <<stringize(par.getFlagFDR()) <<endl; |
---|
777 | if(par.getFlagFDR()){ |
---|
778 | theStream<<setw(widthText)<<"Alpha value for FDR analysis" |
---|
779 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[alphaFDR]" |
---|
780 | <<" = " <<resetiosflags(std::ios::right) |
---|
781 | <<par.getAlpha() <<endl; |
---|
782 | } |
---|
783 | else { |
---|
784 | if(par.getFlagUserThreshold()){ |
---|
785 | theStream<<setw(widthText)<<"Detection Threshold" |
---|
786 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[threshold]" |
---|
787 | <<" = " <<resetiosflags(std::ios::right) |
---|
788 | <<par.getThreshold() <<endl; |
---|
789 | } |
---|
790 | else{ |
---|
791 | theStream<<setw(widthText)<<"SNR Threshold (in sigma)" |
---|
792 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[snrCut]" |
---|
793 | <<" = " <<resetiosflags(std::ios::right) |
---|
794 | <<par.getCut() <<endl; |
---|
795 | } |
---|
796 | } |
---|
797 | theStream <<setw(widthText)<<"Using Adjacent-pixel criterion?" |
---|
798 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagAdjacent]" |
---|
799 | <<" = " <<resetiosflags(std::ios::right) |
---|
800 | <<stringize(par.getFlagAdjacent()) <<endl; |
---|
801 | if(!par.getFlagAdjacent()){ |
---|
802 | theStream<<setw(widthText)<<"Max. spatial separation for merging" |
---|
803 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[threshSpatial]" |
---|
804 | <<" = " <<resetiosflags(std::ios::right) |
---|
805 | <<par.getThreshS() <<endl; |
---|
806 | } |
---|
807 | theStream <<setw(widthText)<<"Max. velocity separation for merging" |
---|
808 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[threshVelocity]" |
---|
809 | <<" = " <<resetiosflags(std::ios::right) |
---|
810 | <<par.getThreshV() <<endl; |
---|
811 | theStream <<setw(widthText)<<"Method of spectral plotting" |
---|
812 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[spectralMethod]" |
---|
813 | <<" = " <<resetiosflags(std::ios::right) |
---|
814 | <<par.getSpectralMethod() <<endl; |
---|
815 | theStream <<"--------------------"<<endl; |
---|
816 | theStream << std::setfill(' '); |
---|
817 | theStream.unsetf(std::ios::left); |
---|
818 | // theStream.unsetf(std::ios::boolalpha); |
---|
819 | } |
---|
820 | |
---|
821 | |
---|
822 | void Param::copyHeaderInfo(FitsHeader &head) |
---|
823 | { |
---|
824 | /** |
---|
825 | * Param::copyHeaderInfo(FitsHeader &head) |
---|
826 | * A function to copy across relevant header keywords from the |
---|
827 | * FitsHeader class to the Param class, as they are needed by |
---|
828 | * functions in the Param class. |
---|
829 | */ |
---|
830 | |
---|
831 | this->blankKeyword = head.getBlankKeyword(); |
---|
832 | this->bscaleKeyword = head.getBscaleKeyword(); |
---|
833 | this->bzeroKeyword = head.getBzeroKeyword(); |
---|
834 | this->blankPixValue = this->blankKeyword * this->bscaleKeyword + |
---|
835 | this->bzeroKeyword; |
---|
836 | |
---|
837 | this->numPixBeam = head.getBeamSize(); |
---|
838 | } |
---|
839 | |
---|
840 | bool Param::isBlank(float &value) |
---|
841 | { |
---|
842 | /** |
---|
843 | * Param::isBlank(float) |
---|
844 | * Tests whether the value passed as the argument is BLANK or not. |
---|
845 | * If flagBlankPix is false, return false. |
---|
846 | * Otherwise, compare to the relevant FITS keywords, using integer |
---|
847 | * comparison. |
---|
848 | * Return a bool. |
---|
849 | */ |
---|
850 | |
---|
851 | return this->flagBlankPix && |
---|
852 | (this->blankKeyword == int((value-this->bzeroKeyword)/this->bscaleKeyword)); |
---|
853 | } |
---|
854 | |
---|
855 | string Param::outputReconFile() |
---|
856 | { |
---|
857 | /** |
---|
858 | * outputReconFile() |
---|
859 | * |
---|
860 | * This function produces the required filename in which to save |
---|
861 | * the reconstructed array. If the input image is image.fits, then |
---|
862 | * the output will be eg. image.RECON-3-2-4-1.fits, where the numbers are |
---|
863 | * 3=reconDim, 2=filterCode, 4=snrRecon, 1=minScale |
---|
864 | */ |
---|
865 | string inputName = this->imageFile; |
---|
866 | std::stringstream ss; |
---|
867 | ss << inputName.substr(0,inputName.size()-5); // remove the ".fits" on the end. |
---|
868 | if(this->flagSubsection) ss<<".sub"; |
---|
869 | ss << ".RECON-" << this->reconDim |
---|
870 | << "-" << this->filterCode |
---|
871 | << "-" << this->snrRecon |
---|
872 | << "-" << this->scaleMin |
---|
873 | << ".fits"; |
---|
874 | return ss.str(); |
---|
875 | } |
---|
876 | |
---|
877 | string Param::outputResidFile() |
---|
878 | { |
---|
879 | /** |
---|
880 | * outputResidFile() |
---|
881 | * |
---|
882 | * This function produces the required filename in which to save |
---|
883 | * the reconstructed array. If the input image is image.fits, then |
---|
884 | * the output will be eg. image.RESID-3-2-4-1.fits, where the numbers are |
---|
885 | * 3=reconDim, 2=filterCode, 4=snrRecon, 1=scaleMin |
---|
886 | */ |
---|
887 | string inputName = this->imageFile; |
---|
888 | std::stringstream ss; |
---|
889 | ss << inputName.substr(0,inputName.size()-5); // remove the ".fits" on the end. |
---|
890 | if(this->flagSubsection) ss<<".sub"; |
---|
891 | ss << ".RESID-" << this->reconDim |
---|
892 | << "-" << this->filterCode |
---|
893 | << "-" << this->snrRecon |
---|
894 | << "-" << this->scaleMin |
---|
895 | << ".fits"; |
---|
896 | return ss.str(); |
---|
897 | } |
---|