[2615] | 1 | #include "sopnamsp.h"
|
---|
[254] | 2 | #include "machdefs.h"
|
---|
[228] | 3 | #include <stdlib.h>
|
---|
| 4 | #include <stdio.h>
|
---|
[3619] | 5 | #include <string.h>
|
---|
[254] | 6 | #include <math.h>
|
---|
[228] | 7 |
|
---|
| 8 | #include "scan.h"
|
---|
[567] | 9 | #include <complex>
|
---|
[809] | 10 | #include "fiondblock.h"
|
---|
[228] | 11 |
|
---|
| 12 | // valeurs de Pi, 2*Pi, etc
|
---|
[809] | 13 | #include "smathconst.h"
|
---|
[228] | 14 |
|
---|
| 15 |
|
---|
| 16 | //
|
---|
| 17 | //++
|
---|
| 18 | // Class Scan
|
---|
| 19 | //
|
---|
[567] | 20 | // include scan.h dvlist.h math.h nbmath.h
|
---|
[228] | 21 | //
|
---|
[567] | 22 | // Storage and treatment of data for a scanning of a part of the sky
|
---|
| 23 | // with a set of given values for parameters (see constructor)
|
---|
[228] | 24 | //--
|
---|
| 25 | //++
|
---|
| 26 | Scan::Scan(float Ouv,float* Omega,float Fech,float T,
|
---|
| 27 | float t0=0., float phi0=0.)
|
---|
| 28 |
|
---|
| 29 | //
|
---|
[567] | 30 | // * Ouv = aperture angle (rad)
|
---|
| 31 | // * Omega[3] = direction of rotation axis of the satellite (teta,phi)
|
---|
| 32 | // and rotation velocity (rad/s)
|
---|
| 33 | // * Fech = sampling frequency (Hz)
|
---|
| 34 | // * T = total time of data acquistion (s)
|
---|
| 35 | // * t0 = starting time (s)
|
---|
| 36 | // * phi0 = offset of antenna (rad)
|
---|
[228] | 37 | //--
|
---|
| 38 | {
|
---|
| 39 | mInfo_=NULL;
|
---|
| 40 | // On memorise les arguments d'appel
|
---|
| 41 | Ouverture_= Ouv;
|
---|
| 42 | OmegaTeta_= Omega[0];
|
---|
| 43 | //
|
---|
| 44 | // je ne comprends pas ce qui se passe ci-apres (GLM)
|
---|
| 45 | if( (Omega[0]== 0.0) || (Omega[0]==(float)Pi) )
|
---|
| 46 | OmegaPhi_ = Omega[1];
|
---|
| 47 | else
|
---|
| 48 | OmegaPhi_ = Omega[1]+(float)Pi/2.;
|
---|
| 49 | OmegaRad_ = Omega[2];
|
---|
| 50 | FrequenceEch_ = Fech;
|
---|
| 51 | TempsFinal_ = T;
|
---|
| 52 | TempsInitial_ = t0;
|
---|
| 53 | PhiZero_ = phi0;
|
---|
| 54 |
|
---|
| 55 | float aux= 0.0;
|
---|
| 56 | // Nombre total de points
|
---|
| 57 | aux= (TempsFinal_-TempsInitial_)*FrequenceEch_;
|
---|
| 58 | NmaxPts_= (int_4)(aux);
|
---|
| 59 |
|
---|
| 60 | // Nombre total de tours
|
---|
| 61 | aux= OmegaRad_*(TempsFinal_-TempsInitial_)/(2.*Pi);
|
---|
| 62 | NmaxTrs_= (int_4)(aux);
|
---|
| 63 |
|
---|
| 64 | // Nombre de points par tour
|
---|
| 65 | aux= 2.*Pi*FrequenceEch_/OmegaRad_;
|
---|
| 66 | NPts1Tr_= (int_4)(aux);
|
---|
| 67 |
|
---|
| 68 | // Creation et initialisation du vecteur des mesures aux points
|
---|
[567] | 69 | // sPix_ = new r_8[NmaxPts_];
|
---|
| 70 | sPix_.ReSize(NmaxPts_);
|
---|
| 71 | sPix_.Reset();
|
---|
| 72 | // for( int_4 i=0; i<NmaxPts_; i++ ) sPix_[i]= 0.;
|
---|
| 73 | for( int_4 i=0; i<NmaxPts_; i++ ) sPix_(i)= 0.;
|
---|
[228] | 74 |
|
---|
| 75 | // matrice de passage du systeme lie au satellite au systeme fixe
|
---|
| 76 |
|
---|
| 77 | Rota_[0]= cos((double)OmegaPhi_);
|
---|
| 78 | Rota_[1]= -sin((double)OmegaPhi_)*cos((double)OmegaTeta_);
|
---|
| 79 | Rota_[2]= sin((double)OmegaPhi_)*sin((double)OmegaTeta_);
|
---|
| 80 | Rota_[3]= sin((double)OmegaPhi_);
|
---|
| 81 | Rota_[4]= cos((double)OmegaPhi_)*cos((double)OmegaTeta_);
|
---|
| 82 | Rota_[5]= -cos((double)OmegaPhi_)*sin((double)OmegaTeta_);
|
---|
| 83 | Rota_[6]= 0.0;
|
---|
| 84 | Rota_[7]= sin((double)OmegaTeta_);
|
---|
| 85 | Rota_[8]= cos((double)OmegaTeta_);
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | // printf("%f %f %f \n",Rota_[0],Rota_[1],Rota_[2]);
|
---|
| 89 | // printf("%f %f %f \n",Rota_[3],Rota_[4],Rota_[5]);
|
---|
| 90 | // printf("%f %f %f \n",Rota_[6],Rota_[7],Rota_[8]);
|
---|
| 91 |
|
---|
| 92 | }
|
---|
[567] | 93 |
|
---|
| 94 |
|
---|
[228] | 95 | //++
|
---|
[701] | 96 | Scan::Scan(const Scan& s, bool share) : sPix_(s.sPix_ , share)
|
---|
[228] | 97 |
|
---|
[567] | 98 | // copy constructor
|
---|
[228] | 99 | //--
|
---|
| 100 | {
|
---|
[567] | 101 | NmaxPts_ = s.NmaxPts_;
|
---|
[228] | 102 | Ouverture_ = s.Ouverture_;
|
---|
| 103 | OmegaTeta_ = s.OmegaTeta_;
|
---|
| 104 | OmegaPhi_ = s.OmegaPhi_;
|
---|
| 105 | OmegaRad_ = s.OmegaRad_;
|
---|
[567] | 106 | FrequenceEch_ = s.FrequenceEch_;
|
---|
| 107 | TempsFinal_ = s.TempsFinal_;
|
---|
[228] | 108 | TempsInitial_ = s.TempsInitial_;
|
---|
[567] | 109 | PhiZero_ = s.PhiZero_;
|
---|
| 110 | for (int k=0; k<9; k++) Rota_[k]=s. Rota_[k];
|
---|
[228] | 111 | }
|
---|
| 112 | //++
|
---|
[567] | 113 | // Titre Destructor
|
---|
[228] | 114 | //--
|
---|
| 115 | //++
|
---|
| 116 | Scan::~Scan()
|
---|
| 117 |
|
---|
| 118 | //
|
---|
| 119 | //--
|
---|
| 120 | {
|
---|
[567] | 121 | // delete[] sPix_ ;
|
---|
[228] | 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | //++
|
---|
[567] | 126 | // Titre Public Methods
|
---|
[228] | 127 | //--
|
---|
| 128 |
|
---|
| 129 | //++
|
---|
| 130 | int_4 Scan::NbPoints() const
|
---|
| 131 |
|
---|
[567] | 132 | // Return the number of points in the scan
|
---|
[228] | 133 | //--
|
---|
| 134 | {
|
---|
| 135 | return(NmaxPts_);
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | /* --Methode-- */
|
---|
| 139 | //++
|
---|
| 140 | int_4 Scan::NbTours() const
|
---|
| 141 |
|
---|
[567] | 142 | // Return total nomber of turns
|
---|
[228] | 143 | //--
|
---|
| 144 | {
|
---|
| 145 | return(NmaxTrs_);
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | /* --Methode-- */
|
---|
| 149 | //++
|
---|
| 150 | int_4 Scan::NbPts1Tr() const
|
---|
| 151 |
|
---|
[567] | 152 | // Return nomber of points for 1 turn
|
---|
[228] | 153 | //--
|
---|
| 154 | {
|
---|
| 155 | return(NPts1Tr_);
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | /* --Methode-- */
|
---|
| 159 | //++
|
---|
| 160 | int_4 Scan::ValueIndex(float t) const
|
---|
| 161 |
|
---|
[567] | 162 | // Return index of pixel associated to time t
|
---|
[228] | 163 | //--
|
---|
| 164 | {
|
---|
| 165 | int_4 k;
|
---|
| 166 | float eps= 1.0E-06;
|
---|
| 167 |
|
---|
| 168 | // verification si t est dans [TempsInitial_,TempsFinal_]
|
---|
| 169 | if( (t< TempsInitial_) || (t> TempsFinal_) ) {
|
---|
| 170 | printf("\n ValueIndex:: probleme sur le temps t= %f",t);
|
---|
| 171 | return(-1);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | k= (int_4)((t-TempsInitial_)*FrequenceEch_+eps);
|
---|
| 175 | if ( (k< 0) || (k >= NmaxPts_) ) {
|
---|
| 176 | printf("\n ValueIndex:: probleme sur l'indice du point k= %d",k);
|
---|
| 177 | return(-1);
|
---|
| 178 | }
|
---|
| 179 | return(k);
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /* --Methode-- */
|
---|
| 183 | //++
|
---|
| 184 | void Scan::Direction(float t, float& teta , float& phi)
|
---|
| 185 |
|
---|
[567] | 186 | // Return (teta,phi) coordinate of pixel related to time t
|
---|
[228] | 187 | //--
|
---|
| 188 | {
|
---|
| 189 | r_8 alfa,xs,ys,zs,x,y,z;
|
---|
| 190 |
|
---|
| 191 | // coordonnees dans le systeme du satellite
|
---|
| 192 | alfa= OmegaRad_*(t-TempsInitial_)+PhiZero_;
|
---|
| 193 | xs = sin((double)Ouverture_)*cos(alfa);
|
---|
| 194 | ys = sin((double)Ouverture_)*sin(alfa);
|
---|
| 195 | zs = cos((double)Ouverture_);
|
---|
| 196 |
|
---|
| 197 | // coordonnees dans le systeme fixe
|
---|
| 198 | x = Rota_[0]*xs+Rota_[1]*ys+Rota_[2]*zs;
|
---|
| 199 | y = Rota_[3]*xs+Rota_[4]*ys+Rota_[5]*zs;
|
---|
| 200 | z = Rota_[6]*xs+Rota_[7]*ys+Rota_[8]*zs;
|
---|
| 201 |
|
---|
| 202 | // angles teta,phi
|
---|
| 203 | teta = acos(z);
|
---|
| 204 | phi = atan2(y,x);
|
---|
| 205 | if( phi< 0. ) phi= DeuxPi+phi;
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | /* --Methode-- */
|
---|
| 209 | //++
|
---|
| 210 | void Scan::DirectionIndex(int_4 k, float& teta, float& phi)
|
---|
| 211 |
|
---|
[567] | 212 | // Return (teta,phi) coordinates of pixel with index k
|
---|
[228] | 213 | //--
|
---|
| 214 | {
|
---|
| 215 | float t;
|
---|
| 216 |
|
---|
| 217 | //recupere le temps associe a l'indice k du pixel
|
---|
| 218 | t= TempsInitial_+(float)k/FrequenceEch_;
|
---|
| 219 |
|
---|
| 220 | // angles teta,phi
|
---|
| 221 | Direction(t, teta, phi);
|
---|
| 222 | }
|
---|
| 223 |
|
---|
| 224 | static r_8 dummy_pixel = 0;
|
---|
| 225 | /* --Methode-- */
|
---|
| 226 | //++
|
---|
[567] | 227 | r_8 const& Scan::PixelValue(int_4 k) const
|
---|
[228] | 228 |
|
---|
| 229 | // Retourne la valeur du contenu du pixel d'indice k
|
---|
| 230 | //--
|
---|
| 231 | {
|
---|
| 232 | if ( (k<0) || (k >= NmaxPts_) ) {
|
---|
| 233 | printf("\n ValueIndex::indice du pixel errone k= %d",k);
|
---|
| 234 | return(dummy_pixel);
|
---|
| 235 | }
|
---|
[567] | 236 | // return(sPix_[k]);
|
---|
| 237 | //return(sPix_(k));
|
---|
| 238 | return *(sPix_.Data()+k);
|
---|
[228] | 239 | }
|
---|
[567] | 240 | //++
|
---|
| 241 | r_8 & Scan::PixelValue(int_4 k)
|
---|
[228] | 242 |
|
---|
[567] | 243 | // Retourne la valeur du contenu du pixel d'indice k
|
---|
| 244 | //--
|
---|
| 245 | {
|
---|
| 246 | if ( (k<0) || (k >= NmaxPts_) ) {
|
---|
| 247 | printf("\n ValueIndex::indice du pixel errone k= %d",k);
|
---|
| 248 | return(dummy_pixel);
|
---|
| 249 | }
|
---|
| 250 | // return(sPix_[k]);
|
---|
| 251 | //return(sPix_(k));
|
---|
| 252 | return *(sPix_.Data()+k);
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | //void Scan::Clear() {
|
---|
| 256 | // if (sPix_) delete[] sPix_;
|
---|
| 257 | //}
|
---|
[228] | 258 | void Scan::InitNull() {
|
---|
[567] | 259 | // sPix_=NULL;
|
---|
[701] | 260 | // sPix_.Reset(); pas de reset (pour le cas de share)
|
---|
[228] | 261 | mInfo_=NULL;
|
---|
| 262 | }
|
---|
[567] | 263 | Scan& Scan::operator = (const Scan& s)
|
---|
| 264 | {
|
---|
| 265 | NmaxPts_ = s.NmaxPts_;
|
---|
| 266 | Ouverture_ = s.Ouverture_;
|
---|
| 267 | OmegaTeta_ = s.OmegaTeta_;
|
---|
| 268 | OmegaPhi_ = s.OmegaPhi_;
|
---|
| 269 | OmegaRad_ = s.OmegaRad_;
|
---|
| 270 | FrequenceEch_ = s.FrequenceEch_;
|
---|
| 271 | TempsFinal_ = s.TempsFinal_;
|
---|
| 272 | TempsInitial_ = s.TempsInitial_;
|
---|
| 273 | PhiZero_ = s.PhiZero_;
|
---|
| 274 | sPix_=s.sPix_;
|
---|
| 275 | for (int k=0; k<9; k++) Rota_[k]=s. Rota_[k];
|
---|
| 276 | return *this;
|
---|
| 277 | }
|
---|
[228] | 278 |
|
---|
| 279 |
|
---|
| 280 | //++
|
---|
[567] | 281 | // Titre Operators
|
---|
[228] | 282 | //--
|
---|
| 283 | //++
|
---|
| 284 | // Links double& operator()(int_4 k)
|
---|
| 285 | //--
|
---|
| 286 | //++
|
---|
[567] | 287 | // fill and/or return value of the pixel with index k
|
---|
[228] | 288 | //--
|
---|
| 289 |
|
---|
| 290 |
|
---|
| 291 |
|
---|
| 292 |
|
---|
| 293 |
|
---|
[567] | 294 | //++
|
---|
| 295 | // Titre class FIO_Scan
|
---|
| 296 | // Delegated objects for persitance management
|
---|
| 297 | //--
|
---|
| 298 |
|
---|
| 299 | //*******************************************************************
|
---|
| 300 | // class FIO_Scan
|
---|
| 301 | // Les objets delegues pour la gestion de persistance
|
---|
| 302 | //*******************************************************************
|
---|
| 303 |
|
---|
| 304 | //++
|
---|
| 305 | FIO_Scan::FIO_Scan()
|
---|
| 306 | //
|
---|
| 307 | //--
|
---|
| 308 | {
|
---|
| 309 | dobj= new Scan;
|
---|
| 310 | ownobj= true;
|
---|
| 311 | }
|
---|
| 312 | //++
|
---|
| 313 | FIO_Scan::FIO_Scan(string const& filename)
|
---|
| 314 | //
|
---|
| 315 | //--
|
---|
| 316 | {
|
---|
| 317 | dobj= new Scan;
|
---|
| 318 | ownobj= true;
|
---|
| 319 | Read(filename);
|
---|
| 320 | }
|
---|
| 321 | //++
|
---|
| 322 | FIO_Scan::FIO_Scan(const Scan& obj)
|
---|
| 323 | //
|
---|
| 324 | //--
|
---|
| 325 | {
|
---|
| 326 | dobj= new Scan(obj);
|
---|
| 327 | ownobj= true;
|
---|
| 328 | }
|
---|
| 329 | FIO_Scan::FIO_Scan(Scan* obj)
|
---|
| 330 | {
|
---|
| 331 | dobj= obj;
|
---|
| 332 | ownobj= false;
|
---|
| 333 | }
|
---|
| 334 | //++
|
---|
| 335 | FIO_Scan::~FIO_Scan()
|
---|
| 336 | //
|
---|
| 337 | //--
|
---|
| 338 | {
|
---|
| 339 | if (ownobj && dobj) delete dobj;
|
---|
| 340 | }
|
---|
| 341 | //++
|
---|
| 342 | AnyDataObj* FIO_Scan::DataObj()
|
---|
| 343 | //
|
---|
| 344 | //--
|
---|
| 345 | {
|
---|
| 346 | return(dobj);
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | //++
|
---|
| 350 | void FIO_Scan::ReadSelf(PInPersist& is)
|
---|
| 351 | //
|
---|
| 352 | //--
|
---|
| 353 | {
|
---|
| 354 |
|
---|
[682] | 355 | int_4 NmaxPts, NmaxTrs, NPts1Tr;
|
---|
[567] | 356 | r_4 Ouverture, OmegaTeta, OmegaPhi, OmegaRad, FrequenceEch;
|
---|
| 357 | r_4 TempsFinal, TempsInitial, PhiZero;
|
---|
| 358 | r_8 Rota[9];
|
---|
| 359 |
|
---|
| 360 | if(dobj == NULL)
|
---|
| 361 | {
|
---|
| 362 | dobj= new Scan;
|
---|
| 363 | }
|
---|
| 364 |
|
---|
| 365 | // Pour savoir s'il y avait un DVList Info associe
|
---|
| 366 | char strg[256];
|
---|
| 367 | is.GetLine(strg, 255);
|
---|
| 368 | bool hadinfo= false;
|
---|
| 369 | if (strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo = true;
|
---|
| 370 | if(hadinfo)
|
---|
| 371 | { // Lecture eventuelle du DVList Info
|
---|
| 372 | is >> dobj->Info();
|
---|
| 373 | }
|
---|
| 374 |
|
---|
| 375 |
|
---|
| 376 | is.GetI4(NmaxPts);
|
---|
| 377 | is.GetI4(NmaxTrs);
|
---|
| 378 | is.GetI4(NPts1Tr);
|
---|
| 379 | dobj->SetIntParams(NmaxPts,NmaxTrs,NPts1Tr);
|
---|
| 380 |
|
---|
| 381 | is.GetR4(Ouverture);
|
---|
| 382 | is.GetR4(OmegaTeta);
|
---|
| 383 | is.GetR4(OmegaPhi);
|
---|
| 384 | is.GetR4(OmegaRad);
|
---|
| 385 | is.GetR4(FrequenceEch);
|
---|
| 386 | is.GetR4(TempsFinal);
|
---|
| 387 | is.GetR4(TempsInitial);
|
---|
| 388 | is.GetR4(PhiZero);
|
---|
| 389 | is.GetR8s(Rota, 9);
|
---|
| 390 | dobj->SetFloatParams(Ouverture,OmegaTeta,OmegaPhi,OmegaRad,
|
---|
| 391 | FrequenceEch,TempsFinal,TempsInitial,PhiZero,Rota);
|
---|
[701] | 392 | // On lit le DataBlock;
|
---|
| 393 | FIO_NDataBlock<r_8> fio_nd(&dobj->DataBlock());
|
---|
| 394 | fio_nd.Read(is);
|
---|
[567] | 395 | }
|
---|
| 396 | //++
|
---|
| 397 | void FIO_Scan::WriteSelf(POutPersist& os) const
|
---|
| 398 | //
|
---|
| 399 | //--
|
---|
| 400 | {
|
---|
| 401 | r_4 Ouverture, OmegaTeta, OmegaPhi, OmegaRad, FrequenceEch;
|
---|
| 402 | r_4 TempsFinal, TempsInitial, PhiZero;
|
---|
| 403 | r_8 Rota[9];
|
---|
| 404 | char strg[256];
|
---|
| 405 |
|
---|
| 406 | if(dobj == NULL)
|
---|
| 407 | {
|
---|
| 408 | cout << " FIO_Scan::WriteSelf:: dobj= null " << endl;
|
---|
| 409 | return;
|
---|
| 410 | }
|
---|
| 411 | dobj->GetFloatParams(Ouverture,OmegaTeta,OmegaPhi,OmegaRad,
|
---|
| 412 | FrequenceEch,TempsFinal,TempsInitial,PhiZero,Rota);
|
---|
| 413 | if (dobj->ptrInfo())
|
---|
| 414 | {sprintf(strg, "Scan: Theta=%9f Phi=%9f omega=%9f HasInfo",
|
---|
| 415 | (float)OmegaTeta, (float)OmegaPhi, (float)OmegaRad);
|
---|
| 416 | os.PutLine(strg);
|
---|
| 417 | os << dobj->Info();
|
---|
| 418 | }
|
---|
| 419 | else
|
---|
| 420 | {
|
---|
| 421 | sprintf(strg, "Scan: Theta=%9f Phi=%9f omega=%9f ",
|
---|
| 422 | (float)OmegaTeta, (float)OmegaPhi, (float)OmegaRad);
|
---|
| 423 | os.PutLine(strg);
|
---|
| 424 | }
|
---|
| 425 |
|
---|
| 426 | os.PutI4(dobj->NbPoints());
|
---|
| 427 | os.PutI4(dobj->NbTours());
|
---|
| 428 | os.PutI4(dobj->NbPts1Tr());
|
---|
| 429 |
|
---|
| 430 | os.PutR4(Ouverture);
|
---|
| 431 | os.PutR4(OmegaTeta);
|
---|
| 432 | os.PutR4(OmegaPhi);
|
---|
| 433 | os.PutR4(OmegaRad);
|
---|
| 434 | os.PutR4(FrequenceEch);
|
---|
| 435 | os.PutR4(TempsFinal);
|
---|
| 436 | os.PutR4(TempsInitial);
|
---|
| 437 | os.PutR4(PhiZero);
|
---|
| 438 | os.PutR8s(Rota, 9);
|
---|
| 439 |
|
---|
[701] | 440 | // On ecrit le dataBlock
|
---|
| 441 | FIO_NDataBlock<r_8> fio_nd(&dobj->DataBlock());
|
---|
| 442 | fio_nd.Write(os);
|
---|
[567] | 443 |
|
---|
| 444 | }
|
---|