source: Sophya/trunk/SophyaLib/Samba/spherethetaphi.h@ 745

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

nouvelle gestion des thetaslices

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