| 1 | #ifndef SPHEREHEALPIX_SEEN | 
|---|
| 2 | #define SPHEREHEALPIX_SEEN | 
|---|
| 3 |  | 
|---|
| 4 | #include "sphericalmap.h" | 
|---|
| 5 | #include "tvector.h" | 
|---|
| 6 | #include "ndatablock.h" | 
|---|
| 7 |  | 
|---|
| 8 | #include "anydataobj.h" | 
|---|
| 9 | #include "ppersist.h" | 
|---|
| 10 |  | 
|---|
| 11 | #include "HEALPixUtils.h" | 
|---|
| 12 |  | 
|---|
| 13 | namespace SOPHYA { | 
|---|
| 14 |  | 
|---|
| 15 |  | 
|---|
| 16 | // ***************** CLASSE SphereHEALPix ***************************** | 
|---|
| 17 |  | 
|---|
| 18 | /*! Class SphereHEALPix */ | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | template<class T> | 
|---|
| 22 | class FIO_SphereHEALPix; | 
|---|
| 23 |  | 
|---|
| 24 | template<class T> | 
|---|
| 25 | class FITS_SphereHEALPix; | 
|---|
| 26 |  | 
|---|
| 27 | template<class T> | 
|---|
| 28 | class SphereHEALPix : public SphericalMap<T> | 
|---|
| 29 | { | 
|---|
| 30 | public : | 
|---|
| 31 | // Static Methods to ease the use of HEALPix index <> angle conversion methods | 
|---|
| 32 |  | 
|---|
| 33 | static inline int_4  nest2ring(int_4 nside,int_4 ipnest) | 
|---|
| 34 | { return HEALPix::nest2ring(nside, ipnest); } | 
|---|
| 35 | static inline int_4  ring2nest(int_4 nside,int_4 ipring) | 
|---|
| 36 | { return HEALPix::ring2nest(nside, ipring); } | 
|---|
| 37 | static inline int_4  ang2pix_ring(int_4 nside,double theta,double phi) | 
|---|
| 38 | { return HEALPix::ang2pix_ring(nside, theta, phi); } | 
|---|
| 39 | static inline int_4  ang2pix_nest(int_4 nside,double theta,double phi) | 
|---|
| 40 | { return HEALPix::ang2pix_nest(nside, theta, phi); } | 
|---|
| 41 | static inline void   pix2ang_ring(int_4 nside,int_4 ipix,double& theta,double& phi) | 
|---|
| 42 | { HEALPix::pix2ang_ring(nside, ipix, theta, phi); } | 
|---|
| 43 | static inline void   pix2ang_nest(int_4 nside,int_4 ipix,double& theta,double& phi) | 
|---|
| 44 | { HEALPix::pix2ang_nest(nside, ipix, theta, phi); } | 
|---|
| 45 |  | 
|---|
| 46 | SphereHEALPix(); | 
|---|
| 47 | SphereHEALPix(int_4 m); | 
|---|
| 48 | SphereHEALPix(const SphereHEALPix<T>& s, bool share); | 
|---|
| 49 | SphereHEALPix(const SphereHEALPix<T>& s); | 
|---|
| 50 | virtual ~SphereHEALPix(); | 
|---|
| 51 |  | 
|---|
| 52 | inline virtual bool   IsTemp(void) const { | 
|---|
| 53 |  | 
|---|
| 54 | if (sliceBeginIndex_.IsTemp() != pixels_.IsTemp() || sliceLenght_.IsTemp() != pixels_.IsTemp() ) | 
|---|
| 55 | throw PException(" l'etat 'temporaire' de la spherehealpix est incoherent"); | 
|---|
| 56 | return pixels_.IsTemp(); | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | inline virtual void SetTemp(bool temp=false) const | 
|---|
| 60 | { | 
|---|
| 61 | pixels_.SetTemp(temp); | 
|---|
| 62 | sliceBeginIndex_.SetTemp(temp); | 
|---|
| 63 | sliceLenght_.SetTemp(temp); | 
|---|
| 64 | }; | 
|---|
| 65 | // ------------------ Definition of PixelMap abstract methods | 
|---|
| 66 |  | 
|---|
| 67 | virtual int_4 NbPixels() const; | 
|---|
| 68 |  | 
|---|
| 69 | virtual T& PixVal(int_4 k); | 
|---|
| 70 | virtual T const& PixVal(int_4 k) const; | 
|---|
| 71 |  | 
|---|
| 72 | uint_4 NbThetaSlices() const; | 
|---|
| 73 | virtual void GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const; | 
|---|
| 74 | virtual void GetThetaSlice(int_4 sliceIndex,r_8& theta, r_8& phi0, TVector<int_4>& pixelIndices,TVector<T>& value) const ; | 
|---|
| 75 |  | 
|---|
| 76 | virtual bool ContainsSph(double theta, double phi) const; | 
|---|
| 77 | virtual int_4 PixIndexSph(double theta,double phi) const; | 
|---|
| 78 |  | 
|---|
| 79 | virtual void PixThetaPhi(int_4 k,double& theta,double& phi) const; | 
|---|
| 80 |  | 
|---|
| 81 | virtual T SetPixels(T v); | 
|---|
| 82 |  | 
|---|
| 83 | /*! Pixel Solid angle  (steradians) | 
|---|
| 84 |  | 
|---|
| 85 | All the pixels have the same solid angle. The dummy argument is | 
|---|
| 86 | for compatibility with eventual pixelizations which would not | 
|---|
| 87 | fulfil this requirement. | 
|---|
| 88 | */ | 
|---|
| 89 | inline virtual double PixSolAngle(int_4 dummy=0) const {return omeg_;} | 
|---|
| 90 |  | 
|---|
| 91 | /*  Acces to the DataBlock  */ | 
|---|
| 92 | inline       NDataBlock<T>& DataBlock()       {return pixels_;} | 
|---|
| 93 | inline const NDataBlock<T>& DataBlock() const {return pixels_;} | 
|---|
| 94 |  | 
|---|
| 95 | // --------------- Specific methods | 
|---|
| 96 |  | 
|---|
| 97 | virtual void Resize(int_4 m); | 
|---|
| 98 |  | 
|---|
| 99 | /*! | 
|---|
| 100 |  | 
|---|
| 101 | \return type of storage of the map : RING or NESTED | 
|---|
| 102 |  | 
|---|
| 103 | at the moment, always RING | 
|---|
| 104 | */ | 
|---|
| 105 | inline virtual char* TypeOfMap() const {return "RING";}; | 
|---|
| 106 |  | 
|---|
| 107 |  | 
|---|
| 108 | virtual T& PixValNest(int_4 k); | 
|---|
| 109 | virtual T const& PixValNest(int_4 k) const; | 
|---|
| 110 |  | 
|---|
| 111 | virtual int_4 PixIndexSphNest(double theta,double phi) const; | 
|---|
| 112 |  | 
|---|
| 113 | virtual void PixThetaPhiNest(int_4 k,double& theta,double& phi) const; | 
|---|
| 114 |  | 
|---|
| 115 | void Pixelize(int_4); | 
|---|
| 116 |  | 
|---|
| 117 | int_4 NestToRing(int_4) const; | 
|---|
| 118 |  | 
|---|
| 119 | int_4 RingToNest(int_4) const; | 
|---|
| 120 |  | 
|---|
| 121 |  | 
|---|
| 122 | /*! \return value of healpix nside */ | 
|---|
| 123 | inline virtual int_4 SizeIndex() const {return(nSide_);} | 
|---|
| 124 |  | 
|---|
| 125 | void print(ostream& os) const; | 
|---|
| 126 |  | 
|---|
| 127 |  | 
|---|
| 128 |  | 
|---|
| 129 | inline  SphereHEALPix<T>& operator = (const SphereHEALPix<T>& a) | 
|---|
| 130 | {return Set(a);} | 
|---|
| 131 |  | 
|---|
| 132 | void CloneOrShare(const SphereHEALPix<T>& a); | 
|---|
| 133 | SphereHEALPix<T>& Set(const SphereHEALPix<T>& a); | 
|---|
| 134 | SphereHEALPix<T>& CopyElt(const SphereHEALPix<T>& a); | 
|---|
| 135 |  | 
|---|
| 136 |  | 
|---|
| 137 | // friend declaration for classes which handle persistence and FITS IO | 
|---|
| 138 | friend class FIO_SphereHEALPix<T>; | 
|---|
| 139 | friend class FITS_SphereHEALPix<T>; | 
|---|
| 140 |  | 
|---|
| 141 | protected : | 
|---|
| 142 |  | 
|---|
| 143 | // ------------- méthodes internes ---------------------- | 
|---|
| 144 | void InitNul(); | 
|---|
| 145 | void SetThetaSlices(); | 
|---|
| 146 |  | 
|---|
| 147 | inline void setParameters(int_4 nside, int_4 nbpixels, double solangle) | 
|---|
| 148 | { | 
|---|
| 149 | nSide_= nside; | 
|---|
| 150 | nPix_= nbpixels; | 
|---|
| 151 | omeg_= solangle; | 
|---|
| 152 | } | 
|---|
| 153 |  | 
|---|
| 154 | // ------------- variables internes ----------------------- | 
|---|
| 155 |  | 
|---|
| 156 | int_4 nSide_; | 
|---|
| 157 | int_4 nPix_; | 
|---|
| 158 | double omeg_; | 
|---|
| 159 |  | 
|---|
| 160 | NDataBlock<T> pixels_; | 
|---|
| 161 | NDataBlock<int_4> sliceBeginIndex_;         // Rationalisation Mac. D.Y. | 
|---|
| 162 | NDataBlock<int_4> sliceLenght_; | 
|---|
| 163 |  | 
|---|
| 164 | }; | 
|---|
| 165 |  | 
|---|
| 166 |  | 
|---|
| 167 |  | 
|---|
| 168 | } // Fin du namespace | 
|---|
| 169 |  | 
|---|
| 170 | #endif | 
|---|