source: Sophya/trunk/SophyaLib/Samba/scan.cc@ 228

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

Creation du module DPC/Samba Reza 13/04/99

  • Property svn:executable set to *
File size: 7.0 KB
Line 
1#include <stdlib.h>
2#include <stdio.h>
3
4#include "scan.h"
5
6// valeurs de Pi, 2*Pi, etc
7#include "nbmath.h"
8
9
10//
11//++
12// Class Scan
13//
14// include scan.h nbmath.h
15//
16// Cette classe permet de stocker et traiter les données pour un balayage
17// d'une portion de ciel pour un jeu de valeurs fixé des paramètres précisé
18// dans le constructeur.
19//--
20//++
21//
22// Links Parents
23//
24//
25//--
26//++
27//
28// Links Descendants
29//
30//
31//--
32//++
33// Titre Constructeurs
34//--
35//++
36Scan::Scan(float Ouv,float* Omega,float Fech,float T,
37 float t0=0., float phi0=0.)
38
39//
40// * Ouv = angle d'ouverture (rad)
41// * Omega[3] = direction de l'axe de rotation du satellite (teta,phi)
42// et vitesse de rotation (rad/s)
43// * Fech = fréquence d'échantillonnage (Hz)
44// * T = temps total de prise des données (s)
45// * t0 = instant de départ (s)
46// * phi0 = offset antenne (rad)
47//--
48{
49 mInfo_=NULL;
50 // On memorise les arguments d'appel
51 Ouverture_= Ouv;
52 OmegaTeta_= Omega[0];
53 //
54 // je ne comprends pas ce qui se passe ci-apres (GLM)
55 if( (Omega[0]== 0.0) || (Omega[0]==(float)Pi) )
56 OmegaPhi_ = Omega[1];
57 else
58 OmegaPhi_ = Omega[1]+(float)Pi/2.;
59 OmegaRad_ = Omega[2];
60 FrequenceEch_ = Fech;
61 TempsFinal_ = T;
62 TempsInitial_ = t0;
63 PhiZero_ = phi0;
64
65 float aux= 0.0;
66 // Nombre total de points
67 aux= (TempsFinal_-TempsInitial_)*FrequenceEch_;
68 NmaxPts_= (int_4)(aux);
69
70 // Nombre total de tours
71 aux= OmegaRad_*(TempsFinal_-TempsInitial_)/(2.*Pi);
72 NmaxTrs_= (int_4)(aux);
73
74 // Nombre de points par tour
75 aux= 2.*Pi*FrequenceEch_/OmegaRad_;
76 NPts1Tr_= (int_4)(aux);
77
78 // Creation et initialisation du vecteur des mesures aux points
79 sPix_ = new r_8[NmaxPts_];
80 for( int_4 i=0; i<NmaxPts_; i++ ) sPix_[i]= 0.;
81
82 // matrice de passage du systeme lie au satellite au systeme fixe
83
84 Rota_[0]= cos((double)OmegaPhi_);
85 Rota_[1]= -sin((double)OmegaPhi_)*cos((double)OmegaTeta_);
86 Rota_[2]= sin((double)OmegaPhi_)*sin((double)OmegaTeta_);
87 Rota_[3]= sin((double)OmegaPhi_);
88 Rota_[4]= cos((double)OmegaPhi_)*cos((double)OmegaTeta_);
89 Rota_[5]= -cos((double)OmegaPhi_)*sin((double)OmegaTeta_);
90 Rota_[6]= 0.0;
91 Rota_[7]= sin((double)OmegaTeta_);
92 Rota_[8]= cos((double)OmegaTeta_);
93
94
95 // printf("%f %f %f \n",Rota_[0],Rota_[1],Rota_[2]);
96 // printf("%f %f %f \n",Rota_[3],Rota_[4],Rota_[5]);
97 // printf("%f %f %f \n",Rota_[6],Rota_[7],Rota_[8]);
98
99}
100//++
101Scan::Scan(const Scan& s)
102
103// Constructeur de copie
104//--
105{
106 NmaxPts_ = s. NmaxPts_;
107 Ouverture_ = s.Ouverture_;
108 OmegaTeta_ = s.OmegaTeta_;
109 OmegaPhi_ = s.OmegaPhi_;
110 OmegaRad_ = s.OmegaRad_;
111 FrequenceEch_ = s. FrequenceEch_;
112 TempsFinal_ = s.TempsFinal_;
113 TempsInitial_ = s.TempsInitial_;
114 PhiZero_ = s. PhiZero_;
115 sPix_=new r_8[ NmaxPts_];
116 for (int_4 k=0; k<NmaxPts_; k++) sPix_[k]=s.sPix_[k];
117 for (int k=0; k<9; k++) Rota_[k]=s. Rota_[k];
118}
119//++
120// Titre Destructeur
121//--
122//++
123Scan::~Scan()
124
125//
126//--
127{
128 delete[] sPix_ ;
129}
130//++
131void Scan::WriteSelf(POutPersist& s) const
132
133// créer un fichier persistant
134//--
135{
136 char strg[256];
137 if (mInfo_) {sprintf(strg, "Scan: Theta=%9f Phi=%9f omega=%9f HasInfo", (float)OmegaTeta_, (float)OmegaPhi_, (float)OmegaRad_);
138 }
139 else {sprintf(strg, "Scan: Theta=%9f Phi=%9f omega=%9f ", (float)OmegaTeta_, (float)OmegaPhi_, (float)OmegaRad_);
140 }
141 s.PutLine(strg);
142 if (mInfo_) mInfo_->Write(s);
143 s.PutI4( NmaxPts_);
144 s.PutI4(NmaxTrs_);
145 s.PutI4( NPts1Tr_);
146 s.PutR4(Ouverture_);
147 s.PutR4(OmegaTeta_);
148 s.PutR4(OmegaPhi_);
149 s.PutR4(OmegaRad_);
150 s.PutR4(FrequenceEch_);
151 s.PutR4(TempsFinal_);
152 s.PutR4( TempsInitial_);
153 s.PutR4( PhiZero_);
154 s.PutR8s(sPix_,NmaxPts_);
155 s.PutR8s(Rota_, 9);
156 return;
157}
158
159
160//++
161void Scan::ReadSelf(PInPersist& s)
162
163// relire un fichier persistant
164//--
165{
166 Clear();
167 char strg[256];
168 s.GetLine(strg,255);
169// Pour savoir s'il y avait un DVList Info associe
170 bool hadinfo = false;
171 if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo = true;
172// Pour savoir s'il y avait un DVList Info associe
173 if (hadinfo) { // Lecture eventuelle du DVList Info
174 if (mInfo_ == NULL) mInfo_ = new DVList;
175 mInfo_->Read(s);
176 }
177 s.GetI4( NmaxPts_);
178 s.GetI4(NmaxTrs_);
179 s.GetI4( NPts1Tr_);
180 s.GetR4(Ouverture_);
181 s.GetR4(OmegaTeta_);
182 s.GetR4(OmegaPhi_);
183 s.GetR4(OmegaRad_);
184 s.GetR4(FrequenceEch_);
185 s.GetR4(TempsFinal_);
186 s.GetR4( TempsInitial_);
187 s.GetR4( PhiZero_);
188 sPix_=new r_8[NmaxPts_];
189 s.GetR8s(sPix_,NmaxPts_);
190 s.GetR8s(Rota_, 9);
191}
192
193
194//++
195// Titre Méthodes
196//--
197
198//++
199int_4 Scan::NbPoints() const
200
201// Retourne le nombre de Points du scan
202//--
203{
204 return(NmaxPts_);
205}
206
207/* --Methode-- */
208//++
209int_4 Scan::NbTours() const
210
211// Retourne le nombre total de tours
212//--
213{
214 return(NmaxTrs_);
215}
216
217/* --Methode-- */
218//++
219int_4 Scan::NbPts1Tr() const
220
221// Retourne le nombre de points pour 1 tour
222//--
223{
224 return(NPts1Tr_);
225}
226
227/* --Methode-- */
228//++
229int_4 Scan::ValueIndex(float t) const
230
231// Retourne l'indice du pixel associé au temps t
232//--
233{
234 int_4 k;
235 float eps= 1.0E-06;
236
237 // verification si t est dans [TempsInitial_,TempsFinal_]
238 if( (t< TempsInitial_) || (t> TempsFinal_) ) {
239 printf("\n ValueIndex:: probleme sur le temps t= %f",t);
240 return(-1);
241 }
242
243 k= (int_4)((t-TempsInitial_)*FrequenceEch_+eps);
244 if ( (k< 0) || (k >= NmaxPts_) ) {
245 printf("\n ValueIndex:: probleme sur l'indice du point k= %d",k);
246 return(-1);
247 }
248 return(k);
249}
250
251/* --Methode-- */
252//++
253void Scan::Direction(float t, float& teta , float& phi)
254
255// Retourne les coordonnées (teta,phi) du pixel lié au temps t
256//--
257{
258 r_8 alfa,xs,ys,zs,x,y,z;
259
260 // coordonnees dans le systeme du satellite
261 alfa= OmegaRad_*(t-TempsInitial_)+PhiZero_;
262 xs = sin((double)Ouverture_)*cos(alfa);
263 ys = sin((double)Ouverture_)*sin(alfa);
264 zs = cos((double)Ouverture_);
265
266 // coordonnees dans le systeme fixe
267 x = Rota_[0]*xs+Rota_[1]*ys+Rota_[2]*zs;
268 y = Rota_[3]*xs+Rota_[4]*ys+Rota_[5]*zs;
269 z = Rota_[6]*xs+Rota_[7]*ys+Rota_[8]*zs;
270
271 // angles teta,phi
272 teta = acos(z);
273 phi = atan2(y,x);
274 if( phi< 0. ) phi= DeuxPi+phi;
275}
276
277/* --Methode-- */
278//++
279void Scan::DirectionIndex(int_4 k, float& teta, float& phi)
280
281// Retourne les coordonnées (teta,phi) du pixel d'indice k
282//--
283{
284 float t;
285
286 //recupere le temps associe a l'indice k du pixel
287 t= TempsInitial_+(float)k/FrequenceEch_;
288
289 // angles teta,phi
290 Direction(t, teta, phi);
291}
292
293static r_8 dummy_pixel = 0;
294/* --Methode-- */
295//++
296r_8& Scan::PixelValue(int_4 k) const
297
298// Retourne la valeur du contenu du pixel d'indice k
299//--
300{
301 if ( (k<0) || (k >= NmaxPts_) ) {
302 printf("\n ValueIndex::indice du pixel errone k= %d",k);
303 return(dummy_pixel);
304 }
305 return(sPix_[k]);
306}
307
308void Scan::Clear() {
309 if (sPix_) delete[] sPix_;
310}
311void Scan::InitNull() {
312 sPix_=NULL;
313 mInfo_=NULL;
314}
315
316
317//++
318// Titre Opérateurs
319//--
320//++
321// Links double& operator()(int_4 k)
322//--
323//++
324// Surcharge de la parenthese a un indice entier : remplit ou/et renvoie
325// la valeur du contenu du pixel d'indice k
326//--
327
328
329
330
331
Note: See TracBrowser for help on using the repository browser.