[228] | 1 | #ifndef SPHEREGORSKI_SEEN
|
---|
| 2 | #define SPHEREGORSKI_SEEN
|
---|
| 3 |
|
---|
| 4 | #include "sphericalmap.h"
|
---|
[470] | 5 | #include "tvector.h"
|
---|
| 6 | #include "ndatablock.h"
|
---|
[228] | 7 |
|
---|
[470] | 8 | #include "anydataobj.h"
|
---|
| 9 | #include "ppersist.h"
|
---|
| 10 |
|
---|
[228] | 11 |
|
---|
[470] | 12 | // ***************** CLASSE SphereGorski *****************************
|
---|
| 13 |
|
---|
[565] | 14 | //! class SphereGorski
|
---|
| 15 | /*!
|
---|
| 16 | Pixelisation Gorski
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | -----------------------------------------------------------------------
|
---|
| 20 | version 0.8.2 Aug97 TAC Eric Hivon, Kris Gorski
|
---|
| 21 | -----------------------------------------------------------------------
|
---|
| 22 |
|
---|
| 23 | the sphere is split in 12 diamond-faces containing nside**2 pixels each
|
---|
| 24 |
|
---|
| 25 | the numbering of the pixels (in the nested scheme) is similar to
|
---|
| 26 | quad-cube
|
---|
| 27 | In each face the first pixel is in the lowest corner of the diamond
|
---|
| 28 |
|
---|
| 29 | the faces are (x,y) coordinate on each face
|
---|
| 30 | \verbatim
|
---|
| 31 | . . . . <--- North Pole
|
---|
| 32 | / \ / \ / \ / \ ^ ^
|
---|
| 33 | . 0 . 1 . 2 . 3 . <--- z = 2/3 \ /
|
---|
| 34 | \ / \ / \ / \ / y \ / x
|
---|
| 35 | 4 . 5 . 6 . 7 . 4 <--- equator \ /
|
---|
| 36 | / \ / \ / \ / \ \/
|
---|
| 37 | . 8 . 9 .10 .11 . <--- z = -2/3 (0,0) : lowest corner
|
---|
| 38 | \ / \ / \ / \ /
|
---|
| 39 | . . . . <--- South Pole
|
---|
| 40 | \endverbatim
|
---|
| 41 | phi:0 2Pi
|
---|
| 42 |
|
---|
| 43 | in the ring scheme pixels are numbered along the parallels
|
---|
| 44 | the first parallel is the one closest to the north pole and so on
|
---|
| 45 | on each parallel, pixels are numbered starting from the one closest
|
---|
| 46 | to phi = 0
|
---|
| 47 |
|
---|
| 48 | nside MUST be a power of 2 (<= 8192)
|
---|
| 49 |
|
---|
| 50 | */
|
---|
| 51 |
|
---|
[470] | 52 | template<class T>
|
---|
[592] | 53 | class SphereGorski : public SphericalMap<T>
|
---|
[470] | 54 | {
|
---|
| 55 |
|
---|
[228] | 56 | public :
|
---|
| 57 |
|
---|
| 58 | SphereGorski();
|
---|
[565] | 59 | /*!
|
---|
| 60 | m is the "nside" of the Gorski algorithm
|
---|
| 61 |
|
---|
| 62 | The total number of pixels will be Npix = 12*nside**2
|
---|
| 63 |
|
---|
| 64 | nside MUST be a power of 2 (<= 8192)
|
---|
| 65 | */
|
---|
[682] | 66 | SphereGorski(int_4 m);
|
---|
[574] | 67 | SphereGorski(const SphereGorski<T>& s, bool share=false);
|
---|
[565] | 68 | //! Destructor
|
---|
[228] | 69 | virtual ~SphereGorski();
|
---|
| 70 |
|
---|
| 71 | // ------------------ Definition of PixelMap abstract methods
|
---|
| 72 |
|
---|
[470] | 73 | /* Nombre de pixels du decoupage */
|
---|
[565] | 74 | /*! Return number of pixels of the splitting */
|
---|
[682] | 75 | virtual int_4 NbPixels() const;
|
---|
| 76 | inline void setNbPixels(int_4 n) {nPix_= n;}
|
---|
[228] | 77 |
|
---|
[470] | 78 | /* Valeur du contenu du pixel d'indice "RING" k */
|
---|
[565] | 79 | /*! Return value of pixel with "RING" index k */
|
---|
[682] | 80 | virtual T& PixVal(int_4 k);
|
---|
| 81 | virtual T const& PixVal(int_4 k) const;
|
---|
[228] | 82 |
|
---|
[470] | 83 | /* Nombre de tranches en theta */
|
---|
[565] | 84 | /*! Return number of slices in theta direction on the sphere */
|
---|
[682] | 85 | int_4 NbThetaSlices() const;
|
---|
[565] | 86 | /*! For a theta-slice with index 'index', return :
|
---|
| 87 |
|
---|
| 88 | the corresponding "theta"
|
---|
| 89 |
|
---|
| 90 | a vector containing the phi's of the pixels of the slice
|
---|
| 91 |
|
---|
| 92 | a vector containing the corresponding values of pixels
|
---|
| 93 | */
|
---|
[682] | 94 | void GetThetaSlice(int_4 index,double& theta,TVector<double>& phi,TVector<T>& value) const;
|
---|
[228] | 95 |
|
---|
[518] | 96 | /* Return true if teta,phi in map */
|
---|
| 97 | virtual bool ContainsSph(double theta, double phi) const;
|
---|
[228] | 98 | /* Indice "RING" du pixel vers lequel pointe une direction definie par
|
---|
| 99 | ses coordonnees spheriques */
|
---|
[565] | 100 | /*! Return "RING" index of the pixel corresponding to direction (theta, phi).
|
---|
| 101 | */
|
---|
[682] | 102 | virtual int_4 PixIndexSph(double theta,double phi) const;
|
---|
[228] | 103 |
|
---|
[470] | 104 | /* Coordonnees spheriques du milieu du pixel d'indice "RING" k */
|
---|
[682] | 105 | virtual void PixThetaPhi(int_4 k,double& theta,double& phi) const;
|
---|
[228] | 106 |
|
---|
[574] | 107 | /*! Set all pixels to value v */
|
---|
| 108 | virtual T SetPixels(T v);
|
---|
| 109 |
|
---|
[470] | 110 | /* Pixel Solid angle (steradians) */
|
---|
[565] | 111 | /*! Pixel Solid angle (steradians)
|
---|
| 112 |
|
---|
| 113 | All the pixels have the same solid angle. The dummy argument is
|
---|
| 114 | for compatibility with eventual pixelizations which would not
|
---|
| 115 | fulfil this requirement.
|
---|
| 116 | */
|
---|
[682] | 117 | virtual double PixSolAngle(int_4 dummy) const;
|
---|
[473] | 118 | inline void setPixSolAngle(double x) {omeg_= x;}
|
---|
[228] | 119 |
|
---|
| 120 | // --------------- Specific methods
|
---|
| 121 |
|
---|
[565] | 122 | /*!
|
---|
| 123 | m is the "nside" of the Gorski algorithm
|
---|
| 124 |
|
---|
| 125 | The total number of pixels will be Npix = 12*nside**2
|
---|
| 126 |
|
---|
| 127 | nside MUST be a power of 2 (<= 8192)
|
---|
| 128 | */
|
---|
[682] | 129 | virtual void Resize(int_4 m);
|
---|
[470] | 130 |
|
---|
[698] | 131 | inline virtual char* TypeOfMap() const {return "HEALPIX";};
|
---|
[470] | 132 |
|
---|
[473] | 133 | /* Valeur du contenu du pixel d'indice "NEST" k */
|
---|
[565] | 134 | /*! Return value of pixel with "NESTED" index k */
|
---|
[682] | 135 | virtual T& PixValNest(int_4 k);
|
---|
[565] | 136 | /*! Return value of pixel with "NESTED" index k */
|
---|
[682] | 137 | virtual T const& PixValNest(int_4 k) const;
|
---|
[228] | 138 |
|
---|
| 139 | /* Indice "NEST" du pixel vers lequel pointe une direction definie par
|
---|
| 140 | ses coordonnees spheriques */
|
---|
[565] | 141 | /*! Return "NESTED" index of the pixel corresponding to direction (theta, phi).
|
---|
| 142 | */
|
---|
[682] | 143 | virtual int_4 PixIndexSphNest(double theta,double phi) const;
|
---|
[228] | 144 |
|
---|
| 145 | /* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */
|
---|
[565] | 146 | /*! Return (theta,phi) coordinates of middle of pixel with "NESTED" index k
|
---|
| 147 | */
|
---|
[682] | 148 | virtual void PixThetaPhiNest(int_4 k,double& theta,double& phi) const;
|
---|
[228] | 149 |
|
---|
[470] | 150 | /* algorithme de pixelisation */
|
---|
[682] | 151 | void Pixelize(int_4);
|
---|
[228] | 152 |
|
---|
| 153 | /* convertit index nested en ring */
|
---|
[565] | 154 | /*! translation from NESTED index into RING index */
|
---|
[682] | 155 | int_4 NestToRing(int_4) const;
|
---|
[228] | 156 |
|
---|
| 157 | /* convertit index ring en nested" */
|
---|
[565] | 158 | /*! translation from RING index into NESTED index */
|
---|
[682] | 159 | int_4 RingToNest(int_4) const;
|
---|
[228] | 160 |
|
---|
| 161 |
|
---|
[470] | 162 | /* retourne/fixe la valeur du parametre Gorski */
|
---|
[682] | 163 | inline virtual int_4 SizeIndex() const {return(nSide_);}
|
---|
| 164 | inline void setSizeIndex(int_4 n) {nSide_= n;}
|
---|
[228] | 165 |
|
---|
[470] | 166 | /* retourne les pointeurs /remplit les tableaux */
|
---|
| 167 | inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); }
|
---|
[682] | 168 | inline void setDataBlock(T* data,int_4 m) { pixels_.FillFrom(m,data); }
|
---|
[470] | 169 |
|
---|
[604] | 170 | /* Acces to the DataBlock */
|
---|
| 171 | inline NDataBlock<T>& DataBlock() {return pixels_;}
|
---|
| 172 | inline const NDataBlock<T>& DataBlock() const {return pixels_;}
|
---|
[470] | 173 |
|
---|
| 174 |
|
---|
[604] | 175 |
|
---|
[470] | 176 | /* impression */
|
---|
| 177 | void print(ostream& os) const;
|
---|
| 178 |
|
---|
[228] | 179 | private :
|
---|
| 180 |
|
---|
[470] | 181 | // ------------- méthodes internes ----------------------
|
---|
| 182 | void InitNul();
|
---|
| 183 |
|
---|
[682] | 184 | int_4 nest2ring(int_4 nside,int_4 ipnest) const;
|
---|
| 185 | int_4 ring2nest(int_4 nside,int_4 ipring) const;
|
---|
[470] | 186 |
|
---|
[682] | 187 | int_4 ang2pix_ring(int_4 nside,double theta,double phi) const;
|
---|
| 188 | int_4 ang2pix_nest(int_4 nside,double theta,double phi) const;
|
---|
| 189 | void pix2ang_ring(int_4 nside,int_4 ipix,double& theta,double& phi) const;
|
---|
| 190 | void pix2ang_nest(int_4 nside,int_4 ipix,double& theta,double& phi) const;
|
---|
[470] | 191 |
|
---|
[228] | 192 | // ------------- variables internes -----------------------
|
---|
[682] | 193 | int_4 nSide_;
|
---|
| 194 | int_4 nPix_;
|
---|
[473] | 195 | double omeg_;
|
---|
[228] | 196 |
|
---|
[470] | 197 | NDataBlock<T> pixels_;
|
---|
[228] | 198 |
|
---|
| 199 | };
|
---|
[470] | 200 |
|
---|
| 201 | //
|
---|
| 202 | // ------------- Classe pour la gestion de persistance --
|
---|
| 203 | //
|
---|
| 204 | template <class T>
|
---|
| 205 | class FIO_SphereGorski : public PPersist
|
---|
| 206 | {
|
---|
| 207 | public:
|
---|
| 208 |
|
---|
| 209 | FIO_SphereGorski();
|
---|
| 210 | FIO_SphereGorski(string const & filename);
|
---|
| 211 | FIO_SphereGorski(const SphereGorski<T>& obj);
|
---|
| 212 | FIO_SphereGorski(SphereGorski<T>* obj);
|
---|
| 213 | virtual ~FIO_SphereGorski();
|
---|
| 214 | virtual AnyDataObj* DataObj();
|
---|
| 215 | inline operator SphereGorski<T>() { return(*dobj); }
|
---|
[565] | 216 | //inline SphereGorski<T> getObj() { return(*dobj); }
|
---|
[470] | 217 |
|
---|
| 218 | protected :
|
---|
| 219 |
|
---|
| 220 | virtual void ReadSelf(PInPersist&);
|
---|
| 221 | virtual void WriteSelf(POutPersist&) const;
|
---|
| 222 | SphereGorski<T>* dobj;
|
---|
| 223 | bool ownobj;
|
---|
| 224 | };
|
---|
| 225 |
|
---|
| 226 | //
|
---|
| 227 | // ------------- Classe PIXELS_XY -----------------------
|
---|
| 228 | //
|
---|
| 229 | class PIXELS_XY
|
---|
| 230 | {
|
---|
| 231 |
|
---|
| 232 | public :
|
---|
| 233 |
|
---|
| 234 | static PIXELS_XY& instance();
|
---|
| 235 |
|
---|
[682] | 236 | NDataBlock<int_4> pix2x_;
|
---|
| 237 | NDataBlock<int_4> pix2y_;
|
---|
| 238 | NDataBlock<int_4> x2pix_;
|
---|
| 239 | NDataBlock<int_4> y2pix_;
|
---|
[470] | 240 |
|
---|
| 241 | private :
|
---|
| 242 |
|
---|
| 243 | PIXELS_XY();
|
---|
| 244 | void mk_pix2xy();
|
---|
| 245 | void mk_xy2pix();
|
---|
| 246 | };
|
---|
[228] | 247 | #endif
|
---|