source: tags/release-1.1/src/fitsHeader.hh @ 1323

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

Adding distribution text at the start of each file...

File size: 7.0 KB
Line 
1// -----------------------------------------------------------------------
2// fitsHeader.hh: Information about the FITS file's header.
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// -----------------------------------------------------------------------
28#ifndef FITSHEADER_H
29#define FITSHEADER_H
30
31#include <string>
32#include <wcs.h>
33
34class Param;
35
36/**
37 *  Class to store FITS header information.
38 *
39 *   Stores information from a FITS header, including WCS information
40 *    in the form of a wcsprm struct, as well as various keywords.
41 */
42class FitsHeader
43{
44
45public:
46  FitsHeader();
47  virtual ~FitsHeader();
48  FitsHeader(const FitsHeader& h);
49  FitsHeader& operator= (const FitsHeader& h);
50
51  //--------------------
52  // Functions in param.cc
53  //
54  /** Assign correct WCS parameters.  */
55  void    setWCS(struct wcsprm *w);
56
57  /** Return the WCS parameters in a WCSLIB wcsprm struct. */
58  struct wcsprm *getWCS();
59
60  /** Provides a reference to the WCS parameters*/
61  struct wcsprm& WCS(){ struct wcsprm &rwcs = *wcs; return rwcs; };
62
63  // front ends to WCS functions
64  /** Convert pixel coords to world coords for a single point. */
65  int     wcsToPix(const double *world, double *pix);
66
67  /** Convert pixel coords to world coords for many points. */
68  int     wcsToPix(const double *world, double *pix, const int npts);
69
70  /** Convert world coords to pixel coords for a single point. */
71  int     pixToWCS(const double *pix, double *world);
72
73  /** Convert world coords to pixel coords for many points. */
74  int     pixToWCS(const double *pix, double *world, const int npts);
75
76  /** Convert a (x,y,z) position to a velocity. */
77  double  pixToVel(double &x, double &y, double &z);
78
79  /** Convert a set of  (x,y,z) positions to a set of velocities. */
80  double *pixToVel(double &x, double &y, double *zarray, int size);
81
82  /** Convert a spectral coordinate to a velocity coordinate.*/
83  double  specToVel(const double &z);
84
85  /** Convert a velocity coordinate to a spectral coordinate.*/
86  double  velToSpec(const float &vel);
87
88  /** Get an IAU-style name for an equatorial or galactic coordinates. */
89  std::string  getIAUName(double ra, double dec);
90
91  /** Correct the units for the spectral axis */
92  void    fixUnits(Param &par);
93 
94  //--------------------
95  // Functions in FitsIO/headerIO.cc
96  //
97  /** Read all header info. */
98  int     readHeaderInfo(std::string fname, Param &par);
99
100  /** Read BUNIT keyword */
101  int     readBUNIT(std::string fname);
102
103  /** Read BLANK & related keywords */
104  int     readBLANKinfo(std::string fname, Param &par);
105
106  /** Read beam-related keywords */
107  int     readBeamInfo(std::string fname, Param &par);
108 
109  //--------------------
110  // Function in FitsIO/wcsIO.cc
111  //
112  /** Read the WCS information from a file. */
113  int     defineWCS(std::string fname, Param &par);
114
115  //--------------------
116  // Basic inline accessor functions
117  //
118  /** Is the WCS good enough to be used? */
119  bool    isWCS(){return wcsIsGood;};
120  int     getNWCS(){return nwcs;};
121  void    setNWCS(int i){nwcs=i;};
122  int     getNumAxes(){return naxis;};
123  void    setNumAxes(int i){naxis=i;};
124  std::string  getSpectralUnits(){return spectralUnits;};
125  void    setSpectralUnits(std::string s){spectralUnits=s;};
126  std::string  getSpectralDescription(){return spectralDescription;};
127  void    setSpectralDescription(std::string s){spectralDescription=s;};
128  std::string  getFluxUnits(){return fluxUnits;};
129  void    setFluxUnits(std::string s){fluxUnits=s;};
130  std::string  getIntFluxUnits(){return intFluxUnits;};
131  void    setIntFluxUnits(std::string s){intFluxUnits=s;};
132  float   getBeamSize(){return beamSize;};
133  void    setBeamSize(float f){beamSize=f;};
134  float   getBmajKeyword(){return bmajKeyword;};
135  void    setBmajKeyword(float f){bmajKeyword=f;};
136  float   getBminKeyword(){return bminKeyword;};
137  void    setBminKeyword(float f){bminKeyword=f;};
138  float   getBpaKeyword(){return bpaKeyword;};
139  void    setBpaKeyword(float f){bpaKeyword=f;};
140  int     getBlankKeyword(){return blankKeyword;};
141  void    setBlankKeyword(int f){blankKeyword=f;};
142  float   getBzeroKeyword(){return bzeroKeyword;};
143  void    setBzeroKeyword(float f){bzeroKeyword=f;};
144  float   getBscaleKeyword(){return bscaleKeyword;};
145  void    setBscaleKeyword(float f){bscaleKeyword=f;};
146
147  /** Average the pixel scale (eg arcmin/pix) between the two
148      spatial axes, and return. */
149  float   getAvPixScale(){
150    return sqrt( fabs ( (wcs->pc[0]*wcs->cdelt[0])*
151                        (wcs->pc[wcs->naxis+1]*wcs->cdelt[1])));
152  };
153
154
155private:
156  struct wcsprm *wcs;           ///< The WCS parameters for the cube
157                                ///   in a struct from the wcslib
158                                ///   library.
159  int     nwcs;                 ///< The number of WCS parameters
160  bool    wcsIsGood;            ///< A flag indicating whether there
161                                ///   is a valid WCS present.
162  int     naxis;                ///< How many axes are in the header?
163  std::string  spectralUnits;        ///< The units of the spectral dimension
164  std::string  spectralDescription;  ///< The description of the
165                                     ///   spectral dimension (Frequency,
166                                     ///   Velocity, ...)
167  std::string  fluxUnits;       ///< The units of pixel flux (from header)
168  std::string  intFluxUnits;    ///< The units of integrated flux (from header)
169  float   beamSize;             ///< The calculated beam size in pixels.
170  float   bmajKeyword;          ///< The FITS header keyword BMAJ.
171  float   bminKeyword;          ///< The FITS header keyword BMIN.
172  float   bpaKeyword;           ///< The FITS header keyword BPA.
173  int     blankKeyword;         ///< The FITS header keyword BLANK.
174  float   bzeroKeyword;         ///< The FITS header keyword BZERO.
175  float   bscaleKeyword;        ///< The FITS header keyword BSCALE.
176  double  scale;                ///< scale parameter for converting
177                                ///   spectral coords
178  double  offset;               ///< offset parameter for converting
179                                ///   spectral coords
180  double  power;                ///< power parameter for converting
181                                ///   spectral coords
182};
183
184#endif // FITSHEADER_H
Note: See TracBrowser for help on using the repository browser.