source: trunk/src/fitsHeader.hh @ 297

Last change on this file since 297 was 291, checked in by Matthew Whiting, 17 years ago

Two basic changes:

  • Made Cube::objectList a pointer to a vector of Detections. This was to improve the memory usage, particularly for the case of many 1000s of detections (and especially in Merger.cc). This changed the way other Cube:: functions accessed it.
  • Made a new reference function to FitsHeader::wcs, so that we don't create a new wcsprm object each time we want to access wcs.lngtyp or similar.
File size: 5.7 KB
Line 
1#ifndef FITSHEADER_H
2#define FITSHEADER_H
3
4#include <string>
5#include <wcs.h>
6
7class Param;
8
9/**
10 *  Class to store FITS header information.
11 *
12 *   Stores information from a FITS header, including WCS information
13 *    in the form of a wcsprm struct, as well as various keywords.
14 */
15class FitsHeader
16{
17
18public:
19  FitsHeader();
20  virtual ~FitsHeader();
21  FitsHeader(const FitsHeader& h);
22  FitsHeader& operator= (const FitsHeader& h);
23
24  //--------------------
25  // Functions in param.cc
26  //
27  /** Assign correct WCS parameters.  */
28  void    setWCS(struct wcsprm *w);
29
30  /** Return the WCS parameters in a WCSLIB wcsprm struct. */
31  struct wcsprm *getWCS();
32
33  /** Provides a reference to the WCS parameters*/
34  struct wcsprm& WCS(){ struct wcsprm &rwcs = *wcs; return rwcs; };
35
36  // front ends to WCS functions
37  /** Convert pixel coords to world coords for a single point. */
38  int     wcsToPix(const double *world, double *pix);
39
40  /** Convert pixel coords to world coords for many points. */
41  int     wcsToPix(const double *world, double *pix, const int npts);
42
43  /** Convert world coords to pixel coords for a single point. */
44  int     pixToWCS(const double *pix, double *world);
45
46  /** Convert world coords to pixel coords for many points. */
47  int     pixToWCS(const double *pix, double *world, const int npts);
48
49  /** Convert a (x,y,z) position to a velocity. */
50  double  pixToVel(double &x, double &y, double &z);
51
52  /** Convert a set of  (x,y,z) positions to a set of velocities. */
53  double *pixToVel(double &x, double &y, double *zarray, int size);
54
55  /** Convert a spectral coordinate to a velocity coordinate.*/
56  double  specToVel(const double &z);
57
58  /** Convert a velocity coordinate to a spectral coordinate.*/
59  double  velToSpec(const float &vel);
60
61  /** Get an IAU-style name for an equatorial or galactic coordinates. */
62  std::string  getIAUName(double ra, double dec);
63
64  /** Correct the units for the spectral axis */
65  void    fixUnits(Param &par);
66 
67  //--------------------
68  // Functions in FitsIO/headerIO.cc
69  //
70  /** Read all header info. */
71  int     readHeaderInfo(std::string fname, Param &par);
72
73  /** Read BUNIT keyword */
74  int     readBUNIT(std::string fname);
75
76  /** Read BLANK & related keywords */
77  int     readBLANKinfo(std::string fname, Param &par);
78
79  /** Read beam-related keywords */
80  int     readBeamInfo(std::string fname, Param &par);
81 
82  //--------------------
83  // Function in FitsIO/wcsIO.cc
84  //
85  /** Read the WCS information from a file. */
86  int     defineWCS(std::string fname, Param &par);
87
88  //--------------------
89  // Basic inline accessor functions
90  //
91  /** Is the WCS good enough to be used? */
92  bool    isWCS(){return wcsIsGood;};
93  int     getNWCS(){return nwcs;};
94  void    setNWCS(int i){nwcs=i;};
95  int     getNumAxes(){return naxis;};
96  void    setNumAxes(int i){naxis=i;};
97  std::string  getSpectralUnits(){return spectralUnits;};
98  void    setSpectralUnits(std::string s){spectralUnits=s;};
99  std::string  getSpectralDescription(){return spectralDescription;};
100  void    setSpectralDescription(std::string s){spectralDescription=s;};
101  std::string  getFluxUnits(){return fluxUnits;};
102  void    setFluxUnits(std::string s){fluxUnits=s;};
103  std::string  getIntFluxUnits(){return intFluxUnits;};
104  void    setIntFluxUnits(std::string s){intFluxUnits=s;};
105  float   getBeamSize(){return beamSize;};
106  void    setBeamSize(float f){beamSize=f;};
107  float   getBmajKeyword(){return bmajKeyword;};
108  void    setBmajKeyword(float f){bmajKeyword=f;};
109  float   getBminKeyword(){return bminKeyword;};
110  void    setBminKeyword(float f){bminKeyword=f;};
111  float   getBpaKeyword(){return bpaKeyword;};
112  void    setBpaKeyword(float f){bpaKeyword=f;};
113  int     getBlankKeyword(){return blankKeyword;};
114  void    setBlankKeyword(int f){blankKeyword=f;};
115  float   getBzeroKeyword(){return bzeroKeyword;};
116  void    setBzeroKeyword(float f){bzeroKeyword=f;};
117  float   getBscaleKeyword(){return bscaleKeyword;};
118  void    setBscaleKeyword(float f){bscaleKeyword=f;};
119
120  /** Average the pixel scale (eg arcmin/pix) between the two
121      spatial axes, and return. */
122  float   getAvPixScale(){
123    return sqrt( fabs ( (wcs->pc[0]*wcs->cdelt[0])*
124                        (wcs->pc[wcs->naxis+1]*wcs->cdelt[1])));
125  };
126
127
128private:
129  struct wcsprm *wcs;           ///< The WCS parameters for the cube
130                                ///   in a struct from the wcslib
131                                ///   library.
132  int     nwcs;                 ///< The number of WCS parameters
133  bool    wcsIsGood;            ///< A flag indicating whether there
134                                ///   is a valid WCS present.
135  int     naxis;                ///< How many axes are in the header?
136  std::string  spectralUnits;        ///< The units of the spectral dimension
137  std::string  spectralDescription;  ///< The description of the
138                                     ///   spectral dimension (Frequency,
139                                     ///   Velocity, ...)
140  std::string  fluxUnits;       ///< The units of pixel flux (from header)
141  std::string  intFluxUnits;    ///< The units of integrated flux (from header)
142  float   beamSize;             ///< The calculated beam size in pixels.
143  float   bmajKeyword;          ///< The FITS header keyword BMAJ.
144  float   bminKeyword;          ///< The FITS header keyword BMIN.
145  float   bpaKeyword;           ///< The FITS header keyword BPA.
146  int     blankKeyword;         ///< The FITS header keyword BLANK.
147  float   bzeroKeyword;         ///< The FITS header keyword BZERO.
148  float   bscaleKeyword;        ///< The FITS header keyword BSCALE.
149  double  scale;                ///< scale parameter for converting
150                                ///   spectral coords
151  double  offset;               ///< offset parameter for converting
152                                ///   spectral coords
153  double  power;                ///< power parameter for converting
154                                ///   spectral coords
155};
156
157#endif // FITSHEADER_H
Note: See TracBrowser for help on using the repository browser.