All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Go to the documentation of this file.
1 /***************************************************************************
2  * GHealpix.hpp - Healpix projection class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2015 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GHealpix.hpp
23  * @brief HealPix projection class definition
24  * @author Juergen Knoedlseder
25  */
27 #ifndef GHEALPIX_HPP
28 #define GHEALPIX_HPP
30 /* __ Includes ___________________________________________________________ */
31 #include "GSkyProjection.hpp"
32 #include "GFitsHDU.hpp"
33 #include "GSkyDir.hpp"
34 #include "GSkyPixel.hpp"
35 #include "GBilinear.hpp"
38 /***********************************************************************//**
39  * @class GHealpix
40  *
41  * @brief HealPix projection class interface definition
42  *
43  * The HealPix projection class has been implemented by adapting code from
44  * the HealPix library (version 2.1). For more information about HEALPix, see
45  *
46  ***************************************************************************/
47 class GHealpix : public GSkyProjection {
49 public:
50  // Constructors and destructors
51  GHealpix(void);
52  GHealpix(const int& nside,
53  const std::string& ordering = "NESTED",
54  const std::string& coordsys = "EQU");
55  explicit GHealpix(const GFitsHDU& hdu);
56  GHealpix(const GHealpix& wcs);
57  virtual ~GHealpix(void);
59  // Operators
60  GHealpix& operator=(const GHealpix& wcs);
62  // Implemented pure virtual base class methods
63  virtual void clear(void);
64  virtual GHealpix* clone(void) const;
65  virtual std::string classname(void) const;
66  virtual int size(void) const;
67  virtual std::string code(void) const;
68  virtual std::string name(void) const;
69  virtual void read(const GFitsHDU& hdu);
70  virtual void write(GFitsHDU& hdu) const;
71  virtual double solidangle(const GSkyPixel& pixel) const;
72  virtual GSkyDir pix2dir(const GSkyPixel& pixel) const;
73  virtual GSkyPixel dir2pix(const GSkyDir& dir) const;
74  virtual GBilinear interpolator(const GSkyDir& dir) const;
75  virtual std::string print(const GChatter& chatter = NORMAL) const;
77  // Other methods
78  const int& npix(void) const;
79  const int& nside(void) const;
80  std::string ordering(void) const;
81  void ordering(const std::string& ordering);
82  std::vector<int> neighbours(const GSkyPixel& pixel) const;
83  std::vector<GSkyDir> boundaries(const GSkyPixel& pixel, const int& step = 1) const;
84  double max_pixrad(void) const;
86 private:
87  // Private methods
88  void init_members(void);
89  void copy_members(const GHealpix& wcs);
90  void free_members(void);
91  virtual bool compare(const GSkyProjection& proj) const;
93  // Low-level HealPix methods
94  int compress_bits(const int& value) const;
95  int spread_bits(const int& value) const;
96  void pix2xyf(const int& pix, int* ix, int* iy, int* face) const;
97  void nest2xyf(const int& pix, int* ix, int* iy, int* face) const;
98  void ring2xyf(const int& pix, int* ix, int* iy, int* face) const;
99  int xyf2nest(const int& ix, const int& iy, const int& face) const;
100  int xyf2ring(const int& ix, const int& iy, const int& face) const;
101  void xyf2loc(const double& x, const double& y, const int& face,
102  double* z, double* phi) const;
103  int nside2order(const int& nside) const;
104  int nest2ring(const int& pix) const;
105  int ring2nest(const int& pix) const;
106  void pix2xy(const int& ipix, int* x, int* y) const;
107  int xy2pix(int x, int y) const;
108  void pix2ang_ring(int ipix, double* theta, double* phi) const;
109  void pix2ang_nest(int ipix, double* theta, double* phi) const;
110  int ang2pix_z_phi_ring(double z, double phi) const;
111  int ang2pix_z_phi_nest(double z, double phi) const;
112  int ring_above(const double& z) const;
113  void get_ring_info(const int& ring, int* startpix, int* ringpix,
114  bool* shifted) const;
115  void get_ring_info(const int& ring, int* startpix, int* ringpix,
116  double* theta, bool* shifted) const;
117  GBilinear interpolator(const double& theta, const double& phi) const;
118  unsigned int isqrt(unsigned int arg) const;
119  GVector set_z_phi(const double& z, const double& phi) const;
120  GSkyDir loc2dir(const double& z, const double& phi) const;
122  // Private data area
123  int m_nside; //!< Number of divisions of each base pixel (1-8192)
124  int m_npface; //!<
125  int m_ncap; //!< Number of pixels in polar cap
126  int m_order; //!< Order
127  int m_ordering; //!< Pixel ordering (0=ring, 1=nested, -1=?)
128  int m_num_pixels; //!< Number of pixels in projection
129  double m_fact1; //!<
130  double m_fact2; //!<
131  double m_solidangle; //!< Solid angle of pixel
132 };
135 /***********************************************************************//**
136  * @brief Return class name
137  *
138  * @return String containing the class name ("GHealpix").
139  ***************************************************************************/
140 inline
141 std::string GHealpix::classname(void) const
142 {
143  return ("GHealpix");
144 }
147 /***********************************************************************//**
148  * @brief Return dimension of projection
149  *
150  * @return Dimension of projection.
151  *
152  * Returns the dimension of the projection.
153  ***************************************************************************/
154 inline
155 int GHealpix::size(void) const
156 {
157  return 1;
158 }
161 /***********************************************************************//**
162  * @brief Return projection code
163  *
164  * @return Projection code.
165  *
166  * Returns the projection code "HPX".
167  ***************************************************************************/
168 inline
169 std::string GHealpix::code(void) const
170 {
171  return "HPX";
172 }
175 /***********************************************************************//**
176  * @brief Return projection name
177  *
178  * @return Projection name.
179  *
180  * Returns the projection name.
181  ***************************************************************************/
182 inline
183 std::string GHealpix::name(void) const
184 {
185  return "HealPix";
186 }
189 /***********************************************************************//**
190  * @brief Returns number of pixels
191  ***************************************************************************/
192 inline
193 const int& GHealpix::npix(void) const
194 {
195  // Return number of pixels
196  return m_num_pixels;
197 }
200 /***********************************************************************//**
201  * @brief Returns number of divisions of the side of each base pixel.
202  ***************************************************************************/
203 inline
204 const int& GHealpix::nside(void) const
205 {
206  return m_nside;
207 }
210 /***********************************************************************//**
211  * @brief Returns solid angle of pixel
212  *
213  * @param[in] pixel Sky pixel.
214  * @return Solid angle of pixel.
215  *
216  * Returns the solid angle of the specified @p pixel. Note that HEALPix
217  * pixels have all the same solid angle, hence the @p pixel argument is in
218  * fact not used by the method.
219  ***************************************************************************/
220 inline
221 double GHealpix::solidangle(const GSkyPixel& pixel) const
222 {
223  return m_solidangle;
224 }
226 #endif /* GHEALPIX_HPP */
virtual std::string classname(void) const
Return class name.
Definition: GHealpix.hpp:141
double m_solidangle
Solid angle of pixel.
Definition: GHealpix.hpp:131
void nest2xyf(const int &pix, int *ix, int *iy, int *face) const
Convert pixel number in nested scheme to (x,y,face) tuple.
Definition: GHealpix.cpp:1020
void init_members(void)
Initialise class members.
Definition: GHealpix.cpp:845
virtual void clear(void)
Clear object.
Definition: GHealpix.cpp:255
Void constructor.
Definition: GHealpix.cpp:102
double m_fact1
Definition: GHealpix.hpp:129
const int & nside(void) const
Returns number of divisions of the side of each base pixel.
Definition: GHealpix.hpp:204
std::vector< int > neighbours(const GSkyPixel &pixel) const
Return neighbouring pixels of a pixel.
Definition: GHealpix.cpp:577
void copy_members(const GHealpix &wcs)
Copy class members.
Definition: GHealpix.cpp:878
GHealpix & operator=(const GHealpix &wcs)
Assignment operator.
Definition: GHealpix.cpp:220
Sky direction class interface definition.
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
virtual GSkyPixel dir2pix(const GSkyDir &dir) const
Returns sky map pixel of sky coordinate.
Definition: GHealpix.cpp:434
int m_order
Definition: GHealpix.hpp:126
virtual void read(const GFitsHDU &hdu)
Read Healpix definition from FITS header.
Definition: GHealpix.cpp:291
int m_nside
Number of divisions of each base pixel (1-8192)
Definition: GHealpix.hpp:123
unsigned int isqrt(unsigned int arg) const
Integer n that fulfills n*n &lt;= arg &lt; (n+1)*(n+1)
Definition: GHealpix.cpp:1890
double max_pixrad(void) const
Return maximum angular distance between pixel centre and corners.
Definition: GHealpix.cpp:777
virtual GBilinear interpolator(const GSkyDir &dir) const
Return interpolator for given sky direction.
Definition: GHealpix.cpp:475
virtual std::string print(const GChatter &chatter=NORMAL) const
Print WCS information.
Definition: GHealpix.cpp:801
void pix2ang_ring(int ipix, double *theta, double *phi) const
Convert pixel index to (theta,phi) angles for ring ordering.
Definition: GHealpix.cpp:1401
double m_fact2
Definition: GHealpix.hpp:130
void ring2xyf(const int &pix, int *ix, int *iy, int *face) const
Convert pixel number in ring scheme to (x,y,face) tuple.
Definition: GHealpix.cpp:1048
void get_ring_info(const int &ring, int *startpix, int *ringpix, bool *shifted) const
Returns useful information about a given ring of the projection.
Definition: GHealpix.cpp:1671
Abstract sky projection base class definition.
int nside2order(const int &nside) const
Convert nside to order.
Definition: GHealpix.cpp:1267
int m_ordering
Pixel ordering (0=ring, 1=nested, -1=?)
Definition: GHealpix.hpp:127
int xyf2ring(const int &ix, const int &iy, const int &face) const
Convert (x,y,face) tuple to pixel number in ring scheme.
Definition: GHealpix.cpp:1147
void pix2ang_nest(int ipix, double *theta, double *phi) const
Convert pixel index to (theta,phi) angles for nested ordering.
Definition: GHealpix.cpp:1451
int m_ncap
Number of pixels in polar cap.
Definition: GHealpix.hpp:125
Abstract FITS extension base class definition.
Sky map pixel class.
Definition: GSkyPixel.hpp:74
virtual GSkyDir pix2dir(const GSkyPixel &pixel) const
Returns sky direction of pixel.
Definition: GHealpix.cpp:385
HealPix projection class interface definition.
Definition: GHealpix.hpp:47
int spread_bits(const int &value) const
Spread Bits.
Definition: GHealpix.cpp:971
std::vector< GSkyDir > boundaries(const GSkyPixel &pixel, const int &step=1) const
Return pixel boundaries.
Definition: GHealpix.cpp:709
int ang2pix_z_phi_nest(double z, double phi) const
Returns pixel which contains angular coordinates (z,phi)
Definition: GHealpix.cpp:1565
GVector set_z_phi(const double &z, const double &phi) const
Return 3D vector.
Definition: GHealpix.cpp:1907
Bilinear interpolator class.
Definition: GBilinear.hpp:40
virtual double solidangle(const GSkyPixel &pixel) const
Returns solid angle of pixel.
Definition: GHealpix.hpp:221
int ring2nest(const int &pix) const
Converts pixel number in ring indexing scheme to nested scheme.
Definition: GHealpix.cpp:1334
virtual std::string name(void) const
Return projection name.
Definition: GHealpix.hpp:183
void pix2xy(const int &ipix, int *x, int *y) const
Convert pixel index to (x,y) coordinate.
Definition: GHealpix.cpp:1363
Definition: GTypemaps.hpp:33
int compress_bits(const int &value) const
Compress Bits.
Definition: GHealpix.cpp:951
const int & npix(void) const
Returns number of pixels.
Definition: GHealpix.hpp:193
int nest2ring(const int &pix) const
Converts pixel number in nested indexing scheme to ring scheme.
Definition: GHealpix.cpp:1300
int xyf2nest(const int &ix, const int &iy, const int &face) const
Convert (x,y,face) tuple to pixel number in nested scheme.
Definition: GHealpix.cpp:1125
virtual std::string coordsys(void) const
Returns coordinate system.
int xy2pix(int x, int y) const
Convert (x,y) coordinate to pixel.
Definition: GHealpix.cpp:1384
virtual bool compare(const GSkyProjection &proj) const
Returns true if argument is identical.
Definition: GHealpix.cpp:913
GSkyDir loc2dir(const double &z, const double &phi) const
Convert local coordinate into sky direction.
Definition: GHealpix.cpp:1236
int ang2pix_z_phi_ring(double z, double phi) const
Returns pixel which contains angular coordinates (z,phi)
Definition: GHealpix.cpp:1517
void xyf2loc(const double &x, const double &y, const int &face, double *z, double *phi) const
Convert (x,y,f) tuple into local coordinates.
Definition: GHealpix.cpp:1188
int m_npface
Definition: GHealpix.hpp:124
Bilinear interpolator class interface definition.
std::string ordering(void) const
Returns ordering parameter.
Definition: GHealpix.cpp:512
virtual ~GHealpix(void)
Definition: GHealpix.cpp:198
void pix2xyf(const int &pix, int *ix, int *iy, int *face) const
Convert pixel number in to (x,y,face) tuple.
Definition: GHealpix.cpp:992
Vector class.
Definition: GVector.hpp:46
virtual std::string code(void) const
Return projection code.
Definition: GHealpix.hpp:169
Abstract sky projection base class.
int m_num_pixels
Number of pixels in projection.
Definition: GHealpix.hpp:128
virtual GHealpix * clone(void) const
Clone instance.
Definition: GHealpix.cpp:273
int ring_above(const double &z) const
Get ring index north of cos(theta)
Definition: GHealpix.cpp:1633
virtual void write(GFitsHDU &hdu) const
Write Healpix definition into FITS HDU.
Definition: GHealpix.cpp:357
Sky map pixel class definition.
Sky direction class.
Definition: GSkyDir.hpp:62
virtual int size(void) const
Return dimension of projection.
Definition: GHealpix.hpp:155
void free_members(void)
Delete class members.
Definition: GHealpix.cpp:899