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

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

ajout arg share ds constructeurs, et methode ContainsSph ds localmap.cc et operateur = , Reza 12/11/99

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