[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 | /** |
---|
[204] | 103 | * FitsHeader::setWCS(struct wcsprm) |
---|
[103] | 104 | * A function that assigns the wcs parameters, and runs |
---|
| 105 | * wcsset to set it up correctly. |
---|
| 106 | * Performs a check to see if the WCS is good (by looking at |
---|
| 107 | * the lng and lat wcsprm parameters), and sets the wcsIsGood |
---|
| 108 | * flag accordingly. |
---|
| 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 | /** |
---|
| 118 | * FitsHeader::getWCS() |
---|
| 119 | * A function that returns a wcsprm object corresponding to the WCS. |
---|
| 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 | |
---|
| 129 | int FitsHeader::wcsToPix(const double *world, double *pix){ |
---|
[204] | 130 | return wcsToPixSingle(this->wcs, world, pix);} |
---|
[103] | 131 | int FitsHeader::wcsToPix(const double *world, double *pix, const int npts){ |
---|
[204] | 132 | return wcsToPixMulti(this->wcs, world, pix, npts);} |
---|
[103] | 133 | int FitsHeader::pixToWCS(const double *pix, double *world){ |
---|
[204] | 134 | return pixToWCSSingle(this->wcs, pix, world);} |
---|
[103] | 135 | int FitsHeader::pixToWCS(const double *pix, double *world, const int npts){ |
---|
[204] | 136 | return pixToWCSMulti(this->wcs, pix,world, npts);} |
---|
[103] | 137 | |
---|
[204] | 138 | double FitsHeader::pixToVel(double &x, double &y, double &z) |
---|
[103] | 139 | { |
---|
[186] | 140 | double vel; |
---|
| 141 | if(this->wcsIsGood){ |
---|
| 142 | double *pix = new double[3]; |
---|
| 143 | double *world = new double[3]; |
---|
| 144 | pix[0] = x; pix[1] = y; pix[2] = z; |
---|
| 145 | pixToWCSSingle(this->wcs,pix,world); |
---|
| 146 | vel = this->specToVel(world[2]); |
---|
| 147 | delete [] pix; |
---|
| 148 | delete [] world; |
---|
| 149 | } |
---|
| 150 | else vel = z; |
---|
[103] | 151 | return vel; |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | double* FitsHeader::pixToVel(double &x, double &y, double *zarray, int size) |
---|
| 155 | { |
---|
[186] | 156 | double *newzarray = new double[size]; |
---|
| 157 | if(this->wcsIsGood){ |
---|
| 158 | double *pix = new double[size*3]; |
---|
| 159 | for(int i=0;i<size;i++){ |
---|
[187] | 160 | pix[3*i] = x; |
---|
| 161 | pix[3*i+1] = y; |
---|
| 162 | pix[3*i+2] = zarray[i]; |
---|
[186] | 163 | } |
---|
| 164 | double *world = new double[size*3]; |
---|
| 165 | pixToWCSMulti(this->wcs,pix,world,size); |
---|
| 166 | delete [] pix; |
---|
| 167 | for(int i=0;i<size;i++) newzarray[i] = this->specToVel(world[3*i+2]); |
---|
| 168 | delete [] world; |
---|
[103] | 169 | } |
---|
[186] | 170 | else{ |
---|
| 171 | for(int i=0;i<size;i++) newzarray[i] = zarray[i]; |
---|
| 172 | } |
---|
[103] | 173 | return newzarray; |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | double FitsHeader::specToVel(const double &coord) |
---|
| 177 | { |
---|
| 178 | double vel; |
---|
[139] | 179 | if(power==1.0) vel = coord*this->scale + this->offset; |
---|
[103] | 180 | else vel = pow( (coord*this->scale + this->offset), this->power); |
---|
| 181 | return vel; |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | double FitsHeader::velToSpec(const float &velocity) |
---|
| 185 | { |
---|
| 186 | // return velToCoord(this->wcs,velocity,this->spectralUnits);}; |
---|
| 187 | return (pow(velocity, 1./this->power) - this->offset) / this->scale;} |
---|
| 188 | |
---|
| 189 | string FitsHeader::getIAUName(double ra, double dec) |
---|
| 190 | { |
---|
[201] | 191 | if(strcmp(this->wcs->lngtyp,"RA")==0) |
---|
| 192 | return getIAUNameEQ(ra, dec, this->wcs->equinox); |
---|
| 193 | else |
---|
| 194 | return getIAUNameGAL(ra, dec); |
---|
[103] | 195 | } |
---|
| 196 | |
---|
| 197 | void FitsHeader::fixUnits(Param &par) |
---|
| 198 | { |
---|
| 199 | // define spectral units from the param set |
---|
| 200 | this->spectralUnits = par.getSpectralUnits(); |
---|
| 201 | |
---|
| 202 | double sc=1.; |
---|
| 203 | double of=0.; |
---|
| 204 | double po=1.;; |
---|
| 205 | if(this->wcsIsGood){ |
---|
[205] | 206 | int status = wcsunits( this->wcs->cunit[this->wcs->spec], |
---|
[160] | 207 | this->spectralUnits.c_str(), |
---|
[142] | 208 | &sc, &of, &po); |
---|
[205] | 209 | if(status > 0){ |
---|
[120] | 210 | std::stringstream errmsg; |
---|
[205] | 211 | errmsg << "WCSUNITS Error, Code = " << status |
---|
| 212 | << ": " << wcsunits_errmsg[status]; |
---|
| 213 | if(status == 10) errmsg << "\nTried to get conversion from '" |
---|
| 214 | << this->wcs->cunit[this->wcs->spec] << "' to '" |
---|
| 215 | << this->spectralUnits.c_str() << "'\n"; |
---|
[204] | 216 | this->spectralUnits = this->wcs->cunit[this->wcs->spec]; |
---|
[103] | 217 | if(this->spectralUnits==""){ |
---|
[202] | 218 | errmsg << |
---|
[219] | 219 | "Spectral units not specified. Setting them to 'SPC' for clarity.\n"; |
---|
| 220 | this->spectralUnits = "SPC"; |
---|
[103] | 221 | } |
---|
[120] | 222 | duchampError("fixUnits", errmsg.str()); |
---|
| 223 | |
---|
[103] | 224 | } |
---|
| 225 | } |
---|
| 226 | this->scale = sc; |
---|
| 227 | this->offset= of; |
---|
| 228 | this->power = po; |
---|
| 229 | |
---|
[142] | 230 | // Work out the integrated flux units, based on the spectral units. |
---|
| 231 | // If flux is per beam, trim the /beam from the flux units and multiply |
---|
| 232 | // by the spectral units. |
---|
| 233 | // Otherwise, just muliply by the spectral units. |
---|
[103] | 234 | if(this->fluxUnits.size()>0){ |
---|
[142] | 235 | if(this->fluxUnits.substr(this->fluxUnits.size()-5, |
---|
| 236 | this->fluxUnits.size() ) == "/beam"){ |
---|
[103] | 237 | this->intFluxUnits = this->fluxUnits.substr(0,this->fluxUnits.size()-5) |
---|
| 238 | +" " +this->spectralUnits; |
---|
| 239 | } |
---|
[159] | 240 | else this->intFluxUnits = this->fluxUnits + " " + this->spectralUnits; |
---|
[103] | 241 | } |
---|
| 242 | |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | /****************************************************************/ |
---|
| 246 | /////////////////////////////////////////////////// |
---|
[3] | 247 | //// Accessor Functions for Parameter class: |
---|
| 248 | /////////////////////////////////////////////////// |
---|
| 249 | Param::Param(){ |
---|
| 250 | /** |
---|
| 251 | * Param() |
---|
| 252 | * Default intial values for the parameters. |
---|
| 253 | * imageFile has no default value! |
---|
| 254 | */ |
---|
| 255 | // Input files |
---|
[190] | 256 | this->imageFile = ""; |
---|
| 257 | this->flagSubsection = false; |
---|
| 258 | this->subsection = "[*,*,*]"; |
---|
| 259 | this->flagReconExists = false; |
---|
| 260 | this->reconFile = ""; |
---|
[208] | 261 | this->flagSmoothExists = false; |
---|
| 262 | this->smoothFile = ""; |
---|
[3] | 263 | // Output files |
---|
[190] | 264 | this->flagLog = true; |
---|
| 265 | this->logFile = "duchamp-Logfile.txt"; |
---|
| 266 | this->outFile = "duchamp-Results.txt"; |
---|
| 267 | this->spectraFile = "duchamp-Spectra.ps"; |
---|
[208] | 268 | this->flagOutputSmooth = false; |
---|
[190] | 269 | this->flagOutputRecon = false; |
---|
| 270 | this->flagOutputResid = false; |
---|
| 271 | this->flagVOT = false; |
---|
| 272 | this->votFile = "duchamp-Results.xml"; |
---|
| 273 | this->flagKarma = false; |
---|
| 274 | this->karmaFile = "duchamp-Results.ann"; |
---|
| 275 | this->flagMaps = true; |
---|
| 276 | this->detectionMap = "duchamp-DetectionMap.ps"; |
---|
| 277 | this->momentMap = "duchamp-MomentMap.ps"; |
---|
[195] | 278 | this->flagXOutput = true; |
---|
[3] | 279 | // Cube related parameters |
---|
[190] | 280 | this->flagBlankPix = true; |
---|
| 281 | this->blankPixValue = -8.00061; |
---|
| 282 | this->blankKeyword = 1; |
---|
| 283 | this->bscaleKeyword = -8.00061; |
---|
| 284 | this->bzeroKeyword = 0.; |
---|
| 285 | this->flagUsingBlank = false; |
---|
| 286 | this->flagMW = false; |
---|
| 287 | this->maxMW = 112; |
---|
| 288 | this->minMW = 75; |
---|
| 289 | this->numPixBeam = 10.; |
---|
| 290 | this->flagUsingBeam = false; |
---|
[3] | 291 | // Trim-related |
---|
[190] | 292 | this->flagTrimmed = false; |
---|
| 293 | this->borderLeft = 0; |
---|
| 294 | this->borderRight = 0; |
---|
| 295 | this->borderBottom = 0; |
---|
| 296 | this->borderTop = 0; |
---|
[3] | 297 | // Subsection offsets |
---|
[204] | 298 | this->sizeOffsets = 0; |
---|
[190] | 299 | this->xSubOffset = 0; |
---|
| 300 | this->ySubOffset = 0; |
---|
| 301 | this->zSubOffset = 0; |
---|
[3] | 302 | // Baseline related |
---|
[190] | 303 | this->flagBaseline = false; |
---|
[3] | 304 | // Detection-related |
---|
[190] | 305 | this->flagNegative = false; |
---|
[3] | 306 | // Object growth |
---|
[190] | 307 | this->flagGrowth = false; |
---|
| 308 | this->growthCut = 2.; |
---|
[3] | 309 | // FDR analysis |
---|
[190] | 310 | this->flagFDR = false; |
---|
| 311 | this->alphaFDR = 0.01; |
---|
[3] | 312 | // Other detection |
---|
[190] | 313 | this->snrCut = 3.; |
---|
| 314 | this->threshold = 0.; |
---|
| 315 | this->flagUserThreshold = false; |
---|
[201] | 316 | // Hanning Smoothing |
---|
| 317 | this->flagSmooth = false; |
---|
| 318 | this->hanningWidth = 5; |
---|
[3] | 319 | // A trous reconstruction parameters |
---|
[190] | 320 | this->flagATrous = true; |
---|
| 321 | this->reconDim = 3; |
---|
| 322 | this->scaleMin = 1; |
---|
| 323 | this->snrRecon = 4.; |
---|
| 324 | this->filterCode = 1; |
---|
[3] | 325 | // Volume-merging parameters |
---|
[190] | 326 | this->flagAdjacent = true; |
---|
| 327 | this->threshSpatial = 3.; |
---|
| 328 | this->threshVelocity = 7.; |
---|
| 329 | this->minChannels = 3; |
---|
| 330 | this->minPix = 2; |
---|
[3] | 331 | // Input-Output related |
---|
[190] | 332 | this->spectralMethod = "peak"; |
---|
| 333 | this->borders = true; |
---|
| 334 | this->blankEdge = true; |
---|
| 335 | this->verbose = true; |
---|
| 336 | this->spectralUnits = "km/s"; |
---|
[3] | 337 | }; |
---|
| 338 | |
---|
[204] | 339 | Param::Param (const Param& p) |
---|
| 340 | { |
---|
| 341 | this->imageFile = p.imageFile; |
---|
| 342 | this->flagSubsection = p.flagSubsection; |
---|
| 343 | this->subsection = p.subsection; |
---|
| 344 | this->flagReconExists = p.flagReconExists; |
---|
| 345 | this->reconFile = p.reconFile; |
---|
[208] | 346 | this->flagSmoothExists = p.flagSmoothExists; |
---|
| 347 | this->smoothFile = p.smoothFile; |
---|
[204] | 348 | this->flagLog = p.flagLog; |
---|
| 349 | this->logFile = p.logFile; |
---|
| 350 | this->outFile = p.outFile; |
---|
| 351 | this->spectraFile = p.spectraFile; |
---|
[208] | 352 | this->flagOutputSmooth = p.flagOutputSmooth; |
---|
[204] | 353 | this->flagOutputRecon = p.flagOutputRecon; |
---|
| 354 | this->flagOutputResid = p.flagOutputResid; |
---|
| 355 | this->flagVOT = p.flagVOT; |
---|
| 356 | this->votFile = p.votFile; |
---|
| 357 | this->flagKarma = p.flagKarma; |
---|
| 358 | this->karmaFile = p.karmaFile; |
---|
| 359 | this->flagMaps = p.flagMaps; |
---|
| 360 | this->detectionMap = p.detectionMap; |
---|
| 361 | this->momentMap = p.momentMap; |
---|
| 362 | this->flagXOutput = p.flagXOutput; |
---|
| 363 | this->flagBlankPix = p.flagBlankPix; |
---|
| 364 | this->blankPixValue = p.blankPixValue; |
---|
| 365 | this->blankKeyword = p.blankKeyword; |
---|
| 366 | this->bscaleKeyword = p.bscaleKeyword; |
---|
| 367 | this->bzeroKeyword = p.bzeroKeyword; |
---|
| 368 | this->flagUsingBlank = p.flagUsingBlank; |
---|
| 369 | this->flagMW = p.flagMW; |
---|
| 370 | this->maxMW = p.maxMW; |
---|
| 371 | this->minMW = p.minMW; |
---|
| 372 | this->numPixBeam = p.numPixBeam; |
---|
| 373 | this->flagTrimmed = p.flagTrimmed; |
---|
| 374 | this->borderLeft = p.borderLeft; |
---|
| 375 | this->borderRight = p.borderRight; |
---|
| 376 | this->borderBottom = p.borderBottom; |
---|
| 377 | this->borderTop = p.borderTop; |
---|
| 378 | this->sizeOffsets = p.sizeOffsets; |
---|
[213] | 379 | this->offsets = new long[this->sizeOffsets]; |
---|
[204] | 380 | if(this->sizeOffsets>0) |
---|
| 381 | for(int i=0;i<this->sizeOffsets;i++) this->offsets[i] = p.offsets[i]; |
---|
| 382 | this->xSubOffset = p.xSubOffset; |
---|
| 383 | this->ySubOffset = p.ySubOffset; |
---|
| 384 | this->zSubOffset = p.zSubOffset; |
---|
| 385 | this->flagBaseline = p.flagBaseline; |
---|
| 386 | this->flagNegative = p.flagNegative; |
---|
| 387 | this->flagGrowth = p.flagGrowth; |
---|
| 388 | this->growthCut = p.growthCut; |
---|
| 389 | this->flagFDR = p.flagFDR; |
---|
| 390 | this->alphaFDR = p.alphaFDR; |
---|
| 391 | this->snrCut = p.snrCut; |
---|
| 392 | this->threshold = p.threshold; |
---|
[205] | 393 | this->flagUserThreshold = p.flagUserThreshold; |
---|
[204] | 394 | this->flagSmooth = p.flagSmooth; |
---|
| 395 | this->hanningWidth = p.hanningWidth; |
---|
| 396 | this->flagATrous = p.flagATrous; |
---|
| 397 | this->reconDim = p.reconDim; |
---|
| 398 | this->scaleMin = p.scaleMin; |
---|
| 399 | this->snrRecon = p.snrRecon; |
---|
| 400 | this->filterCode = p.filterCode; |
---|
| 401 | this->flagAdjacent = p.flagAdjacent; |
---|
| 402 | this->threshSpatial = p.threshSpatial; |
---|
| 403 | this->threshVelocity = p.threshVelocity; |
---|
| 404 | this->minChannels = p.minChannels; |
---|
| 405 | this->minPix = p.minPix; |
---|
| 406 | this->spectralMethod = p.spectralMethod; |
---|
| 407 | this->borders = p.borders; |
---|
| 408 | this->verbose = p.verbose; |
---|
| 409 | this->spectralUnits = p.spectralUnits; |
---|
| 410 | } |
---|
| 411 | |
---|
[137] | 412 | Param& Param::operator= (const Param& p) |
---|
| 413 | { |
---|
[190] | 414 | this->imageFile = p.imageFile; |
---|
| 415 | this->flagSubsection = p.flagSubsection; |
---|
| 416 | this->subsection = p.subsection; |
---|
| 417 | this->flagReconExists = p.flagReconExists; |
---|
| 418 | this->reconFile = p.reconFile; |
---|
[208] | 419 | this->flagSmoothExists = p.flagSmoothExists; |
---|
| 420 | this->smoothFile = p.smoothFile; |
---|
[190] | 421 | this->flagLog = p.flagLog; |
---|
| 422 | this->logFile = p.logFile; |
---|
| 423 | this->outFile = p.outFile; |
---|
| 424 | this->spectraFile = p.spectraFile; |
---|
[208] | 425 | this->flagOutputSmooth = p.flagOutputSmooth; |
---|
[190] | 426 | this->flagOutputRecon = p.flagOutputRecon; |
---|
| 427 | this->flagOutputResid = p.flagOutputResid; |
---|
| 428 | this->flagVOT = p.flagVOT; |
---|
| 429 | this->votFile = p.votFile; |
---|
| 430 | this->flagKarma = p.flagKarma; |
---|
| 431 | this->karmaFile = p.karmaFile; |
---|
| 432 | this->flagMaps = p.flagMaps; |
---|
| 433 | this->detectionMap = p.detectionMap; |
---|
| 434 | this->momentMap = p.momentMap; |
---|
[195] | 435 | this->flagXOutput = p.flagXOutput; |
---|
[190] | 436 | this->flagBlankPix = p.flagBlankPix; |
---|
| 437 | this->blankPixValue = p.blankPixValue; |
---|
| 438 | this->blankKeyword = p.blankKeyword; |
---|
| 439 | this->bscaleKeyword = p.bscaleKeyword; |
---|
| 440 | this->bzeroKeyword = p.bzeroKeyword; |
---|
| 441 | this->flagUsingBlank = p.flagUsingBlank; |
---|
| 442 | this->flagMW = p.flagMW; |
---|
| 443 | this->maxMW = p.maxMW; |
---|
| 444 | this->minMW = p.minMW; |
---|
| 445 | this->numPixBeam = p.numPixBeam; |
---|
| 446 | this->flagTrimmed = p.flagTrimmed; |
---|
| 447 | this->borderLeft = p.borderLeft; |
---|
| 448 | this->borderRight = p.borderRight; |
---|
| 449 | this->borderBottom = p.borderBottom; |
---|
| 450 | this->borderTop = p.borderTop; |
---|
[204] | 451 | this->sizeOffsets = p.sizeOffsets; |
---|
[213] | 452 | this->offsets = new long[this->sizeOffsets]; |
---|
[204] | 453 | if(this->sizeOffsets>0) |
---|
| 454 | for(int i=0;i<this->sizeOffsets;i++) this->offsets[i] = p.offsets[i]; |
---|
[190] | 455 | this->xSubOffset = p.xSubOffset; |
---|
| 456 | this->ySubOffset = p.ySubOffset; |
---|
| 457 | this->zSubOffset = p.zSubOffset; |
---|
| 458 | this->flagBaseline = p.flagBaseline; |
---|
| 459 | this->flagNegative = p.flagNegative; |
---|
| 460 | this->flagGrowth = p.flagGrowth; |
---|
| 461 | this->growthCut = p.growthCut; |
---|
| 462 | this->flagFDR = p.flagFDR; |
---|
| 463 | this->alphaFDR = p.alphaFDR; |
---|
| 464 | this->snrCut = p.snrCut; |
---|
| 465 | this->threshold = p.threshold; |
---|
[205] | 466 | this->flagUserThreshold = p.flagUserThreshold; |
---|
[201] | 467 | this->flagSmooth = p.flagSmooth; |
---|
| 468 | this->hanningWidth = p.hanningWidth; |
---|
[190] | 469 | this->flagATrous = p.flagATrous; |
---|
| 470 | this->reconDim = p.reconDim; |
---|
| 471 | this->scaleMin = p.scaleMin; |
---|
| 472 | this->snrRecon = p.snrRecon; |
---|
| 473 | this->filterCode = p.filterCode; |
---|
| 474 | this->flagAdjacent = p.flagAdjacent; |
---|
| 475 | this->threshSpatial = p.threshSpatial; |
---|
| 476 | this->threshVelocity = p.threshVelocity; |
---|
| 477 | this->minChannels = p.minChannels; |
---|
| 478 | this->minPix = p.minPix; |
---|
| 479 | this->spectralMethod = p.spectralMethod; |
---|
| 480 | this->borders = p.borders; |
---|
| 481 | this->verbose = p.verbose; |
---|
| 482 | this->spectralUnits = p.spectralUnits; |
---|
[137] | 483 | } |
---|
| 484 | |
---|
[3] | 485 | /****************************************************************/ |
---|
| 486 | /////////////////////////////////////////////////// |
---|
| 487 | //// Other Functions using the Parameter class: |
---|
| 488 | /////////////////////////////////////////////////// |
---|
| 489 | |
---|
[163] | 490 | inline string makelower( string s ) |
---|
[3] | 491 | { |
---|
| 492 | // "borrowed" from Matt Howlett's 'fred' |
---|
| 493 | string out = ""; |
---|
| 494 | for( int i=0; i<s.size(); ++i ) { |
---|
| 495 | out += tolower(s[i]); |
---|
| 496 | } |
---|
| 497 | return out; |
---|
| 498 | } |
---|
| 499 | |
---|
[163] | 500 | inline bool boolify( string s ) |
---|
[132] | 501 | { |
---|
| 502 | /** |
---|
[133] | 503 | * bool boolify(string) |
---|
[132] | 504 | * Convert a string to a bool variable |
---|
| 505 | * "1" and "true" get converted to true |
---|
| 506 | * "0" and "false" (and anything else) get converted to false |
---|
| 507 | */ |
---|
| 508 | if((s=="1") || (makelower(s)=="true")) return true; |
---|
| 509 | else if((s=="0") || (makelower(s)=="false")) return false; |
---|
| 510 | else return false; |
---|
| 511 | } |
---|
| 512 | |
---|
[163] | 513 | inline string readSval(std::stringstream& ss) |
---|
| 514 | { |
---|
| 515 | string val; ss >> val; return val; |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | inline bool readFlag(std::stringstream& ss) |
---|
| 519 | { |
---|
| 520 | string val; ss >> val; return boolify(val); |
---|
| 521 | } |
---|
| 522 | |
---|
| 523 | inline float readFval(std::stringstream& ss) |
---|
| 524 | { |
---|
| 525 | float val; ss >> val; return val; |
---|
| 526 | } |
---|
| 527 | |
---|
| 528 | inline int readIval(std::stringstream& ss) |
---|
| 529 | { |
---|
| 530 | int val; ss >> val; return val; |
---|
| 531 | } |
---|
| 532 | |
---|
[160] | 533 | int Param::readParams(string paramfile) |
---|
[3] | 534 | { |
---|
| 535 | |
---|
| 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 | { |
---|
[103] | 621 | // Only show the [blankPixValue] bit if we are using the parameter |
---|
| 622 | // otherwise we have read it from the FITS header. |
---|
| 623 | string blankParam = ""; |
---|
| 624 | if(par.getFlagUsingBlank()) blankParam = "[blankPixValue]"; |
---|
[172] | 625 | string beamParam = ""; |
---|
| 626 | if(par.getFlagUsingBeam()) beamParam = "[beamSize]"; |
---|
[103] | 627 | |
---|
[107] | 628 | // BUG -- can get error: `boolalpha' is not a member of type `ios' -- old compilers: gcc 2.95.3? |
---|
[172] | 629 | // theStream.setf(std::ios::boolalpha); |
---|
[3] | 630 | theStream.setf(std::ios::left); |
---|
[219] | 631 | theStream <<"\n---- Parameters ----"<<endl; |
---|
[103] | 632 | theStream << std::setfill('.'); |
---|
[187] | 633 | const int widthText = 38; |
---|
| 634 | const int widthPar = 18; |
---|
[3] | 635 | if(par.getFlagSubsection()) |
---|
[187] | 636 | theStream<<setw(widthText)<<"Image to be analysed" |
---|
| 637 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]" |
---|
[103] | 638 | <<" = " <<resetiosflags(std::ios::right) |
---|
[172] | 639 | <<(par.getImageFile()+par.getSubsection()) <<endl; |
---|
[3] | 640 | else |
---|
[187] | 641 | theStream<<setw(widthText)<<"Image to be analysed" |
---|
| 642 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]" |
---|
[172] | 643 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 644 | <<par.getImageFile() <<endl; |
---|
[81] | 645 | if(par.getFlagReconExists() && par.getFlagATrous()){ |
---|
[187] | 646 | theStream<<setw(widthText)<<"Reconstructed array exists?" |
---|
| 647 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[reconExists]" |
---|
[172] | 648 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 649 | <<stringize(par.getFlagReconExists())<<endl; |
---|
[187] | 650 | theStream<<setw(widthText)<<"FITS file containing reconstruction" |
---|
| 651 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[reconFile]" |
---|
[172] | 652 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 653 | <<par.getReconFile() <<endl; |
---|
[71] | 654 | } |
---|
[208] | 655 | if(par.getFlagSmoothExists() && par.getFlagSmooth()){ |
---|
| 656 | theStream<<setw(widthText)<<"Hanning-smoothed array exists?" |
---|
| 657 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothExists]" |
---|
| 658 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 659 | <<stringize(par.getFlagSmoothExists())<<endl; |
---|
| 660 | theStream<<setw(widthText)<<"FITS file containing smoothed array" |
---|
| 661 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothFile]" |
---|
| 662 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 663 | <<par.getSmoothFile() <<endl; |
---|
| 664 | } |
---|
[187] | 665 | theStream <<setw(widthText)<<"Intermediate Logfile" |
---|
| 666 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[logFile]" |
---|
[172] | 667 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 668 | <<par.getLogFile() <<endl; |
---|
[187] | 669 | theStream <<setw(widthText)<<"Final Results file" |
---|
| 670 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[outFile]" |
---|
[172] | 671 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 672 | <<par.getOutFile() <<endl; |
---|
[187] | 673 | theStream <<setw(widthText)<<"Spectrum file" |
---|
| 674 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[spectraFile]" |
---|
[172] | 675 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 676 | <<par.getSpectraFile() <<endl; |
---|
[3] | 677 | if(par.getFlagVOT()){ |
---|
[187] | 678 | theStream<<setw(widthText)<<"VOTable file" |
---|
| 679 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[votFile]" |
---|
[172] | 680 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 681 | <<par.getVOTFile() <<endl; |
---|
[3] | 682 | } |
---|
[20] | 683 | if(par.getFlagKarma()){ |
---|
[187] | 684 | theStream<<setw(widthText)<<"Karma annotation file" |
---|
| 685 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[karmaFile]" |
---|
[172] | 686 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 687 | |
---|
| 688 | <<par.getKarmaFile() <<endl; |
---|
[20] | 689 | } |
---|
[3] | 690 | if(par.getFlagMaps()){ |
---|
[187] | 691 | theStream<<setw(widthText)<<"0th Moment Map" |
---|
| 692 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[momentMap]" |
---|
[172] | 693 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 694 | <<par.getMomentMap() <<endl; |
---|
[187] | 695 | theStream<<setw(widthText)<<"Detection Map" |
---|
| 696 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[detectionMap]" |
---|
[172] | 697 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 698 | <<par.getDetectionMap() <<endl; |
---|
[3] | 699 | } |
---|
[195] | 700 | theStream <<setw(widthText)<<"Display a map in a pgplot xwindow?" |
---|
| 701 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagXOutput]" |
---|
| 702 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 703 | <<stringize(par.getFlagXOutput()) <<endl; |
---|
[3] | 704 | if(par.getFlagATrous()){ |
---|
[187] | 705 | theStream<<setw(widthText)<<"Saving reconstructed cube?" |
---|
| 706 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagoutputrecon]" |
---|
[172] | 707 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 708 | <<stringize(par.getFlagOutputRecon())<<endl; |
---|
[187] | 709 | theStream<<setw(widthText)<<"Saving residuals from reconstruction?" |
---|
| 710 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagoutputresid]" |
---|
[172] | 711 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 712 | <<stringize(par.getFlagOutputResid())<<endl; |
---|
[3] | 713 | } |
---|
[208] | 714 | if(par.getFlagSmooth()){ |
---|
| 715 | theStream<<setw(widthText)<<"Saving Hanning-smoothed cube?" |
---|
| 716 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagoutputsmooth]" |
---|
| 717 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 718 | <<stringize(par.getFlagOutputSmooth())<<endl; |
---|
| 719 | } |
---|
[60] | 720 | theStream <<"------"<<endl; |
---|
[187] | 721 | theStream <<setw(widthText)<<"Searching for Negative features?" |
---|
| 722 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagNegative]" |
---|
[172] | 723 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 724 | <<stringize(par.getFlagNegative()) <<endl; |
---|
[187] | 725 | theStream <<setw(widthText)<<"Fixing Blank Pixels?" |
---|
| 726 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagBlankPix]" |
---|
[172] | 727 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 728 | <<stringize(par.getFlagBlankPix()) <<endl; |
---|
[3] | 729 | if(par.getFlagBlankPix()){ |
---|
[187] | 730 | theStream<<setw(widthText)<<"Blank Pixel Value" |
---|
| 731 | <<setw(widthPar)<<setiosflags(std::ios::right)<< blankParam |
---|
[172] | 732 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 733 | <<par.getBlankPixVal() <<endl; |
---|
[3] | 734 | } |
---|
[187] | 735 | theStream <<setw(widthText)<<"Removing Milky Way channels?" |
---|
| 736 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagMW]" |
---|
[172] | 737 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 738 | <<stringize(par.getFlagMW()) <<endl; |
---|
[3] | 739 | if(par.getFlagMW()){ |
---|
[187] | 740 | theStream<<setw(widthText)<<"Milky Way Channels" |
---|
| 741 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[minMW - maxMW]" |
---|
[172] | 742 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 743 | <<par.getMinMW() |
---|
[103] | 744 | <<"-" <<par.getMaxMW() <<endl; |
---|
[3] | 745 | } |
---|
[187] | 746 | theStream <<setw(widthText)<<"Beam Size (pixels)" |
---|
| 747 | <<setw(widthPar)<<setiosflags(std::ios::right)<< beamParam |
---|
[172] | 748 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 749 | <<par.getBeamSize() <<endl; |
---|
[187] | 750 | theStream <<setw(widthText)<<"Removing baselines before search?" |
---|
| 751 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagBaseline]" |
---|
[172] | 752 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 753 | <<stringize(par.getFlagBaseline()) <<endl; |
---|
[187] | 754 | theStream <<setw(widthText)<<"Minimum # Pixels in a detection" |
---|
| 755 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[minPix]" |
---|
[172] | 756 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 757 | <<par.getMinPix() <<endl; |
---|
[187] | 758 | theStream <<setw(widthText)<<"Minimum # Channels in a detection" |
---|
| 759 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[minChannels]" |
---|
[172] | 760 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 761 | <<par.getMinChannels() <<endl; |
---|
[187] | 762 | theStream <<setw(widthText)<<"Growing objects after detection?" |
---|
| 763 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagGrowth]" |
---|
[172] | 764 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 765 | <<stringize(par.getFlagGrowth()) <<endl; |
---|
[3] | 766 | if(par.getFlagGrowth()) { |
---|
[187] | 767 | theStream<<setw(widthText)<<"SNR Threshold for growth" |
---|
| 768 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[growthCut]" |
---|
[172] | 769 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 770 | <<par.getGrowthCut() <<endl; |
---|
[3] | 771 | } |
---|
[201] | 772 | theStream <<setw(widthText)<<"Hanning-smoothing each spectrum first?" |
---|
| 773 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagSmooth]" |
---|
| 774 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 775 | <<stringize(par.getFlagSmooth()) <<endl; |
---|
| 776 | if(par.getFlagSmooth()) |
---|
| 777 | theStream<<setw(widthText)<<"Width of hanning filter" |
---|
| 778 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[hanningWidth]" |
---|
| 779 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 780 | <<par.getHanningWidth() <<endl; |
---|
[187] | 781 | theStream <<setw(widthText)<<"Using A Trous reconstruction?" |
---|
| 782 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagATrous]" |
---|
[172] | 783 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 784 | <<stringize(par.getFlagATrous()) <<endl; |
---|
[3] | 785 | if(par.getFlagATrous()){ |
---|
[187] | 786 | theStream<<setw(widthText)<<"Number of dimensions in reconstruction" |
---|
| 787 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[reconDim]" |
---|
[172] | 788 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 789 | <<par.getReconDim() <<endl; |
---|
[187] | 790 | theStream<<setw(widthText)<<"Minimum scale in reconstruction" |
---|
| 791 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[scaleMin]" |
---|
[172] | 792 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 793 | <<par.getMinScale() <<endl; |
---|
[187] | 794 | theStream<<setw(widthText)<<"SNR Threshold within reconstruction" |
---|
| 795 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[snrRecon]" |
---|
[172] | 796 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 797 | <<par.getAtrousCut() <<endl; |
---|
[187] | 798 | theStream<<setw(widthText)<<"Filter being used for reconstruction" |
---|
| 799 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[filterCode]" |
---|
[172] | 800 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 801 | <<par.getFilterCode() |
---|
[103] | 802 | << " (" << par.getFilterName() << ")" <<endl; |
---|
[3] | 803 | } |
---|
[187] | 804 | theStream <<setw(widthText)<<"Using FDR analysis?" |
---|
| 805 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagFDR]" |
---|
[172] | 806 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 807 | <<stringize(par.getFlagFDR()) <<endl; |
---|
[3] | 808 | if(par.getFlagFDR()){ |
---|
[187] | 809 | theStream<<setw(widthText)<<"Alpha value for FDR analysis" |
---|
| 810 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[alphaFDR]" |
---|
[172] | 811 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 812 | <<par.getAlpha() <<endl; |
---|
[3] | 813 | } |
---|
| 814 | else { |
---|
[190] | 815 | if(par.getFlagUserThreshold()){ |
---|
[189] | 816 | theStream<<setw(widthText)<<"Detection Threshold" |
---|
| 817 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[threshold]" |
---|
| 818 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 819 | <<par.getThreshold() <<endl; |
---|
| 820 | } |
---|
| 821 | else{ |
---|
| 822 | theStream<<setw(widthText)<<"SNR Threshold (in sigma)" |
---|
| 823 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[snrCut]" |
---|
| 824 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 825 | <<par.getCut() <<endl; |
---|
| 826 | } |
---|
[3] | 827 | } |
---|
[187] | 828 | theStream <<setw(widthText)<<"Using Adjacent-pixel criterion?" |
---|
| 829 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[flagAdjacent]" |
---|
[172] | 830 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 831 | <<stringize(par.getFlagAdjacent()) <<endl; |
---|
[3] | 832 | if(!par.getFlagAdjacent()){ |
---|
[187] | 833 | theStream<<setw(widthText)<<"Max. spatial separation for merging" |
---|
| 834 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[threshSpatial]" |
---|
[172] | 835 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 836 | <<par.getThreshS() <<endl; |
---|
[3] | 837 | } |
---|
[187] | 838 | theStream <<setw(widthText)<<"Max. velocity separation for merging" |
---|
| 839 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[threshVelocity]" |
---|
[172] | 840 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 841 | <<par.getThreshV() <<endl; |
---|
[187] | 842 | theStream <<setw(widthText)<<"Method of spectral plotting" |
---|
| 843 | <<setw(widthPar)<<setiosflags(std::ios::right)<<"[spectralMethod]" |
---|
[172] | 844 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 845 | <<par.getSpectralMethod() <<endl; |
---|
[219] | 846 | theStream <<"--------------------\n\n"; |
---|
[103] | 847 | theStream << std::setfill(' '); |
---|
[3] | 848 | theStream.unsetf(std::ios::left); |
---|
[110] | 849 | // theStream.unsetf(std::ios::boolalpha); |
---|
[3] | 850 | } |
---|
| 851 | |
---|
[120] | 852 | |
---|
[112] | 853 | void Param::copyHeaderInfo(FitsHeader &head) |
---|
| 854 | { |
---|
| 855 | /** |
---|
| 856 | * Param::copyHeaderInfo(FitsHeader &head) |
---|
| 857 | * A function to copy across relevant header keywords from the |
---|
| 858 | * FitsHeader class to the Param class, as they are needed by |
---|
| 859 | * functions in the Param class. |
---|
| 860 | */ |
---|
| 861 | |
---|
| 862 | this->blankKeyword = head.getBlankKeyword(); |
---|
| 863 | this->bscaleKeyword = head.getBscaleKeyword(); |
---|
| 864 | this->bzeroKeyword = head.getBzeroKeyword(); |
---|
[159] | 865 | this->blankPixValue = this->blankKeyword * this->bscaleKeyword + |
---|
| 866 | this->bzeroKeyword; |
---|
[112] | 867 | |
---|
| 868 | this->numPixBeam = head.getBeamSize(); |
---|
| 869 | } |
---|
| 870 | |
---|
[118] | 871 | bool Param::isBlank(float &value) |
---|
[3] | 872 | { |
---|
[120] | 873 | /** |
---|
| 874 | * Param::isBlank(float) |
---|
| 875 | * Tests whether the value passed as the argument is BLANK or not. |
---|
| 876 | * If flagBlankPix is false, return false. |
---|
[159] | 877 | * Otherwise, compare to the relevant FITS keywords, using integer |
---|
| 878 | * comparison. |
---|
[120] | 879 | * Return a bool. |
---|
| 880 | */ |
---|
| 881 | |
---|
| 882 | return this->flagBlankPix && |
---|
| 883 | (this->blankKeyword == int((value-this->bzeroKeyword)/this->bscaleKeyword)); |
---|
[3] | 884 | } |
---|
[103] | 885 | |
---|
[208] | 886 | string Param::outputSmoothFile() |
---|
| 887 | { |
---|
| 888 | /** |
---|
| 889 | * outputSmoothFile() |
---|
| 890 | * This function produces the required filename in which to save |
---|
| 891 | * the Hanning-smoothed array. If the input image is image.fits, then |
---|
| 892 | * the output will be eg. image.SMOOTH-3.fits, where the width of the |
---|
| 893 | * Hanning filter was 3 pixels. |
---|
| 894 | */ |
---|
| 895 | string inputName = this->imageFile; |
---|
| 896 | std::stringstream ss; |
---|
| 897 | ss << inputName.substr(0,inputName.size()-5); |
---|
| 898 | // remove the ".fits" on the end. |
---|
| 899 | if(this->flagSubsection) ss<<".sub"; |
---|
| 900 | ss << ".SMOOTH-" << this->hanningWidth |
---|
| 901 | << ".fits"; |
---|
| 902 | return ss.str(); |
---|
| 903 | } |
---|
| 904 | |
---|
[103] | 905 | string Param::outputReconFile() |
---|
| 906 | { |
---|
| 907 | /** |
---|
| 908 | * outputReconFile() |
---|
| 909 | * |
---|
| 910 | * This function produces the required filename in which to save |
---|
| 911 | * the reconstructed array. If the input image is image.fits, then |
---|
| 912 | * the output will be eg. image.RECON-3-2-4-1.fits, where the numbers are |
---|
| 913 | * 3=reconDim, 2=filterCode, 4=snrRecon, 1=minScale |
---|
| 914 | */ |
---|
| 915 | string inputName = this->imageFile; |
---|
| 916 | std::stringstream ss; |
---|
| 917 | ss << inputName.substr(0,inputName.size()-5); // remove the ".fits" on the end. |
---|
[106] | 918 | if(this->flagSubsection) ss<<".sub"; |
---|
[103] | 919 | ss << ".RECON-" << this->reconDim |
---|
| 920 | << "-" << this->filterCode |
---|
| 921 | << "-" << this->snrRecon |
---|
| 922 | << "-" << this->scaleMin |
---|
| 923 | << ".fits"; |
---|
| 924 | return ss.str(); |
---|
| 925 | } |
---|
| 926 | |
---|
| 927 | string Param::outputResidFile() |
---|
| 928 | { |
---|
| 929 | /** |
---|
| 930 | * outputResidFile() |
---|
| 931 | * |
---|
| 932 | * This function produces the required filename in which to save |
---|
| 933 | * the reconstructed array. If the input image is image.fits, then |
---|
| 934 | * the output will be eg. image.RESID-3-2-4-1.fits, where the numbers are |
---|
| 935 | * 3=reconDim, 2=filterCode, 4=snrRecon, 1=scaleMin |
---|
| 936 | */ |
---|
| 937 | string inputName = this->imageFile; |
---|
| 938 | std::stringstream ss; |
---|
| 939 | ss << inputName.substr(0,inputName.size()-5); // remove the ".fits" on the end. |
---|
[106] | 940 | if(this->flagSubsection) ss<<".sub"; |
---|
[103] | 941 | ss << ".RESID-" << this->reconDim |
---|
| 942 | << "-" << this->filterCode |
---|
| 943 | << "-" << this->snrRecon |
---|
| 944 | << "-" << this->scaleMin |
---|
| 945 | << ".fits"; |
---|
| 946 | return ss.str(); |
---|
| 947 | } |
---|