| [649] | 1 | #include "diabolo.h" 
 | 
|---|
 | 2 | #include "senseur_stellaire.h" 
 | 
|---|
 | 3 | #include "recons_sst.h" 
 | 
|---|
 | 4 | #include "FindPeri.h" 
 | 
|---|
 | 5 | #include "stabilite.h"
 | 
|---|
 | 6 | FILE* f;
 | 
|---|
 | 7 | long nstarcatal,nposaxesimu;
 | 
|---|
 | 8 | struct star {
 | 
|---|
 | 9 |   float ra; // en heures dans le catalogue de depart
 | 
|---|
 | 10 |   float dec;// en degres dans le catalogue de depart
 | 
|---|
 | 11 |   short mag; // mag * 100
 | 
|---|
 | 12 | };
 | 
|---|
 | 13 | #define nstpturn 100
 | 
|---|
 | 14 | struct sstgraph {
 | 
|---|
 | 15 |   int netdet; // nombre d'etoiles detectees
 | 
|---|
 | 16 |   float raax; // coordonnees equatoriales de l'axe de rotation du telescope
 | 
|---|
 | 17 |   float decax;
 | 
|---|
 | 18 |   long numcat[nstpturn]; //numero de l'etoile dans le fichier de depart
 | 
|---|
 | 19 |   float phase[nstpturn]; //phase de l'etoile (angle/Nord - Est=+90¡ - ds plan perp axe rot ballon)
 | 
|---|
 | 20 |   float cosinus[nstpturn]; // de l'angle entre la direction de l'etoile et l'axe de rotation du ballon
 | 
|---|
 | 21 |   float fluxcat[nstpturn]; //flux de l'etoile en unites arbitraires
 | 
|---|
 | 22 |   int   icl[nstpturn]; //ordre de l'etoile pour un classement par phases croissantes
 | 
|---|
 | 23 | };
 | 
|---|
 | 24 | struct star* stars;
 | 
|---|
 | 25 | struct sstgraph* listord;
 | 
|---|
 | 26 | int fichierslus=0;
 | 
|---|
 | 27 | float instant[nmemechant],sfluxvu[nmemechant],barette[nmemechant],phd0[nmemechant];
 | 
|---|
 | 28 | float deltap[nmemechant],rapflx[nmemechant];
 | 
|---|
 | 29 | float deltapcat[nstpturn],rapflxcat[nstpturn];
 | 
|---|
 | 30 | float cases[ncasdiftps];float maxcas;float somcas;
 | 
|---|
 | 31 | float sflxv,maintenant,laplushaute;
 | 
|---|
 | 32 | float tdeb;int flagstar;int flagwind;
 | 
|---|
 | 33 | float separtps,separenz;
 | 
|---|
 | 34 | float Period=10.,NewPeriod;float Phase;int Sens=9999;
 | 
|---|
 | 35 | float WidthCas,StepCas;
 | 
|---|
 | 36 | float tpsminfen,tpsmaxfen;
 | 
|---|
 | 37 | float Liminffen,Limsupfen;
 | 
|---|
 | 38 | double CoupFlux;
 | 
|---|
 | 39 | float Papa,poidsvois;
 | 
|---|
 | 40 | float tauxper;long nstastat,ndsper;
 | 
|---|
 | 41 | int flagChPer,flagvuefiltree;
 | 
|---|
 | 42 | int nptsfenper,nptsfenphs;
 | 
|---|
 | 43 | float somtps,somecartps,somecarz;
 | 
|---|
 | 44 | float memtemps,membar;
 | 
|---|
 | 45 | int ncoups;int statcalcphase[ncasphase];int CasesVides;
 | 
|---|
 | 46 | float pasenphase,ecarmoytps[ncasphase],ecarmoyz[ncasphase];
 | 
|---|
 | 47 | float sini[ncasphase],cosini[ncasphase];
 | 
|---|
 | 48 | float phaseret=-9999;
 | 
|---|
 | 49 | float pluvieux;int nlistevue,numaccro,flcatmin;
 | 
|---|
 | 50 | #define D2R .0174533 //1 degre = D2R radians
 | 
|---|
 | 51 | #define H2R .261799 // 1 heure siderale = H2R radians
 | 
|---|
 | 52 | #define P2 1.570796 // pi sur 2
 | 
|---|
 | 53 | #define PI 3.14159265359 // pi
 | 
|---|
 | 54 | #define DPI 6.2831853 // 2*pi
 | 
|---|
 | 55 | //variables geometriques du senseur stellaire :
 | 
|---|
 | 56 | 
 | 
|---|
 | 57 | #define sommetdeg 49. // 1/2 angle d'ouverture du cone moye balay par la barette (en degres)
 | 
|---|
 | 58 | #define ouvertdeg 1.44 // extension de la barette en delta (en degres)
 | 
|---|
 | 59 | float sommet,ouvert; // memes angles en radians
 | 
|---|
 | 60 |    float decaxe;
 | 
|---|
 | 61 |    float raaxe;
 | 
|---|
 | 62 | 
 | 
|---|
 | 63 | 
 | 
|---|
 | 64 | void init_recons_sst()
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 | //appele au debut par diabolo.c, puis a chaque reset de la fenetre findperiod
 | 
|---|
 | 67 | {
 | 
|---|
 | 68 | int i;
 | 
|---|
 | 69 | double valeur=0;
 | 
|---|
 | 70 | //printf("periode echantillonnage %f",gg->periode_echantillonage);
 | 
|---|
 | 71 | pasenphase=360./(float)(ncasphase);
 | 
|---|
 | 72 | for(i=0;i<nmemechant;i++)
 | 
|---|
 | 73 | {
 | 
|---|
 | 74 | instant[i]=0.;
 | 
|---|
 | 75 | sfluxvu[i]=0.;
 | 
|---|
 | 76 | barette[i]=0.;
 | 
|---|
 | 77 | }
 | 
|---|
 | 78 | for(i=0;i<ncasdiftps;i++)
 | 
|---|
 | 79 | {
 | 
|---|
 | 80 | cases[i]=0;
 | 
|---|
 | 81 | }
 | 
|---|
 | 82 | flagvuefiltree=0;
 | 
|---|
 | 83 | //exec_FindPeriod(fenetre_Find_Period,ouverture,valeur);
 | 
|---|
 | 84 | flagwind=0;
 | 
|---|
 | 85 | maxcas=0;
 | 
|---|
 | 86 | Period=LowSeek;Phase=-9999.;Sens=-9999;
 | 
|---|
 | 87 | somcas=0;
 | 
|---|
 | 88 | tdeb=0;
 | 
|---|
 | 89 | flagstar=0;
 | 
|---|
 | 90 | CoupFlux=10.;
 | 
|---|
 | 91 | if(fenetre(fenetre_Find_Period)) CoupFlux=Rd_CpFl(fenetre_Find_Period);
 | 
|---|
 | 92 | //printf("coupure en flux %d \n",(int)(CoupFlux));
 | 
|---|
 | 93 | tauxper=0.;
 | 
|---|
 | 94 | nstastat=0;
 | 
|---|
 | 95 | ndsper=0;
 | 
|---|
 | 96 | nptsfenper=0;
 | 
|---|
 | 97 | nptsfenphs=0;
 | 
|---|
 | 98 | memtemps=-1.;
 | 
|---|
 | 99 | ncoups=0;
 | 
|---|
 | 100 | somtps=0;somecartps=0;somecarz=0;
 | 
|---|
 | 101 | 
 | 
|---|
 | 102 |                                 Liminffen=LowSeek;
 | 
|---|
 | 103 |                                 Limsupfen=HighSeek;
 | 
|---|
 | 104 |                                 Papa=10.;
 | 
|---|
 | 105 |                                 if(fenetre(fenetre_Find_Period))
 | 
|---|
 | 106 |                                  {
 | 
|---|
 | 107 |                                  if(DonnePeriod() != -1)
 | 
|---|
 | 108 |                                   {
 | 
|---|
 | 109 |                                   Liminffen=DonnePeriod()-1;
 | 
|---|
 | 110 |                                   Limsupfen=DonnePeriod()+1;
 | 
|---|
 | 111 |                                   Papa=1.;
 | 
|---|
 | 112 |                                   }
 | 
|---|
 | 113 |                                  flagwind=1;
 | 
|---|
 | 114 |                                  }
 | 
|---|
 | 115 |                                 
 | 
|---|
 | 116 |                                 passargu(Liminffen,Limsupfen,Papa);
 | 
|---|
 | 117 |                                         //nouveauD(fenetre_Find_Period,FindPeriod_id,"FindPeriod",exec_FindPeriod);
 | 
|---|
 | 118 |                                         //nouveauD(fenetre_Phase_SST,phase_id,"phase",exec_phase);
 | 
|---|
 | 119 |                                 //corFC flagwind=0;
 | 
|---|
 | 120 |                                 raz_fen_phase();
 | 
|---|
 | 121 |                                 if (fenetre(fenetre_Find_Period)) {
 | 
|---|
 | 122 |                                         selectgra(fenetre_Find_Period);
 | 
|---|
 | 123 |                                 graph->xmin=Liminffen;
 | 
|---|
 | 124 |                                 graph->xmax=Limsupfen;
 | 
|---|
 | 125 |                                 graph->xpas=Papa;
 | 
|---|
 | 126 |                                 retrace(fenetre_Find_Period);
 | 
|---|
 | 127 |                                         ecritD(fenetre_Find_Period,FP_vperesti," %7.3f",DonnePeriod());
 | 
|---|
 | 128 |                         }
 | 
|---|
 | 129 | 
 | 
|---|
 | 130 |     tpsminfen=Liminffen;
 | 
|---|
 | 131 |     tpsmaxfen=Limsupfen; 
 | 
|---|
 | 132 | StepCas=(HighSeek-LowSeek)/(float)(ncasdiftps);
 | 
|---|
 | 133 | WidthCas=2*StepCas;
 | 
|---|
 | 134 | tabulesincos();
 | 
|---|
 | 135 | CasesVides=ncasphase;
 | 
|---|
 | 136 | //lecture des catalogues STELLAIRES!
 | 
|---|
 | 137 | if(fichierslus==0)
 | 
|---|
 | 138 | {
 | 
|---|
 | 139 | fichierslus=1;
 | 
|---|
 | 140 | printf(" \n");
 | 
|---|
 | 141 |   // Catalogue Dominique Yvon
 | 
|---|
 | 142 |   {
 | 
|---|
 | 143 |      short ref;
 | 
|---|
 | 144 |      long n;
 | 
|---|
 | 145 |      if (FSOpen("\phyp6HADY.dat",0,&ref)) {
 | 
|---|
 | 146 |          printf("***ERREUR*** ouverture hyp6Hammam.dat\n");
 | 
|---|
 | 147 |          return;
 | 
|---|
 | 148 |      }
 | 
|---|
 | 149 |      n = sizeof(long);
 | 
|---|
 | 150 |      FSRead(ref, &n, (char*) &nstarcatal);
 | 
|---|
 | 151 |    printf("nstarcatal = %d\n", nstarcatal);
 | 
|---|
 | 152 |      n = nstarcatal*sizeof(struct star);
 | 
|---|
 | 153 |      stars = (struct star*) malloc(n);
 | 
|---|
 | 154 |      FSRead(ref, &n, (char*) stars);
 | 
|---|
 | 155 |      FSClose(ref);
 | 
|---|
 | 156 |      printf("Hyp6DY m<6 : read %d stars\n", nstarcatal);
 | 
|---|
 | 157 |   }
 | 
|---|
 | 158 |    for(i=0;i<5;i++)
 | 
|---|
 | 159 |    {
 | 
|---|
 | 160 |    printf("alpha %f,delta %f, mag %d \n",stars[i].ra,stars[i].dec,stars[i].mag);
 | 
|---|
 | 161 |         }
 | 
|---|
 | 162 |   {
 | 
|---|
 | 163 |      short ref;
 | 
|---|
 | 164 |      long n;
 | 
|---|
 | 165 |      if (FSOpen("\psstgraphs.dat",0,&ref)) {
 | 
|---|
 | 166 |          printf("***ERREUR*** ouverture sstgraphs.dat\n");
 | 
|---|
 | 167 |          return;
 | 
|---|
 | 168 |      }
 | 
|---|
 | 169 |      n = sizeof(long);
 | 
|---|
 | 170 |      FSRead(ref, &n, (char*) &nposaxesimu);
 | 
|---|
 | 171 |    printf("nstarcatal = %d\n", nposaxesimu);
 | 
|---|
 | 172 |      n = nposaxesimu*sizeof(struct sstgraph);
 | 
|---|
 | 173 |      listord = (struct sstgraph*) malloc(n);
 | 
|---|
 | 174 |      FSRead(ref, &n, (char*) listord);
 | 
|---|
 | 175 |      FSClose(ref);
 | 
|---|
 | 176 |      printf("sstgraph.dat : read %d positions simulees\n", nposaxesimu);
 | 
|---|
 | 177 |   }
 | 
|---|
 | 178 |         printf("nombre d'etoiles selectionnees %d\n",listord[0].netdet);
 | 
|---|
 | 179 |         numaccro=0;flcatmin=1;
 | 
|---|
 | 180 | }
 | 
|---|
 | 181 | }
 | 
|---|
 | 182 | 
 | 
|---|
 | 183 | void exec_recons_sst()
 | 
|---|
 | 184 | {
 | 
|---|
 | 185 | int i,icour;
 | 
|---|
 | 186 | int cascour,casper,vudsper;
 | 
|---|
 | 187 | int valid;
 | 
|---|
 | 188 | float delbar,delebarre;
 | 
|---|
 | 189 | float deltan,deltintin;
 | 
|---|
 | 190 | float delcas,pocac;
 | 
|---|
 | 191 | sflxv=0.;
 | 
|---|
 | 192 | if(nfoundstars>0)
 | 
|---|
 | 193 | {
 | 
|---|
 | 194 | if(nfoundstars>MAXFOUNDSTARS) nfoundstars=MAXFOUNDSTARS;
 | 
|---|
 | 195 | laplushaute=0.;
 | 
|---|
 | 196 | for(i=0;i<nfoundstars;i++)
 | 
|---|
 | 197 | {
 | 
|---|
 | 198 | if(mfoundstars[i]>sflxv)
 | 
|---|
 | 199 | {sflxv=mfoundstars[i];
 | 
|---|
 | 200 | laplushaute=zfoundstars[i];
 | 
|---|
 | 201 | }
 | 
|---|
 | 202 | //printf("%d %f %f %f\n",i,tfoundstars[i],zfoundstars[i],mfoundstars[i]);
 | 
|---|
 | 203 | }
 | 
|---|
 | 204 | 
 | 
|---|
 | 205 | if(sflxv>CoupFlux)
 | 
|---|
 | 206 | {
 | 
|---|
 | 207 | maintenant=tfoundstars[0];
 | 
|---|
 | 208 | membar=laplushaute;
 | 
|---|
 | 209 | if(flagstar==0)
 | 
|---|
 | 210 |  {
 | 
|---|
 | 211 |  tdeb=maintenant;
 | 
|---|
 | 212 |  flagstar=1;
 | 
|---|
 | 213 |  }
 | 
|---|
 | 214 |  if(maintenant-tdeb>LowSeek)
 | 
|---|
 | 215 |  {
 | 
|---|
 | 216 |  vudsper=0;
 | 
|---|
 | 217 |  valid=0;
 | 
|---|
 | 218 |  delbar=0;
 | 
|---|
 | 219 |  delebarre=10000;
 | 
|---|
 | 220 |  deltan=0.;
 | 
|---|
 | 221 |  deltintin=1.;
 | 
|---|
 | 222 | for(i=0;i<nmemechant;i++)
 | 
|---|
 | 223 | {
 | 
|---|
 | 224 | if(sfluxvu[i]==0.) break;
 | 
|---|
 | 225 | separtps=maintenant-instant[i];
 | 
|---|
 | 226 | separenz=laplushaute-barette[i];
 | 
|---|
 | 227 | if(separtps>LowSeek && fabs(sfluxvu[i]-sflxv)/sflxv<.5)
 | 
|---|
 | 228 |  {
 | 
|---|
 | 229 |  if(separtps>tpsminfen && separtps<tpsmaxfen)
 | 
|---|
 | 230 |  {
 | 
|---|
 | 231 |  trace_point(fenetre_Find_Period);
 | 
|---|
 | 232 |  nptsfenper++;
 | 
|---|
 | 233 |  if(nptsfenper==QuorumRafrai && fenetre(fenetre_Find_Period))
 | 
|---|
 | 234 |  { selectgra(fenetre_Find_Period);efface(fenetre_Find_Period);nptsfenper=0;}
 | 
|---|
 | 235 |  }
 | 
|---|
 | 236 |  // recherche de periode
 | 
|---|
 | 237 |  if(separtps<HighSeek)
 | 
|---|
 | 238 |  {
 | 
|---|
 | 239 |  casper=(int)((Period-LowSeek)/StepCas);
 | 
|---|
 | 240 |  cascour=(int)((separtps-LowSeek)/StepCas);
 | 
|---|
 | 241 |  delcas=separtps-StepCas*(cascour+.5)-LowSeek;
 | 
|---|
 | 242 |  pocac=fabs(delcas/StepCas);
 | 
|---|
 | 243 | // printf("separtps %f delcas %f pocac %f\n",separtps,delcas,pocac);
 | 
|---|
 | 244 |  
 | 
|---|
 | 245 |  
 | 
|---|
 | 246 |  if(cascour>0 && cascour<ncasdiftps-1)
 | 
|---|
 | 247 |   {
 | 
|---|
 | 248 |   cases[cascour]+=25./separtps*(1.-pocac);
 | 
|---|
 | 249 |   if(delcas>0.){cases[cascour+1]+=25./separtps*pocac;}
 | 
|---|
 | 250 |   else {cases[cascour-1]+=25./separtps*pocac;}
 | 
|---|
 | 251 |   somcas+=25./separtps;
 | 
|---|
 | 252 |    if(fabs(cascour-casper)<2)
 | 
|---|
 | 253 |    {vudsper++;
 | 
|---|
 | 254 |    }
 | 
|---|
 | 255 |   if(cases[cascour]>maxcas)
 | 
|---|
 | 256 |    {
 | 
|---|
 | 257 |    maxcas=cases[cascour];
 | 
|---|
 | 258 |    poidsvois=cases[cascour-1]+cases[cascour]+cases[cascour+1];
 | 
|---|
 | 259 |    NewPeriod=LowSeek+
 | 
|---|
 | 260 |    (cascour+.5+(cases[cascour+1]-cases[cascour-1])/poidsvois)*StepCas;
 | 
|---|
 | 261 |     if(poidsvois>5*somcas/ncasdiftps){
 | 
|---|
 | 262 |     flagChPer=0;
 | 
|---|
 | 263 |     if(fabs(Period-NewPeriod)>1.)
 | 
|---|
 | 264 |     {nstastat=0;ndsper=0;tauxper=0.;
 | 
|---|
 | 265 |     { if(DonnePeriod() != -1 && fenetre(fenetre_Find_Period))
 | 
|---|
 | 266 |     {selectgra(fenetre_Find_Period);efface(fenetre_Find_Period);nptsfenper=0;}}}
 | 
|---|
 | 267 |     if(fabs(Period-NewPeriod)>.1) flagChPer=1;
 | 
|---|
 | 268 |     if(fabs(Period-NewPeriod)>.010)
 | 
|---|
 | 269 |     {raz_fen_phase();}
 | 
|---|
 | 270 |     Period=NewPeriod;
 | 
|---|
 | 271 |     }
 | 
|---|
 | 272 | //   printf("maxcas %f somcas/ncasdiftps %f Periode : %f\n",maxcas,
 | 
|---|
 | 273 | //   somcas/(float)(ncasdiftps),Period);
 | 
|---|
 | 274 |    }
 | 
|---|
 | 275 |   }
 | 
|---|
 | 276 |   }
 | 
|---|
 | 277 |   delbar=separenz;
 | 
|---|
 | 278 |   deltan=separtps-Period;
 | 
|---|
 | 279 |   if(DonnePeriod() != -1 
 | 
|---|
 | 280 |   && fabs(deltan-Period)<FourchTps && fabs(deltan-Period-2*deltintin)<FourchTps 
 | 
|---|
 | 281 |   && fabs(delebarre-2*delbar)<8 && valid==1)
 | 
|---|
 | 282 |   {
 | 
|---|
 | 283 |         tracephase();
 | 
|---|
 | 284 | //      membar=.3*barette[i]+.7*membar;
 | 
|---|
 | 285 |         nptsfenphs++;
 | 
|---|
 | 286 |         if(nptsfenphs==RafraiPhase)     {raz_fen_phase();}
 | 
|---|
 | 287 | //      printf("periode %8.3f phases tpsdiodes %8.1f sens %d\n",DonnePeriod(),DonnePhase(),DonneSens());
 | 
|---|
 | 288 | 
 | 
|---|
 | 289 |   }
 | 
|---|
 | 290 |   if(DonnePeriod() != -1 && fabs(deltan)<FourchTps && fabs(delbar)<8)
 | 
|---|
 | 291 |   {valid=1;delebarre=delbar;deltintin=deltan;}
 | 
|---|
 | 292 |   
 | 
|---|
 | 293 |  }
 | 
|---|
 | 294 | }
 | 
|---|
 | 295 | nstastat++;
 | 
|---|
 | 296 | if(vudsper!=0)ndsper++;
 | 
|---|
 | 297 | if(nstastat>StatValidePeriode)
 | 
|---|
 | 298 | {
 | 
|---|
 | 299 |         tauxper=(float)(ndsper)/(float)(nstastat);
 | 
|---|
 | 300 | 
 | 
|---|
 | 301 | //      printf("efficacite periode %f\n",tauxper);
 | 
|---|
 | 302 | }
 | 
|---|
 | 303 | 
 | 
|---|
 | 304 | if(nstastat==50)        {nstastat=0;ndsper=0;}
 | 
|---|
 | 305 | if(DonnePeriod()==-1){
 | 
|---|
 | 306 | raz_fen_phase();
 | 
|---|
 | 307 | if(fenetre(fenetre_Find_Period) && tpsminfen != 10.){
 | 
|---|
 | 308 |                                 selectgra(fenetre_Find_Period);
 | 
|---|
 | 309 |                                 graph->xmin=10.;
 | 
|---|
 | 310 |                                 graph->xmax=40.;
 | 
|---|
 | 311 |                                 graph->xpas=10.;
 | 
|---|
 | 312 |                                 Liminffen=graph->xmin;
 | 
|---|
 | 313 |                                 Limsupfen=graph->xmax;
 | 
|---|
 | 314 |                                     tpsminfen=graph->xmin;
 | 
|---|
 | 315 |                                 tpsmaxfen=graph->xmax;
 | 
|---|
 | 316 |                                 passargu(Liminffen,Limsupfen,Papa);
 | 
|---|
 | 317 |                                 efface(fenetre_Find_Period);
 | 
|---|
 | 318 |                                 retrace(fenetre_Find_Period);
 | 
|---|
 | 319 |                                         nptsfenper=0;
 | 
|---|
 | 320 | }
 | 
|---|
 | 321 | 
 | 
|---|
 | 322 | } else
 | 
|---|
 | 323 | {
 | 
|---|
 | 324 | if(flagChPer==1){
 | 
|---|
 | 325 |                 selectgra(fenetre_Find_Period);
 | 
|---|
 | 326 |                                 graph->xmin=DonnePeriod()-1.;
 | 
|---|
 | 327 |                                 graph->xmax=DonnePeriod()+1.;
 | 
|---|
 | 328 |                                 graph->xpas=1.;
 | 
|---|
 | 329 |                                 Liminffen=graph->xmin;
 | 
|---|
 | 330 |                                 Limsupfen=graph->xmax;
 | 
|---|
 | 331 |                                     tpsminfen=graph->xmin;
 | 
|---|
 | 332 |                                 tpsmaxfen=graph->xmax;
 | 
|---|
 | 333 |                                 passargu(Liminffen,Limsupfen,Papa);
 | 
|---|
 | 334 |                                 efface(fenetre_Find_Period);
 | 
|---|
 | 335 |                                 retrace(fenetre_Find_Period);
 | 
|---|
 | 336 |                                         nptsfenper=0;
 | 
|---|
 | 337 | }
 | 
|---|
 | 338 | }
 | 
|---|
 | 339 | if(fenetre(fenetre_Find_Period))
 | 
|---|
 | 340 | {selectgra(fenetre_Find_Period);ecritD(fenetre_Find_Period,FP_vperesti," %7.3f",DonnePeriod());}
 | 
|---|
 | 341 | if(Liminffen==LowSeek && DonnePeriod() != -1 && fenetre(fenetre_Find_Period)) 
 | 
|---|
 | 342 | {
 | 
|---|
 | 343 |                                 selectgra(fenetre_Find_Period);
 | 
|---|
 | 344 |                                 graph->xmin=DonnePeriod()-1.;
 | 
|---|
 | 345 |                                 graph->xmax=DonnePeriod()+1.;
 | 
|---|
 | 346 |                                 graph->xpas=1.;
 | 
|---|
 | 347 |                                 Liminffen=graph->xmin;
 | 
|---|
 | 348 |                                 Limsupfen=graph->xmax;
 | 
|---|
 | 349 |                                     tpsminfen=graph->xmin;
 | 
|---|
 | 350 |                                 tpsmaxfen=graph->xmax;
 | 
|---|
 | 351 |                                 passargu(Liminffen,Limsupfen,Papa);
 | 
|---|
 | 352 |                                 efface(fenetre_Find_Period);
 | 
|---|
 | 353 |                                 retrace(fenetre_Find_Period);
 | 
|---|
 | 354 | 
 | 
|---|
 | 355 | }
 | 
|---|
 | 356 | }
 | 
|---|
 | 357 | 
 | 
|---|
 | 358 | icour=0;
 | 
|---|
 | 359 | pluvieux=maintenant;
 | 
|---|
 | 360 | for(i=nmemechant-1;i>0;i--)
 | 
|---|
 | 361 |  {
 | 
|---|
 | 362 |  icour++;
 | 
|---|
 | 363 |  if(sfluxvu[i-1]==0.) continue;
 | 
|---|
 | 364 |  if(instant[i]<pluvieux)pluvieux=instant[i];
 | 
|---|
 | 365 |  sfluxvu[i]=sfluxvu[i-1];
 | 
|---|
 | 366 |  instant[i]=instant[i-1];
 | 
|---|
 | 367 |  barette[i]=barette[i-1];
 | 
|---|
 | 368 |  phd0[i]=phd0[i-1];
 | 
|---|
 | 369 |   if(DonnePeriod()!=-1){if(maintenant-instant[i]>3.*DonnePeriod())
 | 
|---|
 | 370 |    {
 | 
|---|
 | 371 |     sfluxvu[i]=0.;
 | 
|---|
 | 372 |     instant[i]=0.;
 | 
|---|
 | 373 |     barette[i]=0.;
 | 
|---|
 | 374 |     phd0[i]=0.;
 | 
|---|
 | 375 |    }
 | 
|---|
 | 376 |    }
 | 
|---|
 | 377 |  }
 | 
|---|
 | 378 | sfluxvu[0]=sflxv;
 | 
|---|
 | 379 | instant[0]=maintenant;
 | 
|---|
 | 380 | barette[0]=laplushaute;
 | 
|---|
 | 381 | phd0[i]=0.;
 | 
|---|
 | 382 | {float peri=DonnePeriod();
 | 
|---|
 | 383 | if (peri>0.)phd0[i]=360./peri*(maintenant-peri*(int)(maintenant/peri));
 | 
|---|
 | 384 | }
 | 
|---|
 | 385 | // bloc recherche de l'axe ->identification des etoiles
 | 
|---|
 | 386 | {float difftps=0.;
 | 
|---|
 | 387 | 
 | 
|---|
 | 388 | if(DonnePeriod()>0. && (maintenant - pluvieux)>DonnePeriod())
 | 
|---|
 | 389 | {
 | 
|---|
 | 390 | nlistevue=0;
 | 
|---|
 | 391 | for(i=0;i<nmemechant-1;i++)
 | 
|---|
 | 392 | {
 | 
|---|
 | 393 |  if(sfluxvu[i]==0. |maintenant-instant[i]>Period) break;
 | 
|---|
 | 394 | difftps=(instant[i]-instant[i+1])*DPI/Period;
 | 
|---|
 | 395 | nlistevue++;
 | 
|---|
 | 396 | deltap[i]=difftps;
 | 
|---|
 | 397 | rapflx[i]=sfluxvu[i+1]/sfluxvu[i];
 | 
|---|
 | 398 | }
 | 
|---|
 | 399 | //printf("%d etoiles detectees par tour\n",nlistevue);
 | 
|---|
 | 400 | if(fenetre(fenetre_Find_Period))
 | 
|---|
 | 401 | {selectgra(fenetre_Find_Period);ecritD(fenetre_Find_Period,Find_net," %d",nlistevue);}
 | 
|---|
 | 402 | numaccro=1;
 | 
|---|
 | 403 | if(numaccro==0) chercheaccro(flcatmin);
 | 
|---|
 | 404 | 
 | 
|---|
 | 405 | 
 | 
|---|
 | 406 | 
 | 
|---|
 | 407 | 
 | 
|---|
 | 408 | }}
 | 
|---|
 | 409 | // fin du bloc recherche de l'axe ->identification des etoiles
 | 
|---|
 | 410 | 
 | 
|---|
 | 411 | }
 | 
|---|
 | 412 | }
 | 
|---|
 | 413 | }
 | 
|---|
 | 414 | void chercheaccro(int seuil)
 | 
|---|
 | 415 | {
 | 
|---|
 | 416 | /*
 | 
|---|
 | 417 | #define nstpturn 100
 | 
|---|
 | 418 | struct sstgraph {
 | 
|---|
 | 419 |   int netdet; // nombre d'etoiles detectees
 | 
|---|
 | 420 |   float raax; // coordonnees equatoriales de l'axe de rotation du telescope
 | 
|---|
 | 421 |   float decax;
 | 
|---|
 | 422 |   long numcat[nstpturn]; //numero de l'etoile dans le fichier de depart
 | 
|---|
 | 423 |   float phase[nstpturn]; //phase de l'etoile (angle/Nord - Est=+90¡ - ds plan perp axe rot ballon)
 | 
|---|
 | 424 |   float cosinus[nstpturn]; // de l'angle entre la direction de l'etoile et l'axe de rotation du ballon
 | 
|---|
 | 425 |   float fluxcat[nstpturn]; //flux de l'etoile en unites arbitraires
 | 
|---|
 | 426 |   int   icl[nstpturn]; //ordre de l'etoile pour un classement par phases croissantes
 | 
|---|
 | 427 | };
 | 
|---|
 | 428 | */
 | 
|---|
 | 429 | int i,j;int nstartour;float temps[nstpturn],fluxion[nstpturn];
 | 
|---|
 | 430 | nstartour=0;
 | 
|---|
 | 431 | for(i=0;i<nposaxesimu;i++)
 | 
|---|
 | 432 |         {
 | 
|---|
 | 433 |         for(j=0;j<listord[i].netdet-1;j++)
 | 
|---|
 | 434 |                 {
 | 
|---|
 | 435 |                 deltapcat[j]=listord[i].phase[j+1]-listord[i].phase[j];
 | 
|---|
 | 436 |                 rapflxcat[j]=listord[i].fluxcat[j+1]/listord[i].fluxcat[j];
 | 
|---|
 | 437 |                 }
 | 
|---|
 | 438 |         }
 | 
|---|
 | 439 | 
 | 
|---|
 | 440 | 
 | 
|---|
 | 441 | }
 | 
|---|
 | 442 | void trace_point(int fen)
 | 
|---|
 | 443 | {
 | 
|---|
 | 444 | if(fenetre(fen)) symbole(fen, separtps, sflxv, 2, rond, 0, bleu);
 | 
|---|
 | 445 | }
 | 
|---|
 | 446 | void tracephase(void)
 | 
|---|
 | 447 | {
 | 
|---|
 | 448 | float tempsplie,tempsmoy;float peri;float ecartps,ecarz;
 | 
|---|
 | 449 | peri=DonnePeriod();
 | 
|---|
 | 450 | if (peri>0.)
 | 
|---|
 | 451 | {
 | 
|---|
 | 452 | tempsplie=360./peri*(maintenant-peri*(int)(maintenant/peri));
 | 
|---|
 | 453 | if(!flagvuefiltree)
 | 
|---|
 | 454 | {
 | 
|---|
 | 455 | if(fenetre(fenetre_Phase_SST))
 | 
|---|
 | 456 | {symbole(fenetre_Phase_SST,tempsplie,separtps-2.*peri, 10, carre, 0, bleu);
 | 
|---|
 | 457 | symbole(fenetre_Phase_SST,tempsplie,.005*(separenz), 10, croix, 0, rouge);}
 | 
|---|
 | 458 | }
 | 
|---|
 | 459 | 
 | 
|---|
 | 460 | {
 | 
|---|
 | 461 | if(ncoups==0)memtemps=((int)(tempsplie)/pasenphase)*pasenphase;
 | 
|---|
 | 462 |  if(tempsplie-memtemps<pasenphase && tempsplie>=memtemps)
 | 
|---|
 | 463 |  {
 | 
|---|
 | 464 |   ncoups++;
 | 
|---|
 | 465 |   somtps+=tempsplie;
 | 
|---|
 | 466 |   somecartps+=separtps-2.*peri;
 | 
|---|
 | 467 |   somecarz+=(separenz)*.005;
 | 
|---|
 | 468 |  } else
 | 
|---|
 | 469 |  {
 | 
|---|
 | 470 |   if(ncoups>0)
 | 
|---|
 | 471 |   {
 | 
|---|
 | 472 |    tempsmoy=somtps/(float)(ncoups);
 | 
|---|
 | 473 | //   printf("temps,ecart : %f %f\n",tempsmoy,somecartps/ncoups);
 | 
|---|
 | 474 |    ecartps =somecartps/(float)(ncoups);
 | 
|---|
 | 475 |    ecarz = somecarz/(float)(ncoups);
 | 
|---|
 | 476 |    charge_calc_phase(tempsmoy,ecartps,ecarz);
 | 
|---|
 | 477 | if(fenetre(fenetre_Phase_SST) && flagvuefiltree)
 | 
|---|
 | 478 | {   symbole(fenetre_Phase_SST,tempsmoy,ecartps, 10, carre, 0, bleu);
 | 
|---|
 | 479 |    symbole(fenetre_Phase_SST,tempsmoy,ecarz, 10, croix, 0, rouge);
 | 
|---|
 | 480 | }
 | 
|---|
 | 481 |    ncoups=0;
 | 
|---|
 | 482 |    somtps=0;
 | 
|---|
 | 483 |    somecartps=0;
 | 
|---|
 | 484 |    somecarz=0;
 | 
|---|
 | 485 |    memtemps=((int)(tempsplie)/pasenphase)*pasenphase;
 | 
|---|
 | 486 |   {
 | 
|---|
 | 487 |   ncoups++;
 | 
|---|
 | 488 |   somtps+=tempsplie;
 | 
|---|
 | 489 |   somecartps+=separtps-2.*peri;
 | 
|---|
 | 490 |   somecarz+=(separenz)*.005;
 | 
|---|
 | 491 |  }
 | 
|---|
 | 492 |  }
 | 
|---|
 | 493 |  }
 | 
|---|
 | 494 | 
 | 
|---|
 | 495 | }
 | 
|---|
 | 496 | }}
 | 
|---|
 | 497 | float DonnePeriod(void)
 | 
|---|
 | 498 | {
 | 
|---|
 | 499 | if(tauxper>.4){
 | 
|---|
 | 500 | return Period;}
 | 
|---|
 | 501 | else return -1.;
 | 
|---|
 | 502 | }
 | 
|---|
 | 503 | int CpFl(void)
 | 
|---|
 | 504 | {
 | 
|---|
 | 505 | return (int)(CoupFlux);
 | 
|---|
 | 506 | }
 | 
|---|
 | 507 | void raz_fen_phase()
 | 
|---|
 | 508 | {
 | 
|---|
 | 509 | int i;
 | 
|---|
 | 510 | if (fenetre(fenetre_Phase_SST)){selectgra(fenetre_Phase_SST);
 | 
|---|
 | 511 | efface(fenetre_Phase_SST);}
 | 
|---|
 | 512 | memtemps=-1.;ncoups=0;nptsfenphs=0;phaseret=-9999.;Sens=-9999;
 | 
|---|
 | 513 | CasesVides=ncasphase;for(i=0;i<ncasphase;i++) statcalcphase[i]=0;
 | 
|---|
 | 514 | 
 | 
|---|
 | 515 | }
 | 
|---|
 | 516 | void charge_calc_phase(float tempsmoy,float ecartps,float ecarz)
 | 
|---|
 | 517 | {
 | 
|---|
 | 518 | int caserne;
 | 
|---|
 | 519 | caserne=(tempsmoy+pasenphase*.5)/pasenphase;
 | 
|---|
 | 520 | if(caserne==ncasphase)caserne=0;
 | 
|---|
 | 521 | if(caserne < ncasphase && caserne >= 0)
 | 
|---|
 | 522 | {
 | 
|---|
 | 523 | if(statcalcphase[caserne]<5 | (fabs(ecarmoytps[caserne]-ecartps)<.02 &&
 | 
|---|
 | 524 | fabs(ecarmoyz[caserne]-ecarz)<3.))
 | 
|---|
 | 525 | {ecarmoytps[caserne]*=statcalcphase[caserne];
 | 
|---|
 | 526 | ecarmoyz[caserne]*=statcalcphase[caserne];
 | 
|---|
 | 527 | ecarmoytps[caserne]+=ecartps;
 | 
|---|
 | 528 | ecarmoyz[caserne]+=ecarz;
 | 
|---|
 | 529 | statcalcphase[caserne]++;
 | 
|---|
 | 530 | ecarmoytps[caserne]/=statcalcphase[caserne];
 | 
|---|
 | 531 | ecarmoyz[caserne]/=statcalcphase[caserne];
 | 
|---|
 | 532 | CasesVides=calc_phase();
 | 
|---|
 | 533 | }}}
 | 
|---|
 | 534 | void tabulesincos(void)
 | 
|---|
 | 535 | {
 | 
|---|
 | 536 | int i;float pasenrad;
 | 
|---|
 | 537 | pasenrad=pasenphase*.01745329;
 | 
|---|
 | 538 | for(i=0;i<ncasphase;i++)
 | 
|---|
 | 539 | {
 | 
|---|
 | 540 | sini[i]=sin(pasenrad*(i));
 | 
|---|
 | 541 | cosini[i]=cos(pasenrad*(i));
 | 
|---|
 | 542 | }
 | 
|---|
 | 543 | }
 | 
|---|
 | 544 | int calc_phase(void)
 | 
|---|
 | 545 | {
 | 
|---|
 | 546 | int i,vides;float cocoz,sisiz,cocotps,sisitps;
 | 
|---|
 | 547 | float phasez,phasetps;float sensrot;
 | 
|---|
 | 548 | static float phasemem;
 | 
|---|
 | 549 | vides =0;
 | 
|---|
 | 550 | for(i=0;i<ncasphase;i++)
 | 
|---|
 | 551 | {
 | 
|---|
 | 552 | if(statcalcphase[i]==0) vides++;
 | 
|---|
 | 553 | }
 | 
|---|
 | 554 | 
 | 
|---|
 | 555 | cocoz=0;
 | 
|---|
 | 556 | sisiz=0;
 | 
|---|
 | 557 | cocotps=0;
 | 
|---|
 | 558 | sisitps=0;
 | 
|---|
 | 559 | for(i=0;i<ncasphase;i++)
 | 
|---|
 | 560 | {
 | 
|---|
 | 561 | if(statcalcphase[i]>0)
 | 
|---|
 | 562 | {
 | 
|---|
 | 563 | cocoz+=cosini[i]*ecarmoyz[i];
 | 
|---|
 | 564 | sisiz+=sini[i]*ecarmoyz[i];
 | 
|---|
 | 565 | cocotps+=cosini[i]*ecarmoytps[i];
 | 
|---|
 | 566 | sisitps+=sini[i]*ecarmoytps[i];
 | 
|---|
 | 567 | }
 | 
|---|
 | 568 | }
 | 
|---|
 | 569 | phasez=-atan2(cocoz,sisiz);
 | 
|---|
 | 570 | phasetps=-atan2(cocotps,sisitps);
 | 
|---|
 | 571 | sensrot=phasez-phasetps;
 | 
|---|
 | 572 | if(sensrot>3.14)sensrot-=6.28;
 | 
|---|
 | 573 | if(sensrot<-3.14)sensrot+=6.28;
 | 
|---|
 | 574 | if(sensrot>0.) Sens =1;
 | 
|---|
 | 575 | if(sensrot<=0.) Sens =-1;
 | 
|---|
 | 576 | //arbitraire, ajuste sur la simulation
 | 
|---|
 | 577 | Phase=phasez*57.29577;
 | 
|---|
 | 578 | phaseret=-9999.;
 | 
|---|
 | 579 | if(CasesVides<3 && fabs(Phase-phasemem)<10.){ phaseret=Phase;}
 | 
|---|
 | 580 | if(CasesVides<4) phasemem=Phase;
 | 
|---|
 | 581 | //printf("phases : numdiodes %f, tpsdiodes %f sens %d\n",phasez,phasetps,Sens);
 | 
|---|
 | 582 | return vides;}
 | 
|---|
 | 583 | float DonnePhase(void)
 | 
|---|
 | 584 | {
 | 
|---|
 | 585 | return phaseret;
 | 
|---|
 | 586 | }
 | 
|---|
 | 587 | int DonneSens(void)
 | 
|---|
 | 588 | {
 | 
|---|
 | 589 | if(CasesVides<3){return Sens;}else {return -9999;}
 | 
|---|
 | 590 | } | 
|---|