[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>
|
---|
[701] | 53 | class FIO_SphereGorski;
|
---|
| 54 |
|
---|
| 55 | template<class T>
|
---|
[592] | 56 | class SphereGorski : public SphericalMap<T>
|
---|
[470] | 57 | {
|
---|
| 58 |
|
---|
[701] | 59 | friend class FIO_SphereGorski<T>;
|
---|
| 60 |
|
---|
[228] | 61 | public :
|
---|
| 62 |
|
---|
| 63 | SphereGorski();
|
---|
[565] | 64 | /*!
|
---|
| 65 | m is the "nside" of the Gorski algorithm
|
---|
| 66 |
|
---|
| 67 | The total number of pixels will be Npix = 12*nside**2
|
---|
| 68 |
|
---|
| 69 | nside MUST be a power of 2 (<= 8192)
|
---|
| 70 | */
|
---|
[682] | 71 | SphereGorski(int_4 m);
|
---|
[574] | 72 | SphereGorski(const SphereGorski<T>& s, bool share=false);
|
---|
[565] | 73 | //! Destructor
|
---|
[228] | 74 | virtual ~SphereGorski();
|
---|
| 75 |
|
---|
| 76 | // ------------------ Definition of PixelMap abstract methods
|
---|
| 77 |
|
---|
[470] | 78 | /* Nombre de pixels du decoupage */
|
---|
[565] | 79 | /*! Return number of pixels of the splitting */
|
---|
[682] | 80 | virtual int_4 NbPixels() const;
|
---|
[228] | 81 |
|
---|
[470] | 82 | /* Valeur du contenu du pixel d'indice "RING" k */
|
---|
[565] | 83 | /*! Return value of pixel with "RING" index k */
|
---|
[682] | 84 | virtual T& PixVal(int_4 k);
|
---|
| 85 | virtual T const& PixVal(int_4 k) const;
|
---|
[228] | 86 |
|
---|
[470] | 87 | /* Nombre de tranches en theta */
|
---|
[565] | 88 | /*! Return number of slices in theta direction on the sphere */
|
---|
[682] | 89 | int_4 NbThetaSlices() const;
|
---|
[565] | 90 | /*! For a theta-slice with index 'index', return :
|
---|
| 91 |
|
---|
| 92 | the corresponding "theta"
|
---|
| 93 |
|
---|
| 94 | a vector containing the phi's of the pixels of the slice
|
---|
| 95 |
|
---|
| 96 | a vector containing the corresponding values of pixels
|
---|
| 97 | */
|
---|
[682] | 98 | void GetThetaSlice(int_4 index,double& theta,TVector<double>& phi,TVector<T>& value) const;
|
---|
[228] | 99 |
|
---|
[518] | 100 | /* Return true if teta,phi in map */
|
---|
| 101 | virtual bool ContainsSph(double theta, double phi) const;
|
---|
[228] | 102 | /* Indice "RING" du pixel vers lequel pointe une direction definie par
|
---|
| 103 | ses coordonnees spheriques */
|
---|
[565] | 104 | /*! Return "RING" index of the pixel corresponding to direction (theta, phi).
|
---|
| 105 | */
|
---|
[682] | 106 | virtual int_4 PixIndexSph(double theta,double phi) const;
|
---|
[228] | 107 |
|
---|
[470] | 108 | /* Coordonnees spheriques du milieu du pixel d'indice "RING" k */
|
---|
[682] | 109 | virtual void PixThetaPhi(int_4 k,double& theta,double& phi) const;
|
---|
[228] | 110 |
|
---|
[574] | 111 | /*! Set all pixels to value v */
|
---|
| 112 | virtual T SetPixels(T v);
|
---|
| 113 |
|
---|
[470] | 114 | /* Pixel Solid angle (steradians) */
|
---|
[565] | 115 | /*! Pixel Solid angle (steradians)
|
---|
| 116 |
|
---|
| 117 | All the pixels have the same solid angle. The dummy argument is
|
---|
| 118 | for compatibility with eventual pixelizations which would not
|
---|
| 119 | fulfil this requirement.
|
---|
| 120 | */
|
---|
[701] | 121 | virtual double PixSolAngle(int_4 dummy=0) const;
|
---|
[228] | 122 |
|
---|
| 123 | // --------------- Specific methods
|
---|
| 124 |
|
---|
[565] | 125 | /*!
|
---|
| 126 | m is the "nside" of the Gorski algorithm
|
---|
| 127 |
|
---|
| 128 | The total number of pixels will be Npix = 12*nside**2
|
---|
| 129 |
|
---|
| 130 | nside MUST be a power of 2 (<= 8192)
|
---|
| 131 | */
|
---|
[682] | 132 | virtual void Resize(int_4 m);
|
---|
[470] | 133 |
|
---|
[703] | 134 | // pour l'instant le tableau est ordonne selon RING, uniquement
|
---|
| 135 | inline virtual char* TypeOfMap() const {return "RING";};
|
---|
[470] | 136 |
|
---|
[703] | 137 |
|
---|
[473] | 138 | /* Valeur du contenu du pixel d'indice "NEST" k */
|
---|
[565] | 139 | /*! Return value of pixel with "NESTED" index k */
|
---|
[682] | 140 | virtual T& PixValNest(int_4 k);
|
---|
[565] | 141 | /*! Return value of pixel with "NESTED" index k */
|
---|
[682] | 142 | virtual T const& PixValNest(int_4 k) const;
|
---|
[228] | 143 |
|
---|
| 144 | /* Indice "NEST" du pixel vers lequel pointe une direction definie par
|
---|
| 145 | ses coordonnees spheriques */
|
---|
[565] | 146 | /*! Return "NESTED" index of the pixel corresponding to direction (theta, phi).
|
---|
| 147 | */
|
---|
[682] | 148 | virtual int_4 PixIndexSphNest(double theta,double phi) const;
|
---|
[228] | 149 |
|
---|
| 150 | /* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */
|
---|
[565] | 151 | /*! Return (theta,phi) coordinates of middle of pixel with "NESTED" index k
|
---|
| 152 | */
|
---|
[682] | 153 | virtual void PixThetaPhiNest(int_4 k,double& theta,double& phi) const;
|
---|
[228] | 154 |
|
---|
[470] | 155 | /* algorithme de pixelisation */
|
---|
[682] | 156 | void Pixelize(int_4);
|
---|
[228] | 157 |
|
---|
| 158 | /* convertit index nested en ring */
|
---|
[565] | 159 | /*! translation from NESTED index into RING index */
|
---|
[682] | 160 | int_4 NestToRing(int_4) const;
|
---|
[228] | 161 |
|
---|
| 162 | /* convertit index ring en nested" */
|
---|
[565] | 163 | /*! translation from RING index into NESTED index */
|
---|
[682] | 164 | int_4 RingToNest(int_4) const;
|
---|
[228] | 165 |
|
---|
| 166 |
|
---|
[701] | 167 | /* retourne la valeur du parametre Gorski */
|
---|
[682] | 168 | inline virtual int_4 SizeIndex() const {return(nSide_);}
|
---|
[228] | 169 |
|
---|
[470] | 170 | /* retourne les pointeurs /remplit les tableaux */
|
---|
| 171 |
|
---|
| 172 |
|
---|
| 173 |
|
---|
[604] | 174 |
|
---|
[470] | 175 | /* impression */
|
---|
| 176 | void print(ostream& os) const;
|
---|
| 177 |
|
---|
[228] | 178 | private :
|
---|
| 179 |
|
---|
[470] | 180 | // ------------- méthodes internes ----------------------
|
---|
| 181 | void InitNul();
|
---|
| 182 |
|
---|
[682] | 183 | int_4 nest2ring(int_4 nside,int_4 ipnest) const;
|
---|
| 184 | int_4 ring2nest(int_4 nside,int_4 ipring) const;
|
---|
[470] | 185 |
|
---|
[682] | 186 | int_4 ang2pix_ring(int_4 nside,double theta,double phi) const;
|
---|
| 187 | int_4 ang2pix_nest(int_4 nside,double theta,double phi) const;
|
---|
| 188 | void pix2ang_ring(int_4 nside,int_4 ipix,double& theta,double& phi) const;
|
---|
| 189 | void pix2ang_nest(int_4 nside,int_4 ipix,double& theta,double& phi) const;
|
---|
[701] | 190 | inline void setParameters(int_4 nside, int_4 nbpixels, double solangle)
|
---|
| 191 | {
|
---|
| 192 | nSide_= nside;
|
---|
| 193 | nPix_= nbpixels;
|
---|
| 194 | omeg_= solangle;
|
---|
| 195 | }
|
---|
[470] | 196 |
|
---|
[228] | 197 | // ------------- variables internes -----------------------
|
---|
[682] | 198 | int_4 nSide_;
|
---|
| 199 | int_4 nPix_;
|
---|
[473] | 200 | double omeg_;
|
---|
[228] | 201 |
|
---|
[470] | 202 | NDataBlock<T> pixels_;
|
---|
[228] | 203 |
|
---|
| 204 | };
|
---|
[470] | 205 |
|
---|
| 206 | //
|
---|
| 207 | // ------------- Classe pour la gestion de persistance --
|
---|
| 208 | //
|
---|
| 209 | template <class T>
|
---|
| 210 | class FIO_SphereGorski : public PPersist
|
---|
| 211 | {
|
---|
| 212 | public:
|
---|
| 213 |
|
---|
| 214 | FIO_SphereGorski();
|
---|
| 215 | FIO_SphereGorski(string const & filename);
|
---|
| 216 | FIO_SphereGorski(const SphereGorski<T>& obj);
|
---|
| 217 | FIO_SphereGorski(SphereGorski<T>* obj);
|
---|
| 218 | virtual ~FIO_SphereGorski();
|
---|
| 219 | virtual AnyDataObj* DataObj();
|
---|
| 220 | inline operator SphereGorski<T>() { return(*dobj); }
|
---|
[565] | 221 | //inline SphereGorski<T> getObj() { return(*dobj); }
|
---|
[470] | 222 |
|
---|
| 223 | protected :
|
---|
| 224 |
|
---|
| 225 | virtual void ReadSelf(PInPersist&);
|
---|
| 226 | virtual void WriteSelf(POutPersist&) const;
|
---|
| 227 | SphereGorski<T>* dobj;
|
---|
| 228 | bool ownobj;
|
---|
| 229 | };
|
---|
| 230 |
|
---|
| 231 | //
|
---|
| 232 | // ------------- Classe PIXELS_XY -----------------------
|
---|
| 233 | //
|
---|
| 234 | class PIXELS_XY
|
---|
| 235 | {
|
---|
| 236 |
|
---|
| 237 | public :
|
---|
| 238 |
|
---|
| 239 | static PIXELS_XY& instance();
|
---|
| 240 |
|
---|
[682] | 241 | NDataBlock<int_4> pix2x_;
|
---|
| 242 | NDataBlock<int_4> pix2y_;
|
---|
| 243 | NDataBlock<int_4> x2pix_;
|
---|
| 244 | NDataBlock<int_4> y2pix_;
|
---|
[470] | 245 |
|
---|
| 246 | private :
|
---|
| 247 |
|
---|
| 248 | PIXELS_XY();
|
---|
| 249 | void mk_pix2xy();
|
---|
| 250 | void mk_xy2pix();
|
---|
| 251 | };
|
---|
[228] | 252 | #endif
|
---|