source: Sophya/trunk/SophyaLib/SkyMap/spheregorski.h@ 824

Last change on this file since 824 was 764, checked in by ansari, 26 years ago

Reorganisation - Creation du module SkyMap (Loacl/Spherical maps ...) - Reza 2/3/2000

File size: 7.6 KB
RevLine 
[764]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
52template<class T>
53class FIO_SphereGorski;
54
55template<class T>
56class SphereGorski : public SphericalMap<T>
57{
58
59 friend class FIO_SphereGorski<T>;
60
61public :
62
63SphereGorski();
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*/
71SphereGorski(int_4 m);
72SphereGorski(const SphereGorski<T>& s, bool share=false);
73//! Destructor
74virtual ~SphereGorski();
75
76/*! Setting blockdata to temporary (see ndatablock documentation) */
77inline 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 */
82virtual int_4 NbPixels() const;
83
84/* Valeur du contenu du pixel d'indice "RING" k */
85/*! Return value of pixel with "RING" index k */
86virtual T& PixVal(int_4 k);
87virtual 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 */
91uint_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*/
100void 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 */
116virtual bool ContainsSph(double theta, double phi) const;
117/* Indice "RING" du pixel vers lequel pointe une direction definie par
118ses coordonnees spheriques */
119/*! Return "RING" index of the pixel corresponding to direction (theta, phi).
120 */
121virtual int_4 PixIndexSph(double theta,double phi) const;
122
123/* Coordonnees spheriques du milieu du pixel d'indice "RING" k */
124virtual void PixThetaPhi(int_4 k,double& theta,double& phi) const;
125
126/*! Set all pixels to value v */
127virtual 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*/
136virtual double PixSolAngle(int_4 dummy=0) const;
137
138/* Acces to the DataBlock */
139inline NDataBlock<T>& DataBlock() {return pixels_;}
140inline 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*/
151virtual void Resize(int_4 m);
152
153// pour l'instant le tableau est ordonne selon RING, uniquement
154inline 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 */
159virtual T& PixValNest(int_4 k);
160/*! Return value of pixel with "NESTED" index k */
161virtual T const& PixValNest(int_4 k) const;
162
163/* Indice "NEST" du pixel vers lequel pointe une direction definie par
164ses coordonnees spheriques */
165/*! Return "NESTED" index of the pixel corresponding to direction (theta, phi).
166 */
167virtual 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 */
172virtual void PixThetaPhiNest(int_4 k,double& theta,double& phi) const;
173
174/* algorithme de pixelisation */
175void Pixelize(int_4);
176
177/* convertit index nested en ring */
178/*! translation from NESTED index into RING index */
179int_4 NestToRing(int_4) const;
180
181/* convertit index ring en nested" */
182/*! translation from RING index into NESTED index */
183int_4 RingToNest(int_4) const;
184
185
186/* retourne la valeur du parametre Gorski */
187inline virtual int_4 SizeIndex() const {return(nSide_);}
188
189/* retourne les pointeurs /remplit les tableaux */
190
191
192
193
194/* impression */
195void print(ostream& os) const;
196
197private :
198
199// ------------- méthodes internes ----------------------
200void InitNul();
201 void SetThetaSlices();
202
203int_4 nest2ring(int_4 nside,int_4 ipnest) const;
204int_4 ring2nest(int_4 nside,int_4 ipring) const;
205
206int_4 ang2pix_ring(int_4 nside,double theta,double phi) const;
207int_4 ang2pix_nest(int_4 nside,double theta,double phi) const;
208void pix2ang_ring(int_4 nside,int_4 ipix,double& theta,double& phi) const;
209void pix2ang_nest(int_4 nside,int_4 ipix,double& theta,double& phi) const;
210inline 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
219int_4 nSide_;
220int_4 nPix_;
221double omeg_;
222
223NDataBlock<T> pixels_;
224NDataBlock<int> sliceBeginIndex_;
225 NDataBlock<int> sliceLenght_;
226
227};
228
229//
230// ------------- Classe pour la gestion de persistance --
231//
232template <class T>
233class FIO_SphereGorski : public PPersist
234{
235public:
236
237FIO_SphereGorski();
238FIO_SphereGorski(string const & filename);
239FIO_SphereGorski(const SphereGorski<T>& obj);
240FIO_SphereGorski(SphereGorski<T>* obj);
241virtual ~FIO_SphereGorski();
242virtual AnyDataObj* DataObj();
243virtual void SetDataObj(AnyDataObj & o);
244inline operator SphereGorski<T>() { return(*dobj); }
245
246protected :
247
248virtual void ReadSelf(PInPersist&);
249virtual void WriteSelf(POutPersist&) const;
250SphereGorski<T>* dobj;
251bool ownobj;
252};
253
254//
255// ------------- Classe PIXELS_XY -----------------------
256//
257class PIXELS_XY
258{
259
260public :
261
262static PIXELS_XY& instance();
263
264NDataBlock<int_4> pix2x_;
265NDataBlock<int_4> pix2y_;
266NDataBlock<int_4> x2pix_;
267NDataBlock<int_4> y2pix_;
268
269private :
270
271PIXELS_XY();
272void mk_pix2xy();
273void mk_xy2pix();
274};
275#endif
Note: See TracBrowser for help on using the repository browser.