[3] | 1 | #ifndef PARAM_H |
---|
| 2 | #define PARAM_H |
---|
| 3 | |
---|
| 4 | #include <iostream> |
---|
| 5 | #include <string> |
---|
| 6 | #include <vector> |
---|
[170] | 7 | #include <math.h> |
---|
[103] | 8 | #include <wcs.h> |
---|
[204] | 9 | #include <wcshdr.h> |
---|
[222] | 10 | #include <Utils/utils.hh> |
---|
[232] | 11 | #include <ATrous/filter.hh> |
---|
[3] | 12 | |
---|
[221] | 13 | class FitsHeader; // foreshadow this so that Param knows it exists |
---|
| 14 | |
---|
[3] | 15 | /** |
---|
[221] | 16 | * Class to store general parameters. |
---|
| 17 | * |
---|
| 18 | * This is a general repository for parameters that are used by all |
---|
| 19 | * functions. This is how the user interacts with the program, as |
---|
| 20 | * parameters are read in from disk files through functions in this |
---|
| 21 | * class. |
---|
[3] | 22 | */ |
---|
[112] | 23 | |
---|
[3] | 24 | class Param |
---|
| 25 | { |
---|
| 26 | public: |
---|
| 27 | Param(); |
---|
[204] | 28 | virtual ~Param(){if(sizeOffsets>0) delete [] offsets;}; |
---|
| 29 | Param(const Param& p); |
---|
[137] | 30 | Param& operator= (const Param& p); |
---|
[221] | 31 | //----------------- |
---|
| 32 | // Functions in param.cc |
---|
| 33 | // |
---|
| 34 | /** Read in parameters from a disk file. */ |
---|
[232] | 35 | int readParams(std::string paramfile); |
---|
[221] | 36 | |
---|
| 37 | /** Copy certain necessary FITS header parameters from a FitsHeader object */ |
---|
| 38 | void copyHeaderInfo(FitsHeader &head); |
---|
| 39 | |
---|
| 40 | /** Determine filename in which to save the Hanning-smoothed array. */ |
---|
[232] | 41 | std::string outputSmoothFile(); |
---|
[221] | 42 | |
---|
| 43 | /** Determine filename in which to save the reconstructed array. */ |
---|
[232] | 44 | std::string outputReconFile(); |
---|
[221] | 45 | |
---|
| 46 | /** Determine filename in which to save the residual array from the atrous reconstruction. */ |
---|
[232] | 47 | std::string outputResidFile(); |
---|
[221] | 48 | |
---|
| 49 | /** Print the parameter set in a readable fashion. */ |
---|
[3] | 50 | friend std::ostream& operator<< ( std::ostream& theStream, Param& par); |
---|
| 51 | friend class Image; |
---|
[221] | 52 | //------------------ |
---|
| 53 | // Functions in FitsIO/subsection.cc |
---|
[3] | 54 | // |
---|
[221] | 55 | /** Make sure the subsection string is OK, and read the axis subsections. */ |
---|
| 56 | int verifySubsection(); |
---|
| 57 | |
---|
| 58 | /** Set the correct offset values for each axis */ |
---|
| 59 | void setOffsets(struct wcsprm *wcs); |
---|
| 60 | //-------------------- |
---|
| 61 | // These are inline functions. |
---|
| 62 | // |
---|
| 63 | /** Is a pixel value a BLANK? |
---|
| 64 | * Tests whether the value passed as the argument is BLANK or not. |
---|
| 65 | * If flagBlankPix is false, return false. |
---|
| 66 | * Otherwise, compare to the relevant FITS keywords, using integer comparison. |
---|
| 67 | */ |
---|
| 68 | bool isBlank(float &value){ |
---|
| 69 | return this->flagBlankPix && |
---|
| 70 | (this->blankKeyword == int((value-this->bzeroKeyword)/this->bscaleKeyword)); |
---|
| 71 | }; |
---|
| 72 | |
---|
| 73 | /** Is a given channel flagged as being in the Milky Way?*/ |
---|
| 74 | bool isInMW(int z){return ( flagMW && (z>=minMW) && (z<=maxMW) );}; |
---|
| 75 | |
---|
| 76 | //-------------------- |
---|
| 77 | // Basic inline accessor functions |
---|
| 78 | // |
---|
[232] | 79 | std::string getImageFile(){return imageFile;}; |
---|
| 80 | void setImageFile(std::string fname){imageFile = fname;}; |
---|
| 81 | std::string getFullImageFile(){ |
---|
[106] | 82 | if(flagSubsection) return imageFile+subsection; |
---|
| 83 | else return imageFile; |
---|
| 84 | }; |
---|
[3] | 85 | bool getFlagSubsection(){return flagSubsection;}; |
---|
| 86 | void setFlagSubsection(bool flag){flagSubsection=flag;}; |
---|
[232] | 87 | std::string getSubsection(){return subsection;}; |
---|
| 88 | void setSubsection(std::string range){subsection = range;}; |
---|
[71] | 89 | bool getFlagReconExists(){return flagReconExists;}; |
---|
| 90 | void setFlagReconExists(bool flag){flagReconExists=flag;}; |
---|
[232] | 91 | std::string getReconFile(){return reconFile;}; |
---|
| 92 | void setReconFile(std::string file){reconFile = file;}; |
---|
[208] | 93 | bool getFlagSmoothExists(){return flagSmoothExists;}; |
---|
| 94 | void setFlagSmoothExists(bool flag){flagSmoothExists=flag;}; |
---|
[232] | 95 | std::string getSmoothFile(){return smoothFile;}; |
---|
| 96 | void setSmoothFile(std::string file){smoothFile = file;}; |
---|
[71] | 97 | // |
---|
[3] | 98 | bool getFlagLog(){return flagLog;}; |
---|
| 99 | void setFlagLog(bool flag){flagLog=flag;}; |
---|
[232] | 100 | std::string getLogFile(){return logFile;}; |
---|
| 101 | void setLogFile(std::string fname){logFile = fname;}; |
---|
| 102 | std::string getOutFile(){return outFile;}; |
---|
| 103 | void setOutFile(std::string fname){outFile = fname;}; |
---|
| 104 | std::string getSpectraFile(){return spectraFile;}; |
---|
| 105 | void setSpectraFile(std::string fname){spectraFile = fname;}; |
---|
[208] | 106 | bool getFlagOutputSmooth(){return flagOutputSmooth;}; |
---|
| 107 | void setFlagOutputSmooth(bool flag){flagOutputSmooth=flag;}; |
---|
[3] | 108 | bool getFlagOutputRecon(){return flagOutputRecon;}; |
---|
| 109 | void setFlagOutputRecon(bool flag){flagOutputRecon=flag;}; |
---|
| 110 | bool getFlagOutputResid(){return flagOutputResid;}; |
---|
| 111 | void setFlagOutputResid(bool flag){flagOutputResid=flag;}; |
---|
| 112 | bool getFlagVOT(){return flagVOT;}; |
---|
| 113 | void setFlagVOT(bool flag){flagVOT=flag;}; |
---|
[232] | 114 | std::string getVOTFile(){return votFile;}; |
---|
| 115 | void setVOTFile(std::string fname){votFile = fname;}; |
---|
[20] | 116 | bool getFlagKarma(){return flagKarma;}; |
---|
| 117 | void setFlagKarma(bool flag){flagKarma=flag;}; |
---|
[232] | 118 | std::string getKarmaFile(){return karmaFile;}; |
---|
| 119 | void setKarmaFile(std::string fname){karmaFile = fname;}; |
---|
[3] | 120 | bool getFlagMaps(){return flagMaps;}; |
---|
| 121 | void setFlagMaps(bool flag){flagMaps=flag;}; |
---|
[232] | 122 | std::string getDetectionMap(){return detectionMap;}; |
---|
| 123 | void setDetectionMap(std::string fname){detectionMap = fname;}; |
---|
| 124 | std::string getMomentMap(){return momentMap;}; |
---|
| 125 | void setMomentMap(std::string fname){momentMap = fname;}; |
---|
[195] | 126 | bool getFlagXOutput(){return flagXOutput;}; |
---|
| 127 | void setFlagXOutput(bool b){flagXOutput=b;}; |
---|
[3] | 128 | // |
---|
[60] | 129 | bool getFlagNegative(){return flagNegative;}; |
---|
| 130 | void setFlagNegative(bool flag){flagNegative=flag;}; |
---|
[3] | 131 | bool getFlagBlankPix(){return flagBlankPix;}; |
---|
| 132 | void setFlagBlankPix(bool flag){flagBlankPix=flag;}; |
---|
| 133 | float getBlankPixVal(){return blankPixValue;}; |
---|
| 134 | void setBlankPixVal(float v){blankPixValue=v;}; |
---|
| 135 | int getBlankKeyword(){return blankKeyword;}; |
---|
| 136 | void setBlankKeyword(int v){blankKeyword=v;}; |
---|
| 137 | float getBscaleKeyword(){return bscaleKeyword;}; |
---|
| 138 | void setBscaleKeyword(float v){bscaleKeyword=v;}; |
---|
| 139 | float getBzeroKeyword(){return bzeroKeyword;}; |
---|
| 140 | void setBzeroKeyword(float v){bzeroKeyword=v;}; |
---|
[103] | 141 | bool getFlagUsingBlank(){return flagUsingBlank;}; |
---|
| 142 | void setFlagUsingBlank(bool b){flagUsingBlank=b;}; |
---|
[3] | 143 | bool getFlagMW(){return flagMW;}; |
---|
| 144 | bool setFlagMW(bool flag){flagMW=flag;}; |
---|
| 145 | int getMaxMW(){return maxMW;}; |
---|
| 146 | void setMaxMW(int m){maxMW=m;}; |
---|
| 147 | int getMinMW(){return minMW;}; |
---|
| 148 | void setMinMW(int m){minMW=m;}; |
---|
| 149 | void setBeamSize(float s){numPixBeam = s;}; |
---|
| 150 | float getBeamSize(){return numPixBeam;}; |
---|
[172] | 151 | bool getFlagUsingBeam(){return flagUsingBeam;}; |
---|
| 152 | void setFlagUsingBeam(bool b){flagUsingBeam=b;}; |
---|
[3] | 153 | // |
---|
| 154 | bool getFlagCubeTrimmed(){return flagTrimmed;}; |
---|
| 155 | void setFlagCubeTrimmed(bool flag){flagTrimmed = flag;}; |
---|
| 156 | long getBorderLeft(){return borderLeft;}; |
---|
| 157 | void setBorderLeft(long b){borderLeft = b;}; |
---|
| 158 | long getBorderRight(){return borderRight;}; |
---|
| 159 | void setBorderRight(long b){borderRight = b;}; |
---|
| 160 | long getBorderBottom(){return borderBottom;}; |
---|
| 161 | void setBorderBottom(long b){borderBottom = b;}; |
---|
| 162 | long getBorderTop(){return borderTop;}; |
---|
| 163 | void setBorderTop(long b){borderTop = b;}; |
---|
| 164 | // |
---|
| 165 | long getXOffset(){return xSubOffset;}; |
---|
| 166 | void setXOffset(long o){xSubOffset = o;}; |
---|
| 167 | long getYOffset(){return ySubOffset;}; |
---|
| 168 | void setYOffset(long o){ySubOffset = o;}; |
---|
| 169 | long getZOffset(){return zSubOffset;}; |
---|
| 170 | void setZOffset(long o){zSubOffset = o;}; |
---|
| 171 | // |
---|
| 172 | int getMinPix(){return minPix;}; |
---|
| 173 | void setMinPix(int m){minPix=m;}; |
---|
| 174 | // |
---|
| 175 | bool getFlagGrowth(){return flagGrowth;}; |
---|
| 176 | void setFlagGrowth(bool flag){flagGrowth=flag;}; |
---|
| 177 | float getGrowthCut(){return growthCut;}; |
---|
| 178 | void setGrowthCut(float c){growthCut=c;}; |
---|
| 179 | // |
---|
| 180 | bool getFlagFDR(){return flagFDR;}; |
---|
| 181 | void setFlagFDR(bool flag){flagFDR=flag;}; |
---|
| 182 | float getAlpha(){return alphaFDR;}; |
---|
| 183 | void setAlpha(float a){alphaFDR=a;}; |
---|
| 184 | // |
---|
| 185 | bool getFlagBaseline(){return flagBaseline;}; |
---|
| 186 | void setFlagBaseline(bool flag){flagBaseline = flag;}; |
---|
| 187 | // |
---|
| 188 | float getCut(){return snrCut;}; |
---|
| 189 | void setCut(float c){snrCut=c;}; |
---|
[189] | 190 | float getThreshold(){return threshold;}; |
---|
| 191 | void setThreshold(float f){threshold=f;}; |
---|
[190] | 192 | bool getFlagUserThreshold(){return flagUserThreshold;}; |
---|
| 193 | void setFlagUserThreshold(bool b){flagUserThreshold=b;}; |
---|
[3] | 194 | // |
---|
[201] | 195 | bool getFlagSmooth(){return flagSmooth;}; |
---|
| 196 | void setFlagSmooth(bool b){flagSmooth=b;}; |
---|
| 197 | int getHanningWidth(){return hanningWidth;}; |
---|
| 198 | void setHanningWidth(int f){hanningWidth=f;}; |
---|
| 199 | // |
---|
[3] | 200 | bool getFlagATrous(){return flagATrous;}; |
---|
| 201 | void setFlagATrous(bool flag){flagATrous=flag;}; |
---|
[103] | 202 | int getReconDim(){return reconDim;}; |
---|
| 203 | void setReconDim(int i){reconDim=i;}; |
---|
[3] | 204 | int getMinScale(){return scaleMin;}; |
---|
| 205 | void setMinScale(int s){scaleMin=s;}; |
---|
| 206 | float getAtrousCut(){return snrRecon;}; |
---|
| 207 | void setAtrousCut(float c){snrRecon=c;}; |
---|
| 208 | int getFilterCode(){return filterCode;}; |
---|
| 209 | void setFilterCode(int c){filterCode=c;}; |
---|
[232] | 210 | std::string getFilterName(){return reconFilter.getName();}; |
---|
| 211 | Filter& filter(){ Filter &rfilter = reconFilter; return rfilter; }; |
---|
[3] | 212 | // |
---|
| 213 | bool getFlagAdjacent(){return flagAdjacent;}; |
---|
| 214 | void setFlagAdjacent(bool flag){flagAdjacent=flag;}; |
---|
| 215 | float getThreshS(){return threshSpatial;}; |
---|
| 216 | void setThreshS(float t){threshSpatial=t;}; |
---|
| 217 | float getThreshV(){return threshVelocity;}; |
---|
| 218 | void setThreshV(float t){threshVelocity=t;}; |
---|
| 219 | int getMinChannels(){return minChannels;}; |
---|
| 220 | void setMinChannels(int n){minChannels=n;}; |
---|
| 221 | // |
---|
[232] | 222 | std::string getSpectralMethod(){return spectralMethod;}; |
---|
| 223 | void setSpectralMethod(std::string s){spectralMethod=s;}; |
---|
| 224 | std::string getSpectralUnits(){return spectralUnits;}; |
---|
| 225 | void setSpectralUnits(std::string s){spectralUnits=s;}; |
---|
[3] | 226 | bool drawBorders(){return borders;}; |
---|
| 227 | void setDrawBorders(bool f){borders=f;}; |
---|
[142] | 228 | bool drawBlankEdge(){return blankEdge;}; |
---|
| 229 | void setDrawBlankEdge(bool f){blankEdge=f;}; |
---|
[221] | 230 | |
---|
| 231 | /** Are we in verbose mode? */ |
---|
[3] | 232 | bool isVerbose(){return verbose;}; |
---|
| 233 | void setVerbosity(bool f){verbose=f;}; |
---|
| 234 | |
---|
| 235 | private: |
---|
| 236 | // Input files |
---|
[232] | 237 | std::string imageFile; ///< The image to be analysed. |
---|
[221] | 238 | bool flagSubsection; ///< Whether we just want a subsection of the image |
---|
[232] | 239 | std::string subsection; ///< The subsection requested, taking the form [x1:x2,y1:y2,z1:z2]. If you want the full range of one index, use * |
---|
[221] | 240 | bool flagReconExists; ///< The reconstructed array is in a FITS file on disk. |
---|
[232] | 241 | std::string reconFile; ///< The FITS file containing the reconstructed array. |
---|
[221] | 242 | bool flagSmoothExists;///< The Hanning-smoothed array is in a FITS file. |
---|
[232] | 243 | std::string smoothFile; ///< The FITS file containing the smoothed array. |
---|
[71] | 244 | |
---|
[3] | 245 | // Output files |
---|
[221] | 246 | bool flagLog; ///< Should we do the intermediate logging? |
---|
[232] | 247 | std::string logFile; ///< Where the intermediate logging goes. |
---|
| 248 | std::string outFile; ///< Where the final results get put. |
---|
| 249 | std::string spectraFile; ///< Where the spectra are displayed |
---|
[221] | 250 | bool flagOutputSmooth;///< Should the Hanning-smoothed cube be written? |
---|
| 251 | bool flagOutputRecon; ///< Should the reconstructed cube be written? |
---|
| 252 | bool flagOutputResid; ///< Should the reconstructed cube be written? |
---|
| 253 | bool flagVOT; ///< Should we save results in VOTable format? |
---|
[232] | 254 | std::string votFile; ///< Where the VOTable goes. |
---|
[221] | 255 | bool flagKarma; ///< Should we save results in Karma annotation format? |
---|
[232] | 256 | std::string karmaFile; ///< Where the Karma annotation file goes. |
---|
[221] | 257 | bool flagMaps; ///< Should we produce detection and moment maps in postscript form? |
---|
[232] | 258 | std::string detectionMap; ///< The name of the detection map (ps file). |
---|
| 259 | std::string momentMap; ///< The name of the 0th moment map (ps file). |
---|
[221] | 260 | bool flagXOutput; ///< Should there be an xwindows output of the detection map? |
---|
[3] | 261 | |
---|
| 262 | // Cube related parameters |
---|
[221] | 263 | bool flagNegative; ///< Are we going to search for negative features? |
---|
| 264 | bool flagBlankPix; ///< A flag that indicates whether there are pixels defined as BLANK and whether we need to remove & ignore them in processing. |
---|
| 265 | float blankPixValue; ///< Pixel value that is considered BLANK. |
---|
| 266 | int blankKeyword; ///< The FITS header keyword BLANK. |
---|
| 267 | float bscaleKeyword; ///< The FITS header keyword BSCALE. |
---|
| 268 | float bzeroKeyword; ///< The FITS header keyword BZERO. |
---|
| 269 | bool flagUsingBlank; ///< If true, we are using the blankPixValue keyword, |
---|
| 270 | ///< otherwise we use the value in the FITS header. |
---|
| 271 | bool flagMW; ///< A flag that indicates whether to ignore the Milky Way channels. |
---|
| 272 | int maxMW; ///< Last Galactic velocity plane for HIPASS cubes |
---|
| 273 | int minMW; ///< First Galactic velocity plane for HIPASS cubes |
---|
| 274 | float numPixBeam; ///< Size (area) of the beam in pixels. |
---|
| 275 | bool flagUsingBeam; ///< If true, we are using the numPixBeam parameter, |
---|
| 276 | ///< otherwise we use the value in the FITS header. |
---|
| 277 | // Trim-related |
---|
| 278 | bool flagTrimmed; ///< Has the cube been trimmed of excess BLANKs around the edge? |
---|
| 279 | long borderLeft; ///< The number of BLANK pixels trimmed from the left of the cube; |
---|
| 280 | long borderRight; ///< The number trimmed from the Right of the cube; |
---|
| 281 | long borderBottom; ///< The number trimmed from the Bottom of the cube; |
---|
| 282 | long borderTop; ///< The number trimmed from the Top of the cube; |
---|
[3] | 283 | // Subsection offsets |
---|
[221] | 284 | long *offsets; ///< The array of offsets for each FITS axis. |
---|
| 285 | long sizeOffsets; ///< The size of the offsets array. |
---|
| 286 | long xSubOffset; ///< The offset in the x-direction from the subsection |
---|
| 287 | long ySubOffset; ///< The offset in the y-direction from the subsection |
---|
| 288 | long zSubOffset; ///< The offset in the z-direction from the subsection |
---|
| 289 | // Baseline related |
---|
| 290 | bool flagBaseline; ///< Whether to do baseline subtraction before reconstruction and/or searching. |
---|
| 291 | // Detection-related |
---|
| 292 | int minPix; ///< Minimum number of pixels for a detected object to be counted |
---|
| 293 | // Object growth |
---|
| 294 | bool flagGrowth; ///< Are we growing objects once they are found? |
---|
| 295 | float growthCut; ///< The SNR that we are growing objects down to. |
---|
| 296 | // FDR analysis |
---|
| 297 | bool flagFDR; ///< Should the FDR method be used? |
---|
| 298 | float alphaFDR; ///< Alpha value for FDR detection algorithm |
---|
| 299 | // Basic detection |
---|
| 300 | float snrCut; ///< How many sigma above mean is a detection when sigma-clipping |
---|
| 301 | float threshold; ///< What the threshold is (when sigma-clipping). |
---|
| 302 | bool flagUserThreshold;///< Whether the user has defined a threshold of their own. |
---|
[201] | 303 | // Smoothing of the cube |
---|
[221] | 304 | bool flagSmooth; ///< Should the cube be smoothed before searching? |
---|
| 305 | int hanningWidth; ///< Width for hanning smoothing. |
---|
[3] | 306 | // A trous reconstruction parameters |
---|
[221] | 307 | bool flagATrous; ///< Are we using the a trous reconstruction? |
---|
| 308 | int reconDim; ///< How many dimensions to use for the reconstruction? |
---|
| 309 | int scaleMin; ///< Min scale used in a trous reconstruction |
---|
| 310 | float snrRecon; ///< SNR cutoff used in a trous reconstruction (only wavelet coefficients that survive this threshold are kept) |
---|
[232] | 311 | Filter reconFilter; ///< The filter used for reconstructions. |
---|
[221] | 312 | int filterCode; ///< The code number for the filter to be used (saves having to parse names) |
---|
[232] | 313 | std::string filterName; ///< The code number converted into a name, for outputting purposes. |
---|
[3] | 314 | |
---|
| 315 | // Volume-merging parameters |
---|
[221] | 316 | bool flagAdjacent; ///< Whether to use the adjacent criterion for judging if objects are to be merged. |
---|
| 317 | float threshSpatial; ///< Maximum spatial separation between objects |
---|
| 318 | float threshVelocity; ///< Maximum channels separation between objects |
---|
| 319 | int minChannels; ///< Minimum no. of channels to make an object |
---|
[3] | 320 | // Input-Output related |
---|
[232] | 321 | std::string spectralMethod; ///< A string indicating choice of spectral plotting method: choices are "peak" (default) or "sum" |
---|
| 322 | std::string spectralUnits; ///< A string indicating what units the spectral axis should be quoted in. |
---|
[221] | 323 | bool borders; ///< Whether to draw a border around the individual pixels of a detection in the spectral display |
---|
| 324 | bool blankEdge; ///< Whether to draw a border around the BLANK pixel region in the moment maps and cutout images |
---|
| 325 | bool verbose; ///< Whether to use maximum verbosity -- use progress indicators in the reconstruction & merging steps. |
---|
[3] | 326 | |
---|
| 327 | }; |
---|
| 328 | |
---|
[221] | 329 | //=========================================================================== |
---|
| 330 | |
---|
| 331 | /** |
---|
| 332 | * Class to store FITS header information. |
---|
| 333 | * |
---|
| 334 | * Stores information from a FITS header, including WCS information |
---|
| 335 | * in the form of a wcsprm struct, as well as various keywords. |
---|
| 336 | */ |
---|
[103] | 337 | class FitsHeader |
---|
| 338 | { |
---|
[3] | 339 | |
---|
[103] | 340 | public: |
---|
| 341 | FitsHeader(); |
---|
[204] | 342 | virtual ~FitsHeader(){wcsvfree(&nwcs,&wcs);}; |
---|
[103] | 343 | FitsHeader(const FitsHeader& h); |
---|
| 344 | FitsHeader& operator= (const FitsHeader& h); |
---|
| 345 | |
---|
[221] | 346 | //-------------------- |
---|
| 347 | // Functions in param.cc |
---|
| 348 | // |
---|
| 349 | /** Assign correct WCS parameters. */ |
---|
| 350 | void setWCS(struct wcsprm *w); |
---|
| 351 | |
---|
| 352 | /** Return the WCS parameters in a WCSLIB wcsprm struct. */ |
---|
| 353 | struct wcsprm *getWCS(); |
---|
| 354 | |
---|
| 355 | // front ends to WCS functions |
---|
| 356 | /** Convert pixel coords to world coords for a single point. */ |
---|
[222] | 357 | int wcsToPix(const double *world, double *pix); |
---|
[221] | 358 | |
---|
| 359 | /** Convert pixel coords to world coords for many points. */ |
---|
[222] | 360 | int wcsToPix(const double *world, double *pix, const int npts); |
---|
[221] | 361 | |
---|
| 362 | /** Convert world coords to pixel coords for a single point. */ |
---|
[222] | 363 | int pixToWCS(const double *pix, double *world); |
---|
[221] | 364 | |
---|
| 365 | /** Convert world coords to pixel coords for many points. */ |
---|
[222] | 366 | int pixToWCS(const double *pix, double *world, const int npts); |
---|
[221] | 367 | |
---|
| 368 | /** Convert a (x,y,z) position to a velocity. */ |
---|
| 369 | double pixToVel(double &x, double &y, double &z); |
---|
| 370 | |
---|
| 371 | /** Convert a set of (x,y,z) positions to a set of velocities. */ |
---|
| 372 | double *pixToVel(double &x, double &y, double *zarray, int size); |
---|
| 373 | |
---|
| 374 | /** Convert a spectral coordinate to a velocity coordinate.*/ |
---|
| 375 | double specToVel(const double &z); |
---|
| 376 | |
---|
| 377 | /** Convert a velocity coordinate to a spectral coordinate.*/ |
---|
| 378 | double velToSpec(const float &vel); |
---|
| 379 | |
---|
| 380 | /** Get an IAU-style name for an equatorial or galactic coordinates. */ |
---|
[232] | 381 | std::string getIAUName(double ra, double dec); |
---|
[221] | 382 | |
---|
| 383 | /** Correct the units for the spectral axis */ |
---|
| 384 | void fixUnits(Param &par); |
---|
| 385 | |
---|
| 386 | //-------------------- |
---|
| 387 | // Functions in FitsIO/headerIO.cc |
---|
| 388 | // |
---|
| 389 | /** Read all header info. */ |
---|
[232] | 390 | int readHeaderInfo(std::string fname, Param &par); |
---|
[221] | 391 | |
---|
| 392 | /** Read BUNIT keyword */ |
---|
[232] | 393 | int readBUNIT(std::string fname); |
---|
[221] | 394 | |
---|
| 395 | /** Read BLANK & related keywords */ |
---|
[232] | 396 | int readBLANKinfo(std::string fname, Param &par); |
---|
[221] | 397 | |
---|
| 398 | /** Read beam-related keywords */ |
---|
[232] | 399 | int readBeamInfo(std::string fname, Param &par); |
---|
[221] | 400 | |
---|
| 401 | //-------------------- |
---|
| 402 | // Function in FitsIO/wcsIO.cc |
---|
| 403 | // |
---|
| 404 | /** Read the WCS information from a file. */ |
---|
[232] | 405 | int defineWCS(std::string fname, Param &par); |
---|
[221] | 406 | |
---|
| 407 | //-------------------- |
---|
| 408 | // Basic inline accessor functions |
---|
| 409 | // |
---|
| 410 | bool isWCS(){return wcsIsGood;}; |
---|
| 411 | int getNWCS(){return nwcs;}; |
---|
| 412 | void setNWCS(int i){nwcs=i;}; |
---|
[232] | 413 | std::string getSpectralUnits(){return spectralUnits;}; |
---|
| 414 | void setSpectralUnits(std::string s){spectralUnits=s;}; |
---|
| 415 | std::string getSpectralDescription(){return spectralDescription;}; |
---|
| 416 | void setSpectralDescription(std::string s){spectralDescription=s;}; |
---|
| 417 | std::string getFluxUnits(){return fluxUnits;}; |
---|
| 418 | void setFluxUnits(std::string s){fluxUnits=s;}; |
---|
| 419 | std::string getIntFluxUnits(){return intFluxUnits;}; |
---|
| 420 | void setIntFluxUnits(std::string s){intFluxUnits=s;}; |
---|
[103] | 421 | float getBeamSize(){return beamSize;}; |
---|
| 422 | void setBeamSize(float f){beamSize=f;}; |
---|
| 423 | float getBmajKeyword(){return bmajKeyword;}; |
---|
| 424 | void setBmajKeyword(float f){bmajKeyword=f;}; |
---|
| 425 | float getBminKeyword(){return bminKeyword;}; |
---|
| 426 | void setBminKeyword(float f){bminKeyword=f;}; |
---|
[112] | 427 | int getBlankKeyword(){return blankKeyword;}; |
---|
| 428 | void setBlankKeyword(int f){blankKeyword=f;}; |
---|
[103] | 429 | float getBzeroKeyword(){return bzeroKeyword;}; |
---|
| 430 | void setBzeroKeyword(float f){bzeroKeyword=f;}; |
---|
| 431 | float getBscaleKeyword(){return bscaleKeyword;}; |
---|
| 432 | void setBscaleKeyword(float f){bscaleKeyword=f;}; |
---|
[145] | 433 | float getAvPixScale(){ |
---|
| 434 | return sqrt( fabs ( (wcs->pc[0]*wcs->cdelt[0])* |
---|
| 435 | (wcs->pc[wcs->naxis+1]*wcs->cdelt[1]))); |
---|
| 436 | }; |
---|
[103] | 437 | |
---|
| 438 | |
---|
| 439 | private: |
---|
[221] | 440 | struct wcsprm *wcs; ///< The WCS parameters for the cube in a struct from the wcslib library. |
---|
| 441 | int nwcs; ///< The number of WCS parameters |
---|
| 442 | bool wcsIsGood; ///< A flag indicating whether there is a valid WCS present. |
---|
[232] | 443 | std::string spectralUnits; ///< The units of the spectral dimension |
---|
| 444 | std::string spectralDescription; ///< The description of the spectral dimension (Frequency, Velocity, ...) |
---|
| 445 | std::string fluxUnits; ///< The units of pixel flux (from header) |
---|
| 446 | std::string intFluxUnits; ///< The units of pixel flux (from header) |
---|
[221] | 447 | float beamSize; ///< The calculated beam size in pixels. |
---|
| 448 | float bmajKeyword; ///< The FITS header keyword BMAJ. |
---|
| 449 | float bminKeyword; ///< The FITS header keyword BMIN. |
---|
| 450 | int blankKeyword; ///< The FITS header keyword BLANK. |
---|
| 451 | float bzeroKeyword; ///< The FITS header keyword BZERO. |
---|
| 452 | float bscaleKeyword; ///< The FITS header keyword BSCALE. |
---|
| 453 | double scale; ///< scale param for converting spectral coords |
---|
| 454 | double offset; ///< offset param for converting spectral coords |
---|
| 455 | double power; ///< power param for converting spectral coords |
---|
[103] | 456 | }; |
---|
| 457 | |
---|
[232] | 458 | std::string makelower( std::string s ); |
---|
[103] | 459 | |
---|
[3] | 460 | #endif |
---|