[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>
|
---|
| 53 | class SphereGorski : public SphericalMap<T>, public AnyDataObj
|
---|
| 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 | */
|
---|
[473] | 66 | SphereGorski(int m);
|
---|
[470] | 67 | SphereGorski(const SphereGorski<T>& s);
|
---|
[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 */
|
---|
[473] | 75 | virtual int NbPixels() const;
|
---|
| 76 | inline void setNbPixels(int 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 */
|
---|
[473] | 80 | virtual T& PixVal(int k);
|
---|
| 81 | virtual T const& PixVal(int k) const;
|
---|
[228] | 82 |
|
---|
[470] | 83 | /* Nombre de tranches en theta */
|
---|
[565] | 84 | /*! Return number of slices in theta direction on the sphere */
|
---|
[473] | 85 | int 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 | */
|
---|
[473] | 94 | void GetThetaSlice(int 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 | */
|
---|
[473] | 102 | virtual int PixIndexSph(double theta,double phi) const;
|
---|
[228] | 103 |
|
---|
[470] | 104 | /* Coordonnees spheriques du milieu du pixel d'indice "RING" k */
|
---|
[473] | 105 | virtual void PixThetaPhi(int k,double& theta,double& phi) const;
|
---|
[228] | 106 |
|
---|
[470] | 107 | /* Pixel Solid angle (steradians) */
|
---|
[565] | 108 | /*! Pixel Solid angle (steradians)
|
---|
| 109 |
|
---|
| 110 | All the pixels have the same solid angle. The dummy argument is
|
---|
| 111 | for compatibility with eventual pixelizations which would not
|
---|
| 112 | fulfil this requirement.
|
---|
| 113 | */
|
---|
[473] | 114 | virtual double PixSolAngle(int dummy) const;
|
---|
| 115 | inline void setPixSolAngle(double x) {omeg_= x;}
|
---|
[228] | 116 |
|
---|
| 117 | // --------------- Specific methods
|
---|
| 118 |
|
---|
[565] | 119 | /*!
|
---|
| 120 | m is the "nside" of the Gorski algorithm
|
---|
| 121 |
|
---|
| 122 | The total number of pixels will be Npix = 12*nside**2
|
---|
| 123 |
|
---|
| 124 | nside MUST be a power of 2 (<= 8192)
|
---|
| 125 | */
|
---|
[473] | 126 | virtual void Resize(int m);
|
---|
[470] | 127 |
|
---|
| 128 | inline virtual char* TypeOfMap() const {return "RING";};
|
---|
| 129 |
|
---|
[473] | 130 | /* Valeur du contenu du pixel d'indice "NEST" k */
|
---|
[565] | 131 | /*! Return value of pixel with "NESTED" index k */
|
---|
[473] | 132 | virtual T& PixValNest(int k);
|
---|
[565] | 133 | /*! Return value of pixel with "NESTED" index k */
|
---|
[473] | 134 | virtual T const& PixValNest(int k) const;
|
---|
[228] | 135 |
|
---|
| 136 | /* Indice "NEST" du pixel vers lequel pointe une direction definie par
|
---|
| 137 | ses coordonnees spheriques */
|
---|
[565] | 138 | /*! Return "NESTED" index of the pixel corresponding to direction (theta, phi).
|
---|
| 139 | */
|
---|
[473] | 140 | virtual int PixIndexSphNest(double theta,double phi) const;
|
---|
[228] | 141 |
|
---|
| 142 | /* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */
|
---|
[565] | 143 | /*! Return (theta,phi) coordinates of middle of pixel with "NESTED" index k
|
---|
| 144 | */
|
---|
[473] | 145 | virtual void PixThetaPhiNest(int k,double& theta,double& phi) const;
|
---|
[228] | 146 |
|
---|
[470] | 147 | /* algorithme de pixelisation */
|
---|
[473] | 148 | void Pixelize(int);
|
---|
[228] | 149 |
|
---|
| 150 | /* convertit index nested en ring */
|
---|
[565] | 151 | /*! translation from NESTED index into RING index */
|
---|
[473] | 152 | int NestToRing(int) const;
|
---|
[228] | 153 |
|
---|
| 154 | /* convertit index ring en nested" */
|
---|
[565] | 155 | /*! translation from RING index into NESTED index */
|
---|
[473] | 156 | int RingToNest(int) const;
|
---|
[228] | 157 |
|
---|
| 158 |
|
---|
[470] | 159 | /* retourne/fixe la valeur du parametre Gorski */
|
---|
[473] | 160 | inline virtual int SizeIndex() const {return(nSide_);}
|
---|
| 161 | inline void setSizeIndex(int n) {nSide_= n;}
|
---|
[228] | 162 |
|
---|
[470] | 163 | /* retourne les pointeurs /remplit les tableaux */
|
---|
| 164 | inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); }
|
---|
[473] | 165 | inline void setDataBlock(T* data,int m) { pixels_.FillFrom(m,data); }
|
---|
[470] | 166 |
|
---|
| 167 |
|
---|
| 168 |
|
---|
| 169 | /* impression */
|
---|
| 170 | void print(ostream& os) const;
|
---|
| 171 |
|
---|
[228] | 172 | private :
|
---|
| 173 |
|
---|
[470] | 174 | // ------------- méthodes internes ----------------------
|
---|
| 175 | void InitNul();
|
---|
| 176 |
|
---|
[473] | 177 | int nest2ring(int nside,int ipnest) const;
|
---|
| 178 | int ring2nest(int nside,int ipring) const;
|
---|
[470] | 179 |
|
---|
[473] | 180 | int ang2pix_ring(int nside,double theta,double phi) const;
|
---|
| 181 | int ang2pix_nest(int nside,double theta,double phi) const;
|
---|
| 182 | void pix2ang_ring(int nside,int ipix,double& theta,double& phi) const;
|
---|
| 183 | void pix2ang_nest(int nside,int ipix,double& theta,double& phi) const;
|
---|
[470] | 184 |
|
---|
[228] | 185 | // ------------- variables internes -----------------------
|
---|
[473] | 186 | int nSide_;
|
---|
| 187 | int nPix_;
|
---|
| 188 | double omeg_;
|
---|
[228] | 189 |
|
---|
[470] | 190 | NDataBlock<T> pixels_;
|
---|
[228] | 191 |
|
---|
| 192 | };
|
---|
[470] | 193 |
|
---|
| 194 | //
|
---|
| 195 | // ------------- Classe pour la gestion de persistance --
|
---|
| 196 | //
|
---|
| 197 | template <class T>
|
---|
| 198 | class FIO_SphereGorski : public PPersist
|
---|
| 199 | {
|
---|
| 200 | public:
|
---|
| 201 |
|
---|
| 202 | FIO_SphereGorski();
|
---|
| 203 | FIO_SphereGorski(string const & filename);
|
---|
| 204 | FIO_SphereGorski(const SphereGorski<T>& obj);
|
---|
| 205 | FIO_SphereGorski(SphereGorski<T>* obj);
|
---|
| 206 | virtual ~FIO_SphereGorski();
|
---|
| 207 | virtual AnyDataObj* DataObj();
|
---|
| 208 | inline operator SphereGorski<T>() { return(*dobj); }
|
---|
[565] | 209 | //inline SphereGorski<T> getObj() { return(*dobj); }
|
---|
[470] | 210 |
|
---|
| 211 | protected :
|
---|
| 212 |
|
---|
| 213 | virtual void ReadSelf(PInPersist&);
|
---|
| 214 | virtual void WriteSelf(POutPersist&) const;
|
---|
| 215 | SphereGorski<T>* dobj;
|
---|
| 216 | bool ownobj;
|
---|
| 217 | };
|
---|
| 218 |
|
---|
| 219 | //
|
---|
| 220 | // ------------- Classe PIXELS_XY -----------------------
|
---|
| 221 | //
|
---|
| 222 | class PIXELS_XY
|
---|
| 223 | {
|
---|
| 224 |
|
---|
| 225 | public :
|
---|
| 226 |
|
---|
| 227 | static PIXELS_XY& instance();
|
---|
| 228 |
|
---|
| 229 | NDataBlock<int> pix2x_;
|
---|
| 230 | NDataBlock<int> pix2y_;
|
---|
| 231 | NDataBlock<int> x2pix_;
|
---|
| 232 | NDataBlock<int> y2pix_;
|
---|
| 233 |
|
---|
| 234 | private :
|
---|
| 235 |
|
---|
| 236 | PIXELS_XY();
|
---|
| 237 | void mk_pix2xy();
|
---|
| 238 | void mk_xy2pix();
|
---|
| 239 | };
|
---|
[228] | 240 | #endif
|
---|