source: Sophya/trunk/SophyaLib/Samba/spheregorski.h@ 568

Last change on this file since 568 was 565, checked in by ansari, 26 years ago

ajout doc GLM

File size: 6.7 KB
Line 
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 SphereGorski : public SphericalMap<T>, public AnyDataObj
54{
55
56public :
57
58SphereGorski();
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*/
66SphereGorski(int m);
67SphereGorski(const SphereGorski<T>& s);
68//! Destructor
69virtual ~SphereGorski();
70
71// ------------------ Definition of PixelMap abstract methods
72
73/* Nombre de pixels du decoupage */
74/*! Return number of pixels of the splitting */
75virtual int NbPixels() const;
76inline void setNbPixels(int n) {nPix_= n;}
77
78/* Valeur du contenu du pixel d'indice "RING" k */
79/*! Return value of pixel with "RING" index k */
80virtual T& PixVal(int k);
81virtual T const& PixVal(int k) const;
82
83/* Nombre de tranches en theta */
84/*! Return number of slices in theta direction on the sphere */
85int NbThetaSlices() const;
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*/
94void GetThetaSlice(int index,double& theta,TVector<double>& phi,TVector<T>& value) const;
95
96/* Return true if teta,phi in map */
97virtual bool ContainsSph(double theta, double phi) const;
98/* Indice "RING" du pixel vers lequel pointe une direction definie par
99ses coordonnees spheriques */
100/*! Return "RING" index of the pixel corresponding to direction (theta, phi).
101 */
102virtual int PixIndexSph(double theta,double phi) const;
103
104/* Coordonnees spheriques du milieu du pixel d'indice "RING" k */
105virtual void PixThetaPhi(int k,double& theta,double& phi) const;
106
107/* Pixel Solid angle (steradians) */
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*/
114virtual double PixSolAngle(int dummy) const;
115inline void setPixSolAngle(double x) {omeg_= x;}
116
117// --------------- Specific methods
118
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*/
126virtual void Resize(int m);
127
128inline virtual char* TypeOfMap() const {return "RING";};
129
130/* Valeur du contenu du pixel d'indice "NEST" k */
131/*! Return value of pixel with "NESTED" index k */
132virtual T& PixValNest(int k);
133/*! Return value of pixel with "NESTED" index k */
134virtual T const& PixValNest(int k) const;
135
136/* Indice "NEST" du pixel vers lequel pointe une direction definie par
137ses coordonnees spheriques */
138/*! Return "NESTED" index of the pixel corresponding to direction (theta, phi).
139 */
140virtual int PixIndexSphNest(double theta,double phi) const;
141
142/* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */
143/*! Return (theta,phi) coordinates of middle of pixel with "NESTED" index k
144 */
145virtual void PixThetaPhiNest(int k,double& theta,double& phi) const;
146
147/* algorithme de pixelisation */
148void Pixelize(int);
149
150/* convertit index nested en ring */
151/*! translation from NESTED index into RING index */
152int NestToRing(int) const;
153
154/* convertit index ring en nested" */
155/*! translation from RING index into NESTED index */
156int RingToNest(int) const;
157
158
159/* retourne/fixe la valeur du parametre Gorski */
160inline virtual int SizeIndex() const {return(nSide_);}
161inline void setSizeIndex(int n) {nSide_= n;}
162
163/* retourne les pointeurs /remplit les tableaux */
164inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); }
165inline void setDataBlock(T* data,int m) { pixels_.FillFrom(m,data); }
166
167
168
169/* impression */
170void print(ostream& os) const;
171
172private :
173
174// ------------- méthodes internes ----------------------
175void InitNul();
176
177int nest2ring(int nside,int ipnest) const;
178int ring2nest(int nside,int ipring) const;
179
180int ang2pix_ring(int nside,double theta,double phi) const;
181int ang2pix_nest(int nside,double theta,double phi) const;
182void pix2ang_ring(int nside,int ipix,double& theta,double& phi) const;
183void pix2ang_nest(int nside,int ipix,double& theta,double& phi) const;
184
185// ------------- variables internes -----------------------
186int nSide_;
187int nPix_;
188double omeg_;
189
190NDataBlock<T> pixels_;
191
192};
193
194//
195// ------------- Classe pour la gestion de persistance --
196//
197template <class T>
198class FIO_SphereGorski : public PPersist
199{
200public:
201
202FIO_SphereGorski();
203FIO_SphereGorski(string const & filename);
204FIO_SphereGorski(const SphereGorski<T>& obj);
205FIO_SphereGorski(SphereGorski<T>* obj);
206virtual ~FIO_SphereGorski();
207virtual AnyDataObj* DataObj();
208inline operator SphereGorski<T>() { return(*dobj); }
209//inline SphereGorski<T> getObj() { return(*dobj); }
210
211protected :
212
213virtual void ReadSelf(PInPersist&);
214virtual void WriteSelf(POutPersist&) const;
215SphereGorski<T>* dobj;
216bool ownobj;
217};
218
219//
220// ------------- Classe PIXELS_XY -----------------------
221//
222class PIXELS_XY
223{
224
225public :
226
227static PIXELS_XY& instance();
228
229NDataBlock<int> pix2x_;
230NDataBlock<int> pix2y_;
231NDataBlock<int> x2pix_;
232NDataBlock<int> y2pix_;
233
234private :
235
236PIXELS_XY();
237void mk_pix2xy();
238void mk_xy2pix();
239};
240#endif
Note: See TracBrowser for help on using the repository browser.