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

Last change on this file since 843 was 840, checked in by ansari, 25 years ago

FIO en fichiers separes

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