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

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

Remis methode acces aux pixels - Reza 21/01/2000

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