source: Sophya/trunk/SophyaLib/SkyMap/spherethetaphi.h@ 1242

Last change on this file since 1242 was 1196, checked in by ansari, 25 years ago

Introduction de la classe HEALPix pour accrocher les methodes de
converion angle<>index
rajout en methodes inline static de ces methodes de conversion pour
SphereHEALPix<T>
+ Autre modifs cosmetiques + MAJ Makefile , Reza 21/9/2000

File size: 7.1 KB
Line 
1#ifndef SPHERETHETAPHI_SEEN
2#define SPHERETHETAPHI_SEEN
3
4#include "sphericalmap.h"
5#include "ndatablock.h"
6#include "tvector.h"
7
8#include "anydataobj.h"
9#include "ppersist.h"
10
11namespace SOPHYA {
12
13
14
15template <class T>
16class FIO_SphereThetaPhi;
17
18template<class T>
19class FITS_SphereThetaPhi;
20
21
22// ***************** Class SphereThetaPhi *****************************
23/*! sphere splitted with respect to theta, phi : each hemisphere is
24 splitted into (m-1) parallels (equator does not enter into account).
25 This operation defines m slices, each of which is splitted into
26 equidistant meridians. This splitting is realized in such a way that
27 all pixels have the same area and are as square as possible.
28
29 One begins with the hemisphere with positive z, starting from the pole
30 toward the equator. The first pixel is the polar cap ; it is circular
31 and centered on theta=0.
32*/
33template <class T>
34class SphereThetaPhi : public SphericalMap<T>
35{
36
37public :
38
39SphereThetaPhi();
40/*! m is the number of slices in theta on an hemisphere (the polar cap
41 forms the first slice).
42 pet is a dummy parameter at the moment.
43*/
44SphereThetaPhi(int_4 m);
45SphereThetaPhi(const SphereThetaPhi<T>& s, bool share);
46SphereThetaPhi(const SphereThetaPhi<T>& s);
47virtual ~SphereThetaPhi();
48
49 // Temporaire?
50inline virtual bool IsTemp(void) const {
51
52 if ( NPhi_.IsTemp() != pixels_.IsTemp() ||
53 TNphi_.IsTemp() != pixels_.IsTemp()||
54 Theta_.IsTemp() != pixels_.IsTemp() )
55 throw PException(" l'etat 'temporaire' de la spherethetaphi est incoherent");
56 return pixels_.IsTemp();
57}
58/*! Setting blockdata to temporary (see ndatablock documentation) */
59inline virtual void SetTemp(bool temp=false) const
60 {
61 NPhi_.SetTemp(temp);
62 TNphi_.SetTemp(temp);
63 Theta_.SetTemp(temp);
64 pixels_.SetTemp(temp);
65 };
66
67// ------------ Definition of PixelMap abstract methods -
68
69/* retourne le nombre de pixels */
70/*! Return total number of pixels */
71virtual int_4 NbPixels() const;
72
73/* retourne la valeur du pixel d'indice k */
74/*! Return value of pixel with index k */
75virtual T& PixVal(int_4 k);
76virtual T const& PixVal(int_4 k) const;
77
78/* Return true if teta,phi in map */
79virtual bool ContainsSph(double theta, double phi) const;
80/* retourne l'indice du pixel a (theta,phi) */
81/* Return index of the pixel corresponding to direction (theta, phi). */
82virtual int_4 PixIndexSph(double theta, double phi) const;
83
84/* retourne les coordonnees Spheriques du centre du pixel d'indice k */
85/*! Return (theta,phi) coordinates of middle of pixel with index k */
86virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const;
87
88/*! Setting pixel values to a constant */
89virtual T SetPixels(T v);
90
91/* retourne/fixe l'angle Solide de Pixel (steradians) */
92/*! Pixel Solid angle (steradians)
93
94 All the pixels have the same solid angle. The dummy argument is
95 for compatibility with eventual pixelizations which would not
96 fulfil this requirement.
97*/
98virtual double PixSolAngle(int_4 dummy=0) const;
99
100/* retourne/fixe la valeur du parametre de decoupage m */
101inline virtual int_4 SizeIndex() const { return( NTheta_); }
102
103/* Acces to the DataBlock */
104inline NDataBlock<T>& DataBlock() {return pixels_;}
105inline const NDataBlock<T>& DataBlock() const {return pixels_;}
106
107// ------------- Specific methods ----------------------
108
109/*! re-pixelize the sphere */
110virtual void Resize(int_4 m);
111
112inline virtual char* TypeOfMap() const {return "TETAFI";};
113
114/* Valeurs de theta des paralleles et phi des meridiens limitant le pixel d'indice k */
115/* Return values of theta,phi which limit the pixel with index k */
116virtual void Limits(int_4 k,double& th1,double& th2,double& phi1,double& phi2);
117
118/* Nombre de tranches en theta */
119/*! Return number of theta-slices on the sphere */
120uint_4 NbThetaSlices() const;
121
122/* Nombre de pixels en phi de la tranche d'indice kt */
123int_4 NPhi(int_4 kt) const;
124
125/* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */
126/* de la tranche d'indice kt */
127/*! Return theta values which limit the slice kt */
128void Theta(int_4 kt, double& t1, double& t2);
129
130/* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */
131/* dans la tranche d'indice kt */
132/*! Return values of phi which limit the jp-th pixel of the kt-th slice */
133void Phi(int_4 kt, int_4 jp, double& p1, double& p2);
134
135/* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt */
136/*! Return pixel index with sequence index jp in the slice kt */
137int_4 Index(int_4 kt, int_4 jp) const;
138
139/* Indice kt de la tranche et indice jp du pixel d'indice k */
140/*! Return indices kt (theta) and jp (phi) of pixel with index k */
141void ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp);
142
143/*! achieve the splitting into pixels (m has the same signification
144 as for the constructor)
145
146 Each theta-slice of the north hemisphere will be spitted starting f
147 from phi=0 ...
148
149 South hemisphere is scanned in the same direction according to phi
150 and from equator to the pole (the pixel following the last one of
151 the slice closest to the equator with z>0, is the pixel with lowest
152 phi of the slice closest of the equator with z<0).
153*/
154void Pixelize(int_4);
155
156/*! For a theta-slice with index 'index', return :
157
158 the corresponding "theta"
159
160 a vector containing the phi's of the pixels of the slice
161
162 a vector containing the corresponding values of pixels
163*/
164virtual void GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const;
165
166/*! For a theta-slice with index 'index', return :
167
168 the corresponding "theta"
169
170 the corresponding "phi" for first pixel of the slice
171
172 a vector containing indices of the pixels of the slice
173
174 (equally distributed in phi)
175
176 a vector containing the corresponding values of pixels
177*/
178virtual void GetThetaSlice(int_4 index, r_8& theta, r_8& phi0,TVector<int_4>& pixelIndices, TVector<T>& value) const ;
179
180
181/* impression */
182void print(ostream& os) const;
183
184 void CloneOrShare(const SphereThetaPhi<T>& a);
185
186 SphereThetaPhi<T>& Set(const SphereThetaPhi<T>& a);
187 SphereThetaPhi<T>& CopyElt(const SphereThetaPhi<T>& a);
188
189 inline SphereThetaPhi<T>& operator = (const SphereThetaPhi<T>& a)
190 {return Set(a);}
191
192 // friend declaration for classes which handle persistence and FITS IO
193 friend class FIO_SphereThetaPhi<T>;
194 friend class FITS_SphereThetaPhi<T>;
195
196protected :
197
198// ------------- méthodes internes ----------------------
199void InitNul();
200inline void setParameters( int nbThetaIndex, int nbpix, double omega)
201 {
202 NPix_= nbpix;
203 Omega_= omega;
204 NTheta_= nbThetaIndex;
205 }
206
207// ------------- variables internes ---------------------
208 int_4 NTheta_; // nombre de tranches en theta, pour une demi-sphere
209 int_4 NPix_; // nombre total de pixels
210 double Omega_; // angle solide constant pour chaque pixel
211 NDataBlock<int_4> NPhi_; // tableau donnant, pour chaque bande en theta,
212 //le nombre de pixels selon phi
213 NDataBlock<int_4> TNphi_;
214 NDataBlock<r_8> Theta_;
215 NDataBlock<T> pixels_;
216};
217
218
219
220} // Fin du namespace
221
222#endif
Note: See TracBrowser for help on using the repository browser.