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