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