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

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

changement de nom de code de type de sphere RING->HEALPIX

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