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