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

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

mise a jour de persistances par objets delegues

File size: 6.8 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// --------------- Specific methods
124
125/*!
126 m is the "nside" of the Gorski algorithm
127
128 The total number of pixels will be Npix = 12*nside**2
129
130 nside MUST be a power of 2 (<= 8192)
131*/
132virtual void Resize(int_4 m);
133
134inline virtual char* TypeOfMap() const {return "HEALPIX";};
135
136/* Valeur du contenu du pixel d'indice "NEST" k */
137/*! Return value of pixel with "NESTED" index k */
138virtual T& PixValNest(int_4 k);
139/*! Return value of pixel with "NESTED" index k */
140virtual T const& PixValNest(int_4 k) const;
141
142/* Indice "NEST" du pixel vers lequel pointe une direction definie par
143ses coordonnees spheriques */
144/*! Return "NESTED" index of the pixel corresponding to direction (theta, phi).
145 */
146virtual int_4 PixIndexSphNest(double theta,double phi) const;
147
148/* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */
149/*! Return (theta,phi) coordinates of middle of pixel with "NESTED" index k
150 */
151virtual void PixThetaPhiNest(int_4 k,double& theta,double& phi) const;
152
153/* algorithme de pixelisation */
154void Pixelize(int_4);
155
156/* convertit index nested en ring */
157/*! translation from NESTED index into RING index */
158int_4 NestToRing(int_4) const;
159
160/* convertit index ring en nested" */
161/*! translation from RING index into NESTED index */
162int_4 RingToNest(int_4) const;
163
164
165/* retourne la valeur du parametre Gorski */
166inline virtual int_4 SizeIndex() const {return(nSide_);}
167
168/* retourne les pointeurs /remplit les tableaux */
169
170
171
172
173/* impression */
174void print(ostream& os) const;
175
176private :
177
178// ------------- méthodes internes ----------------------
179void InitNul();
180
181int_4 nest2ring(int_4 nside,int_4 ipnest) const;
182int_4 ring2nest(int_4 nside,int_4 ipring) const;
183
184int_4 ang2pix_ring(int_4 nside,double theta,double phi) const;
185int_4 ang2pix_nest(int_4 nside,double theta,double phi) const;
186void pix2ang_ring(int_4 nside,int_4 ipix,double& theta,double& phi) const;
187void pix2ang_nest(int_4 nside,int_4 ipix,double& theta,double& phi) const;
188inline void setParameters(int_4 nside, int_4 nbpixels, double solangle)
189 {
190 nSide_= nside;
191 nPix_= nbpixels;
192 omeg_= solangle;
193 }
194
195// ------------- variables internes -----------------------
196int_4 nSide_;
197int_4 nPix_;
198double omeg_;
199
200NDataBlock<T> pixels_;
201
202};
203
204//
205// ------------- Classe pour la gestion de persistance --
206//
207template <class T>
208class FIO_SphereGorski : public PPersist
209{
210public:
211
212FIO_SphereGorski();
213FIO_SphereGorski(string const & filename);
214FIO_SphereGorski(const SphereGorski<T>& obj);
215FIO_SphereGorski(SphereGorski<T>* obj);
216virtual ~FIO_SphereGorski();
217virtual AnyDataObj* DataObj();
218inline operator SphereGorski<T>() { return(*dobj); }
219//inline SphereGorski<T> getObj() { return(*dobj); }
220
221protected :
222
223virtual void ReadSelf(PInPersist&);
224virtual void WriteSelf(POutPersist&) const;
225SphereGorski<T>* dobj;
226bool ownobj;
227};
228
229//
230// ------------- Classe PIXELS_XY -----------------------
231//
232class PIXELS_XY
233{
234
235public :
236
237static PIXELS_XY& instance();
238
239NDataBlock<int_4> pix2x_;
240NDataBlock<int_4> pix2y_;
241NDataBlock<int_4> x2pix_;
242NDataBlock<int_4> y2pix_;
243
244private :
245
246PIXELS_XY();
247void mk_pix2xy();
248void mk_xy2pix();
249};
250#endif
Note: See TracBrowser for help on using the repository browser.