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

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

modifs constructeurs copie et operateur =

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