[299] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // param.cc: Dealing with the set of parameters for Duchamp. |
---|
| 3 | // ----------------------------------------------------------------------- |
---|
| 4 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
| 5 | // |
---|
| 6 | // This program is free software; you can redistribute it and/or modify it |
---|
| 7 | // under the terms of the GNU General Public License as published by the |
---|
| 8 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
| 9 | // option) any later version. |
---|
| 10 | // |
---|
| 11 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
| 12 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 13 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
| 14 | // for more details. |
---|
| 15 | // |
---|
| 16 | // You should have received a copy of the GNU General Public License |
---|
| 17 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
| 18 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
| 19 | // |
---|
| 20 | // Correspondence concerning Duchamp may be directed to: |
---|
| 21 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
| 22 | // Postal address: Dr. Matthew Whiting |
---|
| 23 | // Australia Telescope National Facility, CSIRO |
---|
| 24 | // PO Box 76 |
---|
| 25 | // Epping NSW 1710 |
---|
| 26 | // AUSTRALIA |
---|
| 27 | // ----------------------------------------------------------------------- |
---|
[3] | 28 | #include <iostream> |
---|
| 29 | #include <iomanip> |
---|
| 30 | #include <fstream> |
---|
| 31 | #include <sstream> |
---|
| 32 | #include <string> |
---|
[205] | 33 | #include <stdlib.h> |
---|
[269] | 34 | #include <ctype.h> |
---|
[3] | 35 | #include <math.h> |
---|
| 36 | #include <param.hh> |
---|
[272] | 37 | #include <fitsHeader.hh> |
---|
[142] | 38 | #include <duchamp.hh> |
---|
[232] | 39 | #include <ATrous/filter.hh> |
---|
[103] | 40 | #include <Utils/utils.hh> |
---|
[258] | 41 | #include <Utils/Section.hh> |
---|
[3] | 42 | |
---|
[378] | 43 | namespace duchamp |
---|
[309] | 44 | { |
---|
| 45 | |
---|
[378] | 46 | /****************************************************************/ |
---|
| 47 | /////////////////////////////////////////////////// |
---|
| 48 | //// Accessor Functions for Parameter class: |
---|
| 49 | /////////////////////////////////////////////////// |
---|
| 50 | Param::~Param() |
---|
| 51 | { |
---|
| 52 | /** |
---|
| 53 | * Deletes the offsets array if the sizeOffsets parameter is |
---|
| 54 | * positive. |
---|
| 55 | */ |
---|
| 56 | if(this->sizeOffsets>0) delete [] this->offsets; |
---|
| 57 | } |
---|
[309] | 58 | |
---|
[378] | 59 | Param::Param() |
---|
| 60 | { |
---|
| 61 | this->defaultValues(); |
---|
| 62 | } |
---|
[3] | 63 | |
---|
[378] | 64 | void Param::defaultValues() |
---|
| 65 | { |
---|
| 66 | /** |
---|
| 67 | * Provides default intial values for the parameters. Note that |
---|
| 68 | * imageFile has no default value! |
---|
| 69 | */ |
---|
| 70 | std::string baseSection = "[*,*,*]"; |
---|
| 71 | // Input files |
---|
| 72 | this->imageFile = ""; |
---|
| 73 | this->flagSubsection = false; |
---|
| 74 | this->pixelSec.setSection(baseSection); |
---|
| 75 | this->flagReconExists = false; |
---|
| 76 | this->reconFile = ""; |
---|
| 77 | this->flagSmoothExists = false; |
---|
| 78 | this->smoothFile = ""; |
---|
| 79 | // Output files |
---|
| 80 | this->flagLog = false; |
---|
| 81 | this->logFile = "duchamp-Logfile.txt"; |
---|
| 82 | this->outFile = "duchamp-Results.txt"; |
---|
| 83 | this->flagSeparateHeader= false; |
---|
| 84 | this->headerFile = "duchamp-Results.hdr"; |
---|
| 85 | this->spectraFile = "duchamp-Spectra.ps"; |
---|
[379] | 86 | this->flagOutputMask = false; |
---|
[378] | 87 | this->flagOutputSmooth = false; |
---|
| 88 | this->flagOutputRecon = false; |
---|
| 89 | this->flagOutputResid = false; |
---|
| 90 | this->flagVOT = false; |
---|
| 91 | this->votFile = "duchamp-Results.xml"; |
---|
| 92 | this->flagKarma = false; |
---|
| 93 | this->karmaFile = "duchamp-Results.ann"; |
---|
| 94 | this->flagMaps = true; |
---|
| 95 | this->detectionMap = "duchamp-DetectionMap.ps"; |
---|
| 96 | this->momentMap = "duchamp-MomentMap.ps"; |
---|
| 97 | this->flagXOutput = true; |
---|
| 98 | // Cube related parameters |
---|
| 99 | this->flagBlankPix = true; |
---|
| 100 | this->blankPixValue = -8.00061; |
---|
| 101 | this->blankKeyword = 1; |
---|
| 102 | this->bscaleKeyword = -8.00061; |
---|
| 103 | this->bzeroKeyword = 0.; |
---|
| 104 | // Milky-Way parameters |
---|
| 105 | this->flagMW = false; |
---|
| 106 | this->maxMW = 112; |
---|
| 107 | this->minMW = 75; |
---|
| 108 | this->numPixBeam = 10.; |
---|
| 109 | this->flagUsingBeam = false; |
---|
| 110 | // Trim-related |
---|
| 111 | this->flagTrim = false; |
---|
| 112 | this->hasBeenTrimmed = false; |
---|
| 113 | this->borderLeft = 0; |
---|
| 114 | this->borderRight = 0; |
---|
| 115 | this->borderBottom = 0; |
---|
| 116 | this->borderTop = 0; |
---|
| 117 | // Subsection offsets |
---|
| 118 | this->sizeOffsets = 0; |
---|
| 119 | this->xSubOffset = 0; |
---|
| 120 | this->ySubOffset = 0; |
---|
| 121 | this->zSubOffset = 0; |
---|
| 122 | // Baseline related |
---|
| 123 | this->flagBaseline = false; |
---|
| 124 | // Detection-related |
---|
| 125 | this->flagNegative = false; |
---|
| 126 | // Object growth |
---|
| 127 | this->flagGrowth = false; |
---|
| 128 | this->growthCut = 2.; |
---|
| 129 | // FDR analysis |
---|
| 130 | this->flagFDR = false; |
---|
| 131 | this->alphaFDR = 0.01; |
---|
| 132 | // Other detection |
---|
| 133 | this->flagStatSec = false; |
---|
| 134 | this->statSec.setSection(baseSection); |
---|
[385] | 135 | this->flagRobustStats = true; |
---|
[378] | 136 | this->snrCut = 3.; |
---|
| 137 | this->threshold = 0.; |
---|
| 138 | this->flagUserThreshold = false; |
---|
| 139 | // Smoothing |
---|
| 140 | this->flagSmooth = false; |
---|
| 141 | this->smoothType = "spectral"; |
---|
| 142 | this->hanningWidth = 5; |
---|
| 143 | this->kernMaj = 3.; |
---|
| 144 | this->kernMin = -1.; |
---|
| 145 | this->kernPA = 0.; |
---|
| 146 | // A trous reconstruction parameters |
---|
| 147 | this->flagATrous = false; |
---|
| 148 | this->reconDim = 1; |
---|
| 149 | this->scaleMin = 1; |
---|
| 150 | this->scaleMax = 0; |
---|
| 151 | this->snrRecon = 4.; |
---|
| 152 | this->filterCode = 1; |
---|
| 153 | this->reconFilter.define(this->filterCode); |
---|
| 154 | // Volume-merging parameters |
---|
| 155 | this->flagAdjacent = true; |
---|
| 156 | this->threshSpatial = 3.; |
---|
| 157 | this->threshVelocity = 7.; |
---|
| 158 | this->minChannels = 3; |
---|
| 159 | this->minPix = 2; |
---|
| 160 | // Input-Output related |
---|
| 161 | this->spectralMethod = "peak"; |
---|
| 162 | this->spectralUnits = "km/s"; |
---|
| 163 | this->pixelCentre = "centroid"; |
---|
| 164 | this->borders = true; |
---|
| 165 | this->blankEdge = true; |
---|
| 166 | this->verbose = true; |
---|
| 167 | }; |
---|
[204] | 168 | |
---|
[378] | 169 | Param::Param (const Param& p) |
---|
| 170 | { |
---|
| 171 | operator=(p); |
---|
[309] | 172 | } |
---|
[137] | 173 | |
---|
[378] | 174 | Param& Param::operator= (const Param& p) |
---|
| 175 | { |
---|
| 176 | if(this == &p) return *this; |
---|
| 177 | this->imageFile = p.imageFile; |
---|
| 178 | this->flagSubsection = p.flagSubsection; |
---|
| 179 | this->pixelSec = p.pixelSec; |
---|
| 180 | this->flagReconExists = p.flagReconExists; |
---|
| 181 | this->reconFile = p.reconFile; |
---|
| 182 | this->flagSmoothExists = p.flagSmoothExists; |
---|
| 183 | this->smoothFile = p.smoothFile; |
---|
| 184 | this->flagLog = p.flagLog; |
---|
| 185 | this->logFile = p.logFile; |
---|
| 186 | this->outFile = p.outFile; |
---|
| 187 | this->flagSeparateHeader= p.flagSeparateHeader; |
---|
| 188 | this->headerFile = p.headerFile; |
---|
| 189 | this->spectraFile = p.spectraFile; |
---|
[379] | 190 | this->flagOutputMask = p.flagOutputMask; |
---|
[378] | 191 | this->flagOutputSmooth = p.flagOutputSmooth; |
---|
| 192 | this->flagOutputRecon = p.flagOutputRecon; |
---|
| 193 | this->flagOutputResid = p.flagOutputResid; |
---|
| 194 | this->flagVOT = p.flagVOT; |
---|
| 195 | this->votFile = p.votFile; |
---|
| 196 | this->flagKarma = p.flagKarma; |
---|
| 197 | this->karmaFile = p.karmaFile; |
---|
| 198 | this->flagMaps = p.flagMaps; |
---|
| 199 | this->detectionMap = p.detectionMap; |
---|
| 200 | this->momentMap = p.momentMap; |
---|
| 201 | this->flagXOutput = p.flagXOutput; |
---|
| 202 | this->flagBlankPix = p.flagBlankPix; |
---|
| 203 | this->blankPixValue = p.blankPixValue; |
---|
| 204 | this->blankKeyword = p.blankKeyword; |
---|
| 205 | this->bscaleKeyword = p.bscaleKeyword; |
---|
| 206 | this->bzeroKeyword = p.bzeroKeyword; |
---|
| 207 | this->flagMW = p.flagMW; |
---|
| 208 | this->maxMW = p.maxMW; |
---|
| 209 | this->minMW = p.minMW; |
---|
| 210 | this->numPixBeam = p.numPixBeam; |
---|
| 211 | this->flagTrim = p.flagTrim; |
---|
| 212 | this->hasBeenTrimmed = p.hasBeenTrimmed; |
---|
| 213 | this->borderLeft = p.borderLeft; |
---|
| 214 | this->borderRight = p.borderRight; |
---|
| 215 | this->borderBottom = p.borderBottom; |
---|
| 216 | this->borderTop = p.borderTop; |
---|
| 217 | if(this->sizeOffsets>0) delete [] this->offsets; |
---|
| 218 | this->sizeOffsets = p.sizeOffsets; |
---|
| 219 | if(this->sizeOffsets>0){ |
---|
| 220 | this->offsets = new long[this->sizeOffsets]; |
---|
| 221 | for(int i=0;i<this->sizeOffsets;i++) this->offsets[i] = p.offsets[i]; |
---|
| 222 | } |
---|
| 223 | this->xSubOffset = p.xSubOffset; |
---|
| 224 | this->ySubOffset = p.ySubOffset; |
---|
| 225 | this->zSubOffset = p.zSubOffset; |
---|
| 226 | this->flagBaseline = p.flagBaseline; |
---|
| 227 | this->flagNegative = p.flagNegative; |
---|
| 228 | this->flagGrowth = p.flagGrowth; |
---|
| 229 | this->growthCut = p.growthCut; |
---|
| 230 | this->flagFDR = p.flagFDR; |
---|
| 231 | this->alphaFDR = p.alphaFDR; |
---|
| 232 | this->flagStatSec = p.flagStatSec; |
---|
[385] | 233 | this->statSec = p.statSec; |
---|
| 234 | this->flagRobustStats = p.flagRobustStats; |
---|
[378] | 235 | this->snrCut = p.snrCut; |
---|
| 236 | this->threshold = p.threshold; |
---|
| 237 | this->flagUserThreshold = p.flagUserThreshold; |
---|
| 238 | this->flagSmooth = p.flagSmooth; |
---|
| 239 | this->smoothType = p.smoothType; |
---|
| 240 | this->hanningWidth = p.hanningWidth; |
---|
| 241 | this->kernMaj = p.kernMaj; |
---|
| 242 | this->kernMin = p.kernMin; |
---|
| 243 | this->kernPA = p.kernPA; |
---|
| 244 | this->flagATrous = p.flagATrous; |
---|
| 245 | this->reconDim = p.reconDim; |
---|
| 246 | this->scaleMin = p.scaleMin; |
---|
| 247 | this->scaleMax = p.scaleMax; |
---|
| 248 | this->snrRecon = p.snrRecon; |
---|
| 249 | this->filterCode = p.filterCode; |
---|
| 250 | this->reconFilter = p.reconFilter; |
---|
| 251 | this->flagAdjacent = p.flagAdjacent; |
---|
| 252 | this->threshSpatial = p.threshSpatial; |
---|
| 253 | this->threshVelocity = p.threshVelocity; |
---|
| 254 | this->minChannels = p.minChannels; |
---|
| 255 | this->minPix = p.minPix; |
---|
| 256 | this->spectralMethod = p.spectralMethod; |
---|
| 257 | this->spectralUnits = p.spectralUnits; |
---|
| 258 | this->pixelCentre = p.pixelCentre; |
---|
| 259 | this->borders = p.borders; |
---|
| 260 | this->verbose = p.verbose; |
---|
| 261 | return *this; |
---|
| 262 | } |
---|
| 263 | //-------------------------------------------------------------------- |
---|
[266] | 264 | |
---|
[378] | 265 | int Param::getopts(int argc, char ** argv) |
---|
| 266 | { |
---|
| 267 | /** |
---|
| 268 | * A function that reads in the command-line options, in a manner |
---|
| 269 | * tailored for use with the main Duchamp program. |
---|
| 270 | * |
---|
| 271 | * \param argc The number of command line arguments. |
---|
| 272 | * \param argv The array of command line arguments. |
---|
| 273 | */ |
---|
| 274 | |
---|
| 275 | int returnValue = FAILURE; |
---|
| 276 | if(argc==1){ |
---|
| 277 | std::cout << ERR_USAGE_MSG; |
---|
| 278 | returnValue = FAILURE; |
---|
| 279 | } |
---|
| 280 | else { |
---|
| 281 | std::string file; |
---|
| 282 | bool changeX = false; |
---|
| 283 | this->defaultValues(); |
---|
| 284 | char c; |
---|
| 285 | while( ( c = getopt(argc,argv,"p:f:hvx") )!=-1){ |
---|
| 286 | switch(c) { |
---|
| 287 | case 'p': |
---|
| 288 | file = optarg; |
---|
| 289 | if(this->readParams(file)==FAILURE){ |
---|
| 290 | std::stringstream errmsg; |
---|
| 291 | errmsg << "Could not open parameter file " << file << ".\n"; |
---|
| 292 | duchampError("Duchamp",errmsg.str()); |
---|
| 293 | } |
---|
| 294 | else returnValue = SUCCESS; |
---|
| 295 | break; |
---|
| 296 | case 'f': |
---|
| 297 | file = optarg; |
---|
| 298 | this->imageFile = file; |
---|
| 299 | returnValue = SUCCESS; |
---|
| 300 | break; |
---|
| 301 | case 'v': |
---|
| 302 | std::cout << PROGNAME << " version " << VERSION << std::endl; |
---|
| 303 | break; |
---|
| 304 | case 'x': |
---|
| 305 | changeX = true; |
---|
| 306 | break; |
---|
| 307 | case 'h': |
---|
| 308 | default : |
---|
| 309 | std::cout << ERR_USAGE_MSG; |
---|
| 310 | break; |
---|
[266] | 311 | } |
---|
| 312 | } |
---|
[378] | 313 | if(changeX){ |
---|
| 314 | if(returnValue == SUCCESS) this->setFlagXOutput(false); |
---|
| 315 | else { |
---|
| 316 | duchampError("Duchamp", |
---|
| 317 | "You need to specify either a parameter file or FITS image.\n"); |
---|
| 318 | std::cout << "\n" << ERR_USAGE_MSG; |
---|
| 319 | } |
---|
[294] | 320 | } |
---|
| 321 | } |
---|
[378] | 322 | return returnValue; |
---|
[266] | 323 | } |
---|
[378] | 324 | //-------------------------------------------------------------------- |
---|
[266] | 325 | |
---|
[378] | 326 | bool Param::isBlank(float &value) |
---|
| 327 | { |
---|
| 328 | /** |
---|
| 329 | * Tests whether the value passed as the argument is BLANK or not. |
---|
| 330 | * \param value Pixel value to be tested. |
---|
| 331 | * \return False if flagBlankPix is false. Else, compare to the |
---|
| 332 | * relevant FITS keywords, using integer comparison. |
---|
| 333 | */ |
---|
| 334 | return this->flagBlankPix && |
---|
| 335 | (this->blankKeyword == int((value-this->bzeroKeyword)/this->bscaleKeyword)); |
---|
| 336 | }; |
---|
[266] | 337 | |
---|
[378] | 338 | bool *Param::makeBlankMask(float *array, int size) |
---|
| 339 | { |
---|
| 340 | /** |
---|
| 341 | * This returns an array of bools, saying whether each pixel in the |
---|
| 342 | * given array is BLANK or not. If the pixel is BLANK, set mask to |
---|
| 343 | * false, else set to true. The array is allocated by the function. |
---|
| 344 | */ |
---|
| 345 | bool *mask = new bool[size]; |
---|
| 346 | for(int i=0;i<size;i++) mask[i] = !this->isBlank(array[i]); |
---|
| 347 | return mask; |
---|
| 348 | } |
---|
[275] | 349 | |
---|
| 350 | |
---|
[378] | 351 | bool Param::isInMW(int z) |
---|
| 352 | { |
---|
| 353 | /** |
---|
| 354 | * Tests whether we are flagging Milky Way channels, and if so |
---|
| 355 | * whether the given channel number is in the Milky Way range. The |
---|
| 356 | * channels are assumed to start at number 0. |
---|
| 357 | * \param z The channel number |
---|
| 358 | * \return True if we are flagging Milky Way channels and z is in |
---|
| 359 | * the range. |
---|
| 360 | */ |
---|
| 361 | return ( flagMW && (z>=minMW) && (z<=maxMW) ); |
---|
| 362 | } |
---|
[266] | 363 | |
---|
[378] | 364 | bool Param::isStatOK(int x, int y, int z) |
---|
| 365 | { |
---|
| 366 | /** |
---|
| 367 | * Test whether a given pixel position lies within the subsection |
---|
| 368 | * given by the statSec parameter. Only tested if the flagSubsection |
---|
| 369 | * parameter is true -- if it isn't, we just return true since all |
---|
| 370 | * pixels are therefore available for statstical calculations. |
---|
| 371 | * \param x X-value of pixel being tested. |
---|
| 372 | * \param y Y-value of pixel being tested. |
---|
| 373 | * \param z Z-value of pixel being tested. |
---|
| 374 | * \return True if pixel is able to be used for statistical |
---|
| 375 | * calculations. False otherwise. |
---|
| 376 | */ |
---|
[272] | 377 | int xval=x,yval=y,zval=z; |
---|
| 378 | if(flagSubsection){ |
---|
| 379 | xval += pixelSec.getStart(0); |
---|
| 380 | yval += pixelSec.getStart(1); |
---|
| 381 | zval += pixelSec.getStart(2); |
---|
| 382 | } |
---|
| 383 | return !flagStatSec || statSec.isInside(xval,yval,zval); |
---|
| 384 | }; |
---|
[266] | 385 | |
---|
[378] | 386 | /****************************************************************/ |
---|
| 387 | /////////////////////////////////////////////////// |
---|
| 388 | //// Other Functions using the Parameter class: |
---|
| 389 | /////////////////////////////////////////////////// |
---|
[3] | 390 | |
---|
[378] | 391 | std::string makelower( std::string s ) |
---|
| 392 | { |
---|
| 393 | // "borrowed" from Matt Howlett's 'fred' |
---|
| 394 | std::string out = ""; |
---|
| 395 | for( int i=0; i<s.size(); ++i ) { |
---|
| 396 | out += tolower(s[i]); |
---|
| 397 | } |
---|
| 398 | return out; |
---|
[3] | 399 | } |
---|
| 400 | |
---|
[378] | 401 | inline std::string stringize(bool b) |
---|
| 402 | { |
---|
| 403 | /** |
---|
| 404 | * Convert a bool variable to the textual equivalent. |
---|
| 405 | * \return A std::string with the english equivalent of the bool. |
---|
| 406 | */ |
---|
| 407 | std::string output; |
---|
| 408 | if(b) output="true"; |
---|
| 409 | else output="false"; |
---|
| 410 | return output; |
---|
| 411 | } |
---|
[274] | 412 | |
---|
[378] | 413 | inline bool boolify( std::string s ) |
---|
| 414 | { |
---|
| 415 | /** |
---|
| 416 | * Convert a std::string to a bool variable: |
---|
| 417 | * "1" and "true" get converted to true; |
---|
| 418 | * "0" and "false" (and anything else) get converted to false. |
---|
| 419 | * \return The bool equivalent of the string. |
---|
| 420 | */ |
---|
| 421 | if((s=="1") || (makelower(s)=="true")) return true; |
---|
| 422 | else if((s=="0") || (makelower(s)=="false")) return false; |
---|
| 423 | else return false; |
---|
| 424 | } |
---|
[132] | 425 | |
---|
[378] | 426 | inline std::string readSval(std::stringstream& ss) |
---|
| 427 | { |
---|
| 428 | std::string val; ss >> val; return val; |
---|
| 429 | } |
---|
[163] | 430 | |
---|
[378] | 431 | inline bool readFlag(std::stringstream& ss) |
---|
| 432 | { |
---|
| 433 | std::string val; ss >> val; return boolify(val); |
---|
| 434 | } |
---|
[163] | 435 | |
---|
[378] | 436 | inline float readFval(std::stringstream& ss) |
---|
| 437 | { |
---|
| 438 | float val; ss >> val; return val; |
---|
| 439 | } |
---|
[163] | 440 | |
---|
[378] | 441 | inline int readIval(std::stringstream& ss) |
---|
| 442 | { |
---|
| 443 | int val; ss >> val; return val; |
---|
| 444 | } |
---|
[163] | 445 | |
---|
[378] | 446 | int Param::readParams(std::string paramfile) |
---|
| 447 | { |
---|
| 448 | /** |
---|
| 449 | * The parameters are read in from a disk file, on the assumption that each |
---|
| 450 | * line of the file has the format "parameter value" (eg. alphafdr 0.1) |
---|
| 451 | * |
---|
| 452 | * The case of the parameter name does not matter, nor does the |
---|
| 453 | * formatting of the spaces (it can be any amount of whitespace or |
---|
| 454 | * tabs). |
---|
| 455 | * |
---|
| 456 | * \param paramfile A std::string containing the parameter filename. |
---|
| 457 | * |
---|
| 458 | * \return FAILURE if the parameter file does not exist. SUCCESS if |
---|
| 459 | * it is able to read it. |
---|
| 460 | */ |
---|
| 461 | std::ifstream fin(paramfile.c_str()); |
---|
| 462 | if(!fin.is_open()) return FAILURE; |
---|
| 463 | std::string line; |
---|
| 464 | while( !std::getline(fin,line,'\n').eof()){ |
---|
[3] | 465 | |
---|
[378] | 466 | if(line[0]!='#'){ |
---|
| 467 | std::stringstream ss; |
---|
| 468 | ss.str(line); |
---|
| 469 | std::string arg; |
---|
| 470 | ss >> arg; |
---|
| 471 | arg = makelower(arg); |
---|
| 472 | if(arg=="imagefile") this->imageFile = readSval(ss); |
---|
| 473 | if(arg=="flagsubsection") this->flagSubsection = readFlag(ss); |
---|
| 474 | if(arg=="subsection") this->pixelSec.setSection(readSval(ss)); |
---|
| 475 | if(arg=="flagreconexists") this->flagReconExists = readFlag(ss); |
---|
| 476 | if(arg=="reconfile") this->reconFile = readSval(ss); |
---|
| 477 | if(arg=="flagsmoothexists")this->flagSmoothExists = readFlag(ss); |
---|
| 478 | if(arg=="smoothfile") this->smoothFile = readSval(ss); |
---|
[71] | 479 | |
---|
[378] | 480 | if(arg=="flaglog") this->flagLog = readFlag(ss); |
---|
| 481 | if(arg=="logfile") this->logFile = readSval(ss); |
---|
| 482 | if(arg=="outfile") this->outFile = readSval(ss); |
---|
| 483 | if(arg=="flagseparateheader") this->flagSeparateHeader = readFlag(ss); |
---|
| 484 | if(arg=="headerfile") this->headerFile = readSval(ss); |
---|
| 485 | if(arg=="spectrafile") this->spectraFile = readSval(ss); |
---|
[379] | 486 | if(arg=="flagoutputmask") this->flagOutputMask = readFlag(ss); |
---|
[378] | 487 | if(arg=="flagoutputsmooth")this->flagOutputSmooth = readFlag(ss); |
---|
| 488 | if(arg=="flagoutputrecon") this->flagOutputRecon = readFlag(ss); |
---|
| 489 | if(arg=="flagoutputresid") this->flagOutputResid = readFlag(ss); |
---|
| 490 | if(arg=="flagvot") this->flagVOT = readFlag(ss); |
---|
| 491 | if(arg=="votfile") this->votFile = readSval(ss); |
---|
| 492 | if(arg=="flagkarma") this->flagKarma = readFlag(ss); |
---|
| 493 | if(arg=="karmafile") this->karmaFile = readSval(ss); |
---|
| 494 | if(arg=="flagmaps") this->flagMaps = readFlag(ss); |
---|
| 495 | if(arg=="detectionmap") this->detectionMap = readSval(ss); |
---|
| 496 | if(arg=="momentmap") this->momentMap = readSval(ss); |
---|
| 497 | if(arg=="flagxoutput") this->flagXOutput = readFlag(ss); |
---|
[3] | 498 | |
---|
[378] | 499 | if(arg=="flagnegative") this->flagNegative = readFlag(ss); |
---|
| 500 | if(arg=="flagtrim") this->flagTrim = readFlag(ss); |
---|
| 501 | if(arg=="flagmw") this->flagMW = readFlag(ss); |
---|
| 502 | if(arg=="maxmw") this->maxMW = readIval(ss); |
---|
| 503 | if(arg=="minmw") this->minMW = readIval(ss); |
---|
| 504 | if(arg=="beamsize") this->numPixBeam = readFval(ss); |
---|
[71] | 505 | |
---|
[378] | 506 | if(arg=="flagbaseline") this->flagBaseline = readFlag(ss); |
---|
| 507 | if(arg=="minpix") this->minPix = readIval(ss); |
---|
| 508 | if(arg=="flaggrowth") this->flagGrowth = readFlag(ss); |
---|
| 509 | if(arg=="growthcut") this->growthCut = readFval(ss); |
---|
[71] | 510 | |
---|
[378] | 511 | if(arg=="flagfdr") this->flagFDR = readFlag(ss); |
---|
| 512 | if(arg=="alphafdr") this->alphaFDR = readFval(ss); |
---|
[103] | 513 | |
---|
[378] | 514 | if(arg=="flagstatsec") this->flagStatSec = readFlag(ss); |
---|
| 515 | if(arg=="statsec") this->statSec.setSection(readSval(ss)); |
---|
[385] | 516 | if(arg=="flagrobuststats") this->flagRobustStats = readFlag(ss); |
---|
[378] | 517 | if(arg=="snrcut") this->snrCut = readFval(ss); |
---|
| 518 | if(arg=="threshold"){ |
---|
| 519 | this->threshold = readFval(ss); |
---|
| 520 | this->flagUserThreshold = true; |
---|
| 521 | } |
---|
[201] | 522 | |
---|
[378] | 523 | if(arg=="flagsmooth") this->flagSmooth = readFlag(ss); |
---|
| 524 | if(arg=="smoothtype") this->smoothType = readSval(ss); |
---|
| 525 | if(arg=="hanningwidth") this->hanningWidth = readIval(ss); |
---|
| 526 | if(arg=="kernmaj") this->kernMaj = readFval(ss); |
---|
| 527 | if(arg=="kernmin") this->kernMin = readFval(ss); |
---|
| 528 | if(arg=="kernpa") this->kernPA = readFval(ss); |
---|
[103] | 529 | |
---|
[378] | 530 | if(arg=="flagatrous") this->flagATrous = readFlag(ss); |
---|
| 531 | if(arg=="recondim") this->reconDim = readIval(ss); |
---|
| 532 | if(arg=="scalemin") this->scaleMin = readIval(ss); |
---|
| 533 | if(arg=="scalemax") this->scaleMax = readIval(ss); |
---|
| 534 | if(arg=="snrrecon") this->snrRecon = readFval(ss); |
---|
| 535 | if(arg=="filtercode"){ |
---|
| 536 | this->filterCode = readIval(ss); |
---|
| 537 | this->reconFilter.define(this->filterCode); |
---|
| 538 | } |
---|
[71] | 539 | |
---|
[378] | 540 | if(arg=="flagadjacent") this->flagAdjacent = readFlag(ss); |
---|
| 541 | if(arg=="threshspatial") this->threshSpatial = readFval(ss); |
---|
| 542 | if(arg=="threshvelocity") this->threshVelocity = readFval(ss); |
---|
| 543 | if(arg=="minchannels") this->minChannels = readIval(ss); |
---|
[71] | 544 | |
---|
[378] | 545 | if(arg=="spectralmethod") this->spectralMethod=makelower(readSval(ss)); |
---|
| 546 | if(arg=="spectralunits") this->spectralUnits = makelower(readSval(ss)); |
---|
| 547 | if(arg=="pixelcentre") this->pixelCentre = makelower(readSval(ss)); |
---|
| 548 | if(arg=="drawborders") this->borders = readFlag(ss); |
---|
| 549 | if(arg=="drawblankedges") this->blankEdge = readFlag(ss); |
---|
| 550 | if(arg=="verbose") this->verbose = readFlag(ss); |
---|
[295] | 551 | |
---|
[378] | 552 | // Dealing with deprecated parameters. |
---|
| 553 | if(arg=="flagblankpix"){ |
---|
| 554 | this->flagTrim = readFlag(ss); |
---|
| 555 | std::stringstream errmsg; |
---|
| 556 | errmsg <<"The parameter flagBlankPix is deprecated. " |
---|
| 557 | <<"Please use the flagTrim parameter in future.\n" |
---|
| 558 | <<"Setting flagTrim = " << stringize(this->flagTrim) << ".\n"; |
---|
| 559 | duchampWarning("Reading parameters",errmsg.str()); |
---|
| 560 | } |
---|
| 561 | if(arg=="blankpixvalue"){ |
---|
| 562 | std::stringstream errmsg; |
---|
| 563 | errmsg <<"The parameter blankPixValue is deprecated.\n" |
---|
| 564 | <<"This value is only taken from the FITS header.\n"; |
---|
| 565 | duchampWarning("Reading parameters",errmsg.str()); |
---|
| 566 | } |
---|
| 567 | |
---|
[295] | 568 | } |
---|
[378] | 569 | } |
---|
[295] | 570 | |
---|
[378] | 571 | // The wavelet reconstruction takes precendence over the smoothing. |
---|
| 572 | if(this->flagATrous) this->flagSmooth = false; |
---|
| 573 | |
---|
| 574 | // Make sure smoothType is an acceptable type -- default is "spectral" |
---|
| 575 | if((this->smoothType!="spectral")&& |
---|
| 576 | (this->smoothType!="spatial")){ |
---|
| 577 | std::stringstream errmsg; |
---|
| 578 | errmsg << "The requested value of the parameter smoothType, \"" |
---|
| 579 | << this->smoothType << "\" is invalid.\n" |
---|
| 580 | << "Changing to \"spectral\".\n"; |
---|
| 581 | duchampWarning("Reading parameters",errmsg.str()); |
---|
| 582 | this->smoothType = "spectral"; |
---|
[3] | 583 | } |
---|
[378] | 584 | // If kernMin has not been given, or is negative, make it equal to kernMaj |
---|
| 585 | if(this->kernMin < 0) this->kernMin = this->kernMaj; |
---|
[272] | 586 | |
---|
[378] | 587 | // Make sure spectralMethod is an acceptable type -- default is "peak" |
---|
| 588 | if((this->spectralMethod!="peak")&& |
---|
| 589 | (this->spectralMethod!="sum")){ |
---|
| 590 | std::stringstream errmsg; |
---|
| 591 | errmsg << "The requested value of the parameter spectralMethod, \"" |
---|
| 592 | << this->spectralMethod << "\" is invalid.\n" |
---|
| 593 | << "Changing to \"peak\".\n"; |
---|
| 594 | duchampWarning("Reading parameters",errmsg.str()); |
---|
| 595 | this->spectralMethod = "peak"; |
---|
| 596 | } |
---|
[232] | 597 | |
---|
[378] | 598 | // Make sure pixelCentre is an acceptable type -- default is "peak" |
---|
| 599 | if((this->pixelCentre!="centroid")&& |
---|
| 600 | (this->pixelCentre!="average") && |
---|
| 601 | (this->pixelCentre!="peak") ){ |
---|
| 602 | std::stringstream errmsg; |
---|
| 603 | errmsg << "The requested value of the parameter pixelCentre, \"" |
---|
| 604 | << this->pixelCentre << "\" is invalid.\n" |
---|
| 605 | << "Changing to \"centroid\".\n"; |
---|
| 606 | duchampWarning("Reading parameters",errmsg.str()); |
---|
| 607 | this->pixelCentre = "centroid"; |
---|
| 608 | } |
---|
[275] | 609 | |
---|
[378] | 610 | return SUCCESS; |
---|
[265] | 611 | } |
---|
| 612 | |
---|
| 613 | |
---|
[378] | 614 | std::ostream& operator<< ( std::ostream& theStream, Param& par) |
---|
| 615 | { |
---|
| 616 | /** |
---|
| 617 | * Print out the parameter set in a formatted, easy to read style. |
---|
| 618 | * Lists the parameters, a description of them, and their value. |
---|
| 619 | */ |
---|
[3] | 620 | |
---|
[378] | 621 | // Only show the [beamSize] bit if we are using the parameter |
---|
| 622 | // otherwise we have read it from the FITS header. |
---|
| 623 | std::string beamParam = ""; |
---|
| 624 | if(par.getFlagUsingBeam()) beamParam = "[beamSize]"; |
---|
[3] | 625 | |
---|
[378] | 626 | // BUG -- can get error: `boolalpha' is not a member of type `ios' -- old compilers: gcc 2.95.3? |
---|
| 627 | // theStream.setf(std::ios::boolalpha); |
---|
| 628 | theStream.setf(std::ios::left); |
---|
| 629 | theStream <<"\n---- Parameters ----"<<std::endl; |
---|
| 630 | theStream << std::setfill('.'); |
---|
| 631 | const int widthText = 38; |
---|
| 632 | const int widthPar = 18; |
---|
| 633 | if(par.getFlagSubsection()) |
---|
| 634 | theStream<<std::setw(widthText)<<"Image to be analysed" |
---|
| 635 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]" |
---|
| 636 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 637 | <<(par.getImageFile()+par.getSubsection()) <<std::endl; |
---|
| 638 | else |
---|
| 639 | theStream<<std::setw(widthText)<<"Image to be analysed" |
---|
| 640 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[imageFile]" |
---|
| 641 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 642 | <<par.getImageFile() <<std::endl; |
---|
| 643 | if(par.getFlagReconExists() && par.getFlagATrous()){ |
---|
| 644 | theStream<<std::setw(widthText)<<"Reconstructed array exists?" |
---|
| 645 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[reconExists]" |
---|
| 646 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 647 | <<stringize(par.getFlagReconExists())<<std::endl; |
---|
| 648 | theStream<<std::setw(widthText)<<"FITS file containing reconstruction" |
---|
| 649 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[reconFile]" |
---|
| 650 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 651 | <<par.getReconFile() <<std::endl; |
---|
| 652 | } |
---|
| 653 | if(par.getFlagSmoothExists() && par.getFlagSmooth()){ |
---|
| 654 | theStream<<std::setw(widthText)<<"Smoothed array exists?" |
---|
| 655 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothExists]" |
---|
| 656 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 657 | <<stringize(par.getFlagSmoothExists())<<std::endl; |
---|
| 658 | theStream<<std::setw(widthText)<<"FITS file containing smoothed array" |
---|
| 659 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothFile]" |
---|
| 660 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 661 | <<par.getSmoothFile() <<std::endl; |
---|
| 662 | } |
---|
| 663 | theStream <<std::setw(widthText)<<"Intermediate Logfile" |
---|
| 664 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[logFile]" |
---|
| 665 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 666 | <<par.getLogFile() <<std::endl; |
---|
| 667 | theStream <<std::setw(widthText)<<"Final Results file" |
---|
| 668 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[outFile]" |
---|
| 669 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 670 | <<par.getOutFile() <<std::endl; |
---|
| 671 | if(par.getFlagSeparateHeader()) |
---|
| 672 | theStream <<std::setw(widthText)<<"Header for results file" |
---|
| 673 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[headerFile]" |
---|
| 674 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 675 | <<par.getHeaderFile() <<std::endl; |
---|
| 676 | theStream <<std::setw(widthText)<<"Spectrum file" |
---|
| 677 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[spectraFile]" |
---|
| 678 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 679 | <<par.getSpectraFile() <<std::endl; |
---|
| 680 | if(par.getFlagVOT()){ |
---|
| 681 | theStream<<std::setw(widthText)<<"VOTable file" |
---|
| 682 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[votFile]" |
---|
| 683 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 684 | <<par.getVOTFile() <<std::endl; |
---|
| 685 | } |
---|
| 686 | if(par.getFlagKarma()){ |
---|
| 687 | theStream<<std::setw(widthText)<<"Karma annotation file" |
---|
| 688 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[karmaFile]" |
---|
| 689 | <<" = " <<resetiosflags(std::ios::right) |
---|
[172] | 690 | |
---|
[378] | 691 | <<par.getKarmaFile() <<std::endl; |
---|
| 692 | } |
---|
| 693 | if(par.getFlagMaps()){ |
---|
| 694 | theStream<<std::setw(widthText)<<"0th Moment Map" |
---|
| 695 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[momentMap]" |
---|
[275] | 696 | <<" = " <<resetiosflags(std::ios::right) |
---|
[378] | 697 | <<par.getMomentMap() <<std::endl; |
---|
| 698 | theStream<<std::setw(widthText)<<"Detection Map" |
---|
| 699 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[detectionMap]" |
---|
[275] | 700 | <<" = " <<resetiosflags(std::ios::right) |
---|
[378] | 701 | <<par.getDetectionMap() <<std::endl; |
---|
| 702 | } |
---|
| 703 | theStream <<std::setw(widthText)<<"Display a map in a pgplot xwindow?" |
---|
| 704 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagXOutput]" |
---|
[275] | 705 | <<" = " <<resetiosflags(std::ios::right) |
---|
[378] | 706 | <<stringize(par.getFlagXOutput()) <<std::endl; |
---|
| 707 | if(par.getFlagATrous()){ |
---|
| 708 | theStream<<std::setw(widthText)<<"Saving reconstructed cube?" |
---|
| 709 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagOutputRecon]" |
---|
[275] | 710 | <<" = " <<resetiosflags(std::ios::right) |
---|
[378] | 711 | <<stringize(par.getFlagOutputRecon())<<std::endl; |
---|
| 712 | theStream<<std::setw(widthText)<<"Saving residuals from reconstruction?" |
---|
| 713 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagOutputResid]" |
---|
| 714 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 715 | <<stringize(par.getFlagOutputResid())<<std::endl; |
---|
| 716 | } |
---|
| 717 | if(par.getFlagSmooth()){ |
---|
| 718 | theStream<<std::setw(widthText)<<"Saving smoothed cube?" |
---|
| 719 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagOutputSmooth]" |
---|
| 720 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 721 | <<stringize(par.getFlagOutputSmooth())<<std::endl; |
---|
| 722 | } |
---|
[379] | 723 | theStream<<std::setw(widthText)<<"Saving mask cube?" |
---|
| 724 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagOutputMask]" |
---|
| 725 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 726 | <<stringize(par.getFlagOutputMask())<<std::endl; |
---|
[378] | 727 | theStream <<"------"<<std::endl; |
---|
| 728 | if(par.getFlagBlankPix()){ |
---|
| 729 | theStream<<std::setw(widthText)<<"Blank Pixel Value" |
---|
| 730 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<< "" |
---|
| 731 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 732 | <<par.getBlankPixVal() <<std::endl; |
---|
[275] | 733 | } |
---|
[378] | 734 | theStream <<std::setw(widthText)<<"Trimming Blank Pixels?" |
---|
| 735 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagTrim]" |
---|
[348] | 736 | <<" = " <<resetiosflags(std::ios::right) |
---|
[378] | 737 | <<stringize(par.getFlagTrim()) <<std::endl; |
---|
| 738 | theStream <<std::setw(widthText)<<"Searching for Negative features?" |
---|
| 739 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagNegative]" |
---|
| 740 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 741 | <<stringize(par.getFlagNegative()) <<std::endl; |
---|
| 742 | theStream <<std::setw(widthText)<<"Removing Milky Way channels?" |
---|
| 743 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagMW]" |
---|
| 744 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 745 | <<stringize(par.getFlagMW()) <<std::endl; |
---|
| 746 | if(par.getFlagMW()){ |
---|
| 747 | theStream<<std::setw(widthText)<<"Milky Way Channels" |
---|
| 748 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[minMW - maxMW]" |
---|
| 749 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 750 | <<par.getMinMW() |
---|
| 751 | <<"-" <<par.getMaxMW() <<std::endl; |
---|
[348] | 752 | } |
---|
[378] | 753 | theStream <<std::setw(widthText)<<"Beam Size (pixels)" |
---|
| 754 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<< beamParam |
---|
[348] | 755 | <<" = " <<resetiosflags(std::ios::right) |
---|
[378] | 756 | <<par.getBeamSize() <<std::endl; |
---|
| 757 | theStream <<std::setw(widthText)<<"Removing baselines before search?" |
---|
| 758 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagBaseline]" |
---|
| 759 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 760 | <<stringize(par.getFlagBaseline()) <<std::endl; |
---|
| 761 | theStream <<std::setw(widthText)<<"Smoothing each spectrum first?" |
---|
| 762 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagSmooth]" |
---|
| 763 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 764 | <<stringize(par.getFlagSmooth()) <<std::endl; |
---|
| 765 | if(par.getFlagSmooth()){ |
---|
| 766 | theStream<<std::setw(widthText)<<"Type of smoothing" |
---|
| 767 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[smoothType]" |
---|
| 768 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 769 | <<par.getSmoothType() <<std::endl; |
---|
| 770 | if(par.getSmoothType()=="spectral") |
---|
| 771 | theStream<<std::setw(widthText)<<"Width of hanning filter" |
---|
| 772 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[hanningWidth]" |
---|
| 773 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 774 | <<par.getHanningWidth() <<std::endl; |
---|
| 775 | else{ |
---|
| 776 | theStream<<std::setw(widthText)<<"Gaussian kernel semi-major axis [pix]" |
---|
| 777 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[kernMaj]" |
---|
| 778 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 779 | <<par.getKernMaj() << std::endl; |
---|
| 780 | theStream<<std::setw(widthText)<<"Gaussian kernel semi-minor axis [pix]" |
---|
| 781 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[kernMin]" |
---|
| 782 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 783 | <<par.getKernMin() << std::endl; |
---|
| 784 | theStream<<std::setw(widthText)<<"Gaussian kernel position angle [deg]" |
---|
| 785 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[kernPA]" |
---|
| 786 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 787 | <<par.getKernPA() << std::endl; |
---|
| 788 | } |
---|
[348] | 789 | } |
---|
[378] | 790 | theStream <<std::setw(widthText)<<"Using A Trous reconstruction?" |
---|
| 791 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagATrous]" |
---|
[189] | 792 | <<" = " <<resetiosflags(std::ios::right) |
---|
[378] | 793 | <<stringize(par.getFlagATrous()) <<std::endl; |
---|
| 794 | if(par.getFlagATrous()){ |
---|
| 795 | theStream<<std::setw(widthText)<<"Number of dimensions in reconstruction" |
---|
| 796 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[reconDim]" |
---|
| 797 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 798 | <<par.getReconDim() <<std::endl; |
---|
| 799 | if(par.getMaxScale()>0){ |
---|
| 800 | theStream<<std::setw(widthText-1)<<"Scales used in reconstruction" |
---|
| 801 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[scaleMin-scaleMax]" |
---|
| 802 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 803 | <<par.getMinScale() << "-" << par.getMaxScale() <<std::endl; |
---|
| 804 | } |
---|
| 805 | else{ |
---|
| 806 | theStream<<std::setw(widthText)<<"Minimum scale in reconstruction" |
---|
| 807 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[scaleMin]" |
---|
| 808 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 809 | <<par.getMinScale() <<std::endl; |
---|
| 810 | } |
---|
| 811 | theStream<<std::setw(widthText)<<"SNR Threshold within reconstruction" |
---|
| 812 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[snrRecon]" |
---|
| 813 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 814 | <<par.getAtrousCut() <<std::endl; |
---|
| 815 | theStream<<std::setw(widthText)<<"Filter being used for reconstruction" |
---|
| 816 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[filterCode]" |
---|
| 817 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 818 | <<par.getFilterCode() |
---|
| 819 | << " (" << par.getFilterName() << ")" <<std::endl; |
---|
| 820 | } |
---|
[385] | 821 | theStream <<std::setw(widthText)<<"Using Robust statistics?" |
---|
| 822 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagRobustStats]" |
---|
| 823 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 824 | <<stringize(par.getFlagRobustStats()) <<std::endl; |
---|
[378] | 825 | if(par.getFlagStatSec()){ |
---|
| 826 | theStream<<std::setw(widthText)<<"Section used by statistics calculation" |
---|
| 827 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[statSec]" |
---|
| 828 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 829 | <<par.statSec.getSection() <<std::endl; |
---|
[189] | 830 | } |
---|
[378] | 831 | theStream <<std::setw(widthText)<<"Using FDR analysis?" |
---|
| 832 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagFDR]" |
---|
[189] | 833 | <<" = " <<resetiosflags(std::ios::right) |
---|
[378] | 834 | <<stringize(par.getFlagFDR()) <<std::endl; |
---|
| 835 | if(par.getFlagFDR()){ |
---|
| 836 | theStream<<std::setw(widthText)<<"Alpha value for FDR analysis" |
---|
| 837 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[alphaFDR]" |
---|
| 838 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 839 | <<par.getAlpha() <<std::endl; |
---|
| 840 | } |
---|
| 841 | else { |
---|
| 842 | if(par.getFlagUserThreshold()){ |
---|
| 843 | theStream<<std::setw(widthText)<<"Detection Threshold" |
---|
| 844 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[threshold]" |
---|
| 845 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 846 | <<par.getThreshold() <<std::endl; |
---|
| 847 | } |
---|
| 848 | else{ |
---|
| 849 | theStream<<std::setw(widthText)<<"SNR Threshold (in sigma)" |
---|
| 850 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[snrCut]" |
---|
| 851 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 852 | <<par.getCut() <<std::endl; |
---|
| 853 | } |
---|
[189] | 854 | } |
---|
[378] | 855 | theStream <<std::setw(widthText)<<"Minimum # Pixels in a detection" |
---|
| 856 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[minPix]" |
---|
| 857 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 858 | <<par.getMinPix() <<std::endl; |
---|
| 859 | theStream <<std::setw(widthText)<<"Minimum # Channels in a detection" |
---|
| 860 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[minChannels]" |
---|
| 861 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 862 | <<par.getMinChannels() <<std::endl; |
---|
| 863 | theStream <<std::setw(widthText)<<"Growing objects after detection?" |
---|
| 864 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagGrowth]" |
---|
| 865 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 866 | <<stringize(par.getFlagGrowth()) <<std::endl; |
---|
| 867 | if(par.getFlagGrowth()) { |
---|
| 868 | theStream<<std::setw(widthText)<<"SNR Threshold for growth" |
---|
| 869 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[growthCut]" |
---|
| 870 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 871 | <<par.getGrowthCut() <<std::endl; |
---|
| 872 | } |
---|
| 873 | theStream <<std::setw(widthText)<<"Using Adjacent-pixel criterion?" |
---|
| 874 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[flagAdjacent]" |
---|
| 875 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 876 | <<stringize(par.getFlagAdjacent()) <<std::endl; |
---|
| 877 | if(!par.getFlagAdjacent()){ |
---|
| 878 | theStream<<std::setw(widthText)<<"Max. spatial separation for merging" |
---|
| 879 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[threshSpatial]" |
---|
| 880 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 881 | <<par.getThreshS() <<std::endl; |
---|
| 882 | } |
---|
| 883 | theStream <<std::setw(widthText)<<"Max. velocity separation for merging" |
---|
| 884 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[threshVelocity]" |
---|
| 885 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 886 | <<par.getThreshV() <<std::endl; |
---|
| 887 | theStream <<std::setw(widthText)<<"Method of spectral plotting" |
---|
| 888 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[spectralMethod]" |
---|
| 889 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 890 | <<par.getSpectralMethod() <<std::endl; |
---|
| 891 | theStream <<std::setw(widthText)<<"Type of object centre used in results" |
---|
| 892 | <<std::setw(widthPar)<<setiosflags(std::ios::right)<<"[pixelCentre]" |
---|
| 893 | <<" = " <<resetiosflags(std::ios::right) |
---|
| 894 | <<par.getPixelCentre() <<std::endl; |
---|
| 895 | theStream <<"--------------------\n\n"; |
---|
| 896 | theStream << std::setfill(' '); |
---|
| 897 | theStream.unsetf(std::ios::left); |
---|
| 898 | // theStream.unsetf(std::ios::boolalpha); |
---|
| 899 | return theStream; |
---|
[3] | 900 | } |
---|
| 901 | |
---|
[120] | 902 | |
---|
[378] | 903 | void Param::copyHeaderInfo(FitsHeader &head) |
---|
| 904 | { |
---|
| 905 | /** |
---|
| 906 | * A function to copy across relevant header keywords from the |
---|
| 907 | * FitsHeader class to the Param class, as they are needed by |
---|
| 908 | * functions in the Param class. |
---|
| 909 | * The parameters are the keywords BLANK, BSCALE, BZERO, and the beam size. |
---|
| 910 | */ |
---|
[112] | 911 | |
---|
[378] | 912 | this->blankKeyword = head.getBlankKeyword(); |
---|
| 913 | this->bscaleKeyword = head.getBscaleKeyword(); |
---|
| 914 | this->bzeroKeyword = head.getBzeroKeyword(); |
---|
| 915 | this->blankPixValue = this->blankKeyword * this->bscaleKeyword + |
---|
| 916 | this->bzeroKeyword; |
---|
[112] | 917 | |
---|
[378] | 918 | this->numPixBeam = head.getBeamSize(); |
---|
| 919 | } |
---|
[112] | 920 | |
---|
[379] | 921 | std::string Param::outputMaskFile() |
---|
| 922 | { |
---|
| 923 | /** |
---|
| 924 | * This function produces the required filename in which to save |
---|
| 925 | * the mask image, indicating which pixels have been detected as |
---|
| 926 | * part of an object. If the input image is image.fits, then the |
---|
| 927 | * output will be image.MASK.fits. |
---|
| 928 | */ |
---|
| 929 | std::string inputName = this->imageFile; |
---|
| 930 | std::stringstream ss; |
---|
| 931 | ss << inputName.substr(0,inputName.size()-5); |
---|
| 932 | // remove the ".fits" on the end. |
---|
| 933 | ss << ".MASK.fits"; |
---|
| 934 | return ss.str(); |
---|
| 935 | } |
---|
| 936 | |
---|
[378] | 937 | std::string Param::outputSmoothFile() |
---|
| 938 | { |
---|
| 939 | /** |
---|
| 940 | * This function produces the required filename in which to save |
---|
| 941 | * the smoothed array. If the input image is image.fits, then |
---|
| 942 | * the output will be: |
---|
| 943 | * <ul><li> Spectral smoothing: image.SMOOTH-1D-3.fits, where the |
---|
| 944 | * width of the Hanning filter was 3 pixels. |
---|
| 945 | * <li> Spatial smoothing : image.SMOOTH-2D-3-2-20.fits, where |
---|
| 946 | * kernMaj=3, kernMin=2 and kernPA=20 degrees. |
---|
| 947 | * </ul> |
---|
| 948 | */ |
---|
| 949 | std::string inputName = this->imageFile; |
---|
| 950 | std::stringstream ss; |
---|
| 951 | ss << inputName.substr(0,inputName.size()-5); |
---|
| 952 | // remove the ".fits" on the end. |
---|
| 953 | if(this->flagSubsection) ss<<".sub"; |
---|
| 954 | if(this->smoothType=="spectral") |
---|
| 955 | ss << ".SMOOTH-1D-" << this->hanningWidth << ".fits"; |
---|
| 956 | else if(this->smoothType=="spatial") |
---|
| 957 | ss << ".SMOOTH-2D-" |
---|
| 958 | << this->kernMaj << "-" |
---|
| 959 | << this->kernMin << "-" |
---|
| 960 | << this->kernPA << ".fits"; |
---|
| 961 | return ss.str(); |
---|
| 962 | } |
---|
[208] | 963 | |
---|
[378] | 964 | std::string Param::outputReconFile() |
---|
| 965 | { |
---|
| 966 | /** |
---|
| 967 | * This function produces the required filename in which to save |
---|
| 968 | * the reconstructed array. If the input image is image.fits, then |
---|
| 969 | * the output will be eg. image.RECON-3-2-4-1.fits, where the numbers are |
---|
| 970 | * 3=reconDim, 2=filterCode, 4=snrRecon, 1=minScale |
---|
| 971 | */ |
---|
| 972 | std::string inputName = this->imageFile; |
---|
| 973 | std::stringstream ss; |
---|
| 974 | // First we remove the ".fits" from the end of the filename. |
---|
| 975 | ss << inputName.substr(0,inputName.size()-5); |
---|
| 976 | if(this->flagSubsection) ss<<".sub"; |
---|
| 977 | ss << ".RECON-" << this->reconDim |
---|
| 978 | << "-" << this->filterCode |
---|
| 979 | << "-" << this->snrRecon |
---|
| 980 | << "-" << this->scaleMin |
---|
| 981 | << ".fits"; |
---|
| 982 | return ss.str(); |
---|
| 983 | } |
---|
[103] | 984 | |
---|
[378] | 985 | std::string Param::outputResidFile() |
---|
| 986 | { |
---|
| 987 | /** |
---|
| 988 | * This function produces the required filename in which to save |
---|
| 989 | * the reconstructed array. If the input image is image.fits, then |
---|
| 990 | * the output will be eg. image.RESID-3-2-4-1.fits, where the numbers are |
---|
| 991 | * 3=reconDim, 2=filterCode, 4=snrRecon, 1=scaleMin |
---|
| 992 | */ |
---|
| 993 | std::string inputName = this->imageFile; |
---|
| 994 | std::stringstream ss; |
---|
| 995 | // First we remove the ".fits" from the end of the filename. |
---|
| 996 | ss << inputName.substr(0,inputName.size()-5); |
---|
| 997 | if(this->flagSubsection) ss<<".sub"; |
---|
| 998 | ss << ".RESID-" << this->reconDim |
---|
| 999 | << "-" << this->filterCode |
---|
| 1000 | << "-" << this->snrRecon |
---|
| 1001 | << "-" << this->scaleMin |
---|
| 1002 | << ".fits"; |
---|
| 1003 | return ss.str(); |
---|
| 1004 | } |
---|
| 1005 | |
---|
[103] | 1006 | } |
---|