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