| [3308] | 1 | /* lecture des fichiers de suivi:     cmv 21/12/93 */ | 
|---|
|  | 2 | #include "machdefs.h" | 
|---|
| [3615] | 3 | #include "sopnamsp.h"  // using SOPHYA namespace | 
|---|
| [3308] | 4 | #include <stdio.h> | 
|---|
|  | 5 | #include <stdlib.h> | 
|---|
|  | 6 | #include <string.h> | 
|---|
|  | 7 | #include <math.h> | 
|---|
|  | 8 | #include <signal.h> | 
|---|
|  | 9 |  | 
|---|
| [3615] | 10 | #include "sophyainit.h" | 
|---|
| [3308] | 11 | #include "fsvcache.h" | 
|---|
|  | 12 | #include "nbtri.h" | 
|---|
|  | 13 | #include "nbmath.h" | 
|---|
|  | 14 | #include "strutil.h" | 
|---|
|  | 15 | #include "fsvst.h" | 
|---|
|  | 16 |  | 
|---|
|  | 17 | // Ne pas changer l'ordre des 3 lignes suivantes!!! | 
|---|
|  | 18 | #define  FLAG_MAIN_NBSREAD | 
|---|
|  | 19 | #include "nbsread.h" | 
|---|
|  | 20 | #include "nbgene.h" | 
|---|
|  | 21 |  | 
|---|
|  | 22 | void INIT_NBSR(void); | 
|---|
|  | 23 | void OPENSUIV(int ic); | 
|---|
|  | 24 | void READST(int ic); | 
|---|
|  | 25 | void READET(int ic); | 
|---|
|  | 26 | void DATCLEAN(int ic); | 
|---|
|  | 27 | void DATSORT(int ic); | 
|---|
|  | 28 |  | 
|---|
|  | 29 | void SELSTAR(void); | 
|---|
|  | 30 | void GET_STAR_ID(void); | 
|---|
|  | 31 |  | 
|---|
|  | 32 | int  DECODESUIVINAME(char* str); | 
|---|
|  | 33 | void DECODE_GLOBINFO(GLOBINFO *p); | 
|---|
|  | 34 | void DECODE_STARINFO(STARINFO *p, int ic); | 
|---|
|  | 35 | void DECODE_TIMEINFO(TIMEINFO *p, int ic, int imes); | 
|---|
|  | 36 | void DECODE_MESURE  (MESURE   *p, int ic, int imes); | 
|---|
|  | 37 |  | 
|---|
|  | 38 | void DO_MALLOC(void); | 
|---|
|  | 39 | void DO_FREE(void); | 
|---|
|  | 40 |  | 
|---|
|  | 41 | GLOBINFO     glinf; | 
|---|
|  | 42 | STARINFO     star; | 
|---|
|  | 43 | TIMEINFO     timinf; | 
|---|
|  | 44 | MESURE       mes; | 
|---|
|  | 45 |  | 
|---|
|  | 46 | /* Pour catcher un CTRL-C ou des time limites */ | 
|---|
|  | 47 | static struct sigaction Nbsread_Action; | 
|---|
|  | 48 | void Nbsread_SigCatchInit(void); | 
|---|
|  | 49 | void Nbsread_SigCatch(int s); | 
|---|
|  | 50 |  | 
|---|
|  | 51 | void usage(int); | 
|---|
|  | 52 | void usage(int lp) { | 
|---|
|  | 53 | printf("nbsread\n"); | 
|---|
|  | 54 | printf("  nom du fichier des fichiers de suivi\n"); | 
|---|
|  | 55 | printf("  [-h] help detaille\n"); | 
|---|
|  | 56 | printf("  [-et et1,et2,etinc]\n"); | 
|---|
|  | 57 | printf("  [-prt niv]\n"); | 
|---|
|  | 58 | printf("  [-dbg et1,et2,ccd,niv]\n"); | 
|---|
|  | 59 | printf("  [-kill mes1 mes2 mes3 ...]\n"); | 
|---|
|  | 60 | printf("  [-mc ngenstar]\n"); | 
|---|
|  | 61 | printf("  [-u0 U0MinI,U0MaxI,U0SimI]\n"); | 
|---|
|  | 62 | printf("  [-t0 T0MinI,T0MaxI,T0SimI]\n"); | 
|---|
|  | 63 | printf("  [-tau TauMinI,TauMaxI,TauSimI]\n"); | 
|---|
|  | 64 | printf("  [-tf type(1ou2),UMinI,UMaxI,USimI,Usu0_Cut]\n"); | 
|---|
|  | 65 | printf("  [-bl Blending (1ou2)]\n"); | 
|---|
|  | 66 | printf("  [-seed seed1,seed2,seed3]\n"); | 
|---|
|  | 67 | if(lp<=0) exit(-1); | 
|---|
|  | 68 | printf("\n"); | 
|---|
|  | 69 | printf("et1,et2,etinc: on utilise les etoiles de et1 a et2 par pas de etinc\n"); | 
|---|
|  | 70 | printf("niv: niveau de print\n"); | 
|---|
|  | 71 | printf("et1,et2,ccd,niv: debug etoiles et1 a et2 ccd ccd (-1=tous) niveau niv\n"); | 
|---|
|  | 72 | printf("mes1 mes2 mes3...: mesure a ne pas considerer dans les cdl\n"); | 
|---|
|  | 73 | printf("ngenstar: nombre de generations montecarlo par etoile\n"); | 
|---|
|  | 74 | printf("U0MinI,U0MaxI,U0SimI: generation du parametre d impact (def=0,0,0)\n"); | 
|---|
|  | 75 | printf("   si U0MinI<U0MaxI on tire u0 plat entre U0MinI,U0MaxI\n"); | 
|---|
|  | 76 | printf("   si U0MinI>=U0MaxI u0 est fixe a U0SimI\n"); | 
|---|
|  | 77 | printf("TauMinI,TauMaxI,TauSimI: generation du parametre tau (def=0.01,365.)\n"); | 
|---|
|  | 78 | printf("   ... meme logique que u0 ...\n"); | 
|---|
|  | 79 | printf("T0MinI,T0MaxI,T0SimI: generation du temps du maximum (def=1,-1,-1)\n"); | 
|---|
|  | 80 | printf("   si T0MinI<T0MaxI on tire t0 plat entre T0MinI,T0MaxI\n"); | 
|---|
|  | 81 | printf("   si T0MinI>=T0MaxI ET T0SimI>0 t0 est fixe a T0SimI\n"); | 
|---|
|  | 82 | printf("                     ET T0SimI<0 t0 tout l intervalle du suivi (def)\n"); | 
|---|
|  | 83 | printf("type,UMinI,UMaxI,USimI,Usu0_Cut: pour tirage taille finie (def=0,0,0,0.001)\n"); | 
|---|
|  | 84 | printf("   type = 1 taille finie tirage plat en U = Rs(proj)/Re\n"); | 
|---|
|  | 85 | printf("          2 taille finie tirage plat en UC (U = UC*Rs)\n"); | 
|---|
|  | 86 | printf("   si UMinI>=UMaxI U est fixe a U0SimI\n"); | 
|---|
|  | 87 | printf("   si UMinI<UMaxI on tire U plat entre UMinI,UMaxI si type=1\n"); | 
|---|
|  | 88 | printf("                                 entre UMinI*Rs,UMaxI*Rs si type=2\n"); | 
|---|
|  | 89 | printf("Blending = 1 sur l'etoile la + brillante du couple\n"); | 
|---|
|  | 90 | printf("           2 sur l'etoile la - brillante du couple\n"); | 
|---|
|  | 91 | printf("Il y a possibilite de definir ses propres fct de tirage (cf nbgene.c)\n"); | 
|---|
|  | 92 | printf("seed1,seed2,seed3: initialisation des aleatoires (def=36117,51106,21478)\n"); | 
|---|
|  | 93 | exit(-1); | 
|---|
|  | 94 | } | 
|---|
|  | 95 |  | 
|---|
|  | 96 | /*==========================================================================*/ | 
|---|
|  | 97 | int main (int narg, char *arg[]) | 
|---|
|  | 98 | { | 
|---|
|  | 99 | int_4 i,ic,iet1,iet2,iet0,ietmax,ietinc=1; | 
|---|
|  | 100 | char str[NBSREAD_LSTR]; | 
|---|
|  | 101 |  | 
|---|
|  | 102 | printf("=====> "); | 
|---|
|  | 103 | for(i=0;i<narg;i++) printf("%s ",arg[i]); | 
|---|
|  | 104 | printf("\n"); | 
|---|
|  | 105 |  | 
|---|
|  | 106 | /* printf("main: narg=%d %s\n",narg,arg[0]); */ | 
|---|
|  | 107 | if (narg < 2) usage(0); | 
|---|
|  | 108 | if( !strcmp(arg[1],"-h") != 0 ) usage(1); | 
|---|
|  | 109 |  | 
|---|
|  | 110 | /*------------------------------------------*/ | 
|---|
| [3615] | 111 | /*-------- Initialisation Aleatoire --------*/ | 
|---|
|  | 112 | /*------------------------------------------*/ | 
|---|
|  | 113 | SophyaInit(); | 
|---|
|  | 114 | RandGen = new DR48RandGen; | 
|---|
|  | 115 | RandomGeneratorInterface::SetGlobalRandGenP(RandGen); | 
|---|
|  | 116 |  | 
|---|
|  | 117 |  | 
|---|
|  | 118 | /*------------------------------------------*/ | 
|---|
| [3308] | 119 | /*-------- Initialisation variables --------*/ | 
|---|
|  | 120 | /*------------------------------------------*/ | 
|---|
|  | 121 |  | 
|---|
|  | 122 | INIT_NBSR(); | 
|---|
|  | 123 |  | 
|---|
|  | 124 | /*---------------------------------------*/ | 
|---|
|  | 125 | /*-------- Lecture des arguments --------*/ | 
|---|
|  | 126 | /*---------------------------------------*/ | 
|---|
|  | 127 |  | 
|---|
|  | 128 | i=2; | 
|---|
|  | 129 | while ( i < narg ) { | 
|---|
|  | 130 | /* printf("arg[%d] %s\n",i,arg[i]); */ | 
|---|
|  | 131 | if( !strcmp(arg[i],"-h") != 0 ) { | 
|---|
|  | 132 | usage(1); | 
|---|
|  | 133 | } else if( !strcmp(arg[i],"-et") != 0 ) { | 
|---|
|  | 134 | i++; | 
|---|
|  | 135 | sscanf(arg[i],"%d,%d,%d",&ietlim[0],&ietlim[1],&ietinc); | 
|---|
|  | 136 | if( ietinc<=0 ) ietinc = 1; | 
|---|
|  | 137 | printf("Etoiles traitees de %d a %d par pas de %d\n" | 
|---|
|  | 138 | ,ietlim[0],ietlim[1],ietinc); | 
|---|
|  | 139 | } else if( !strcmp(arg[i],"-prt") != 0 ) { | 
|---|
|  | 140 | i++; | 
|---|
|  | 141 | sscanf(arg[i],"%d",&ffprt); | 
|---|
|  | 142 | printf("Niveau de print %d\n",ffprt); | 
|---|
|  | 143 | } else if( !strcmp(arg[i],"-dbg") != 0 ) { | 
|---|
|  | 144 | i++; | 
|---|
|  | 145 | sscanf(arg[i],"%d,%d,%d,%d",&idebug[0],&idebug[1],&idebug[2],&idebug[3]); | 
|---|
|  | 146 | printf("Debug de l'et %d a l'et %d ccd %d niveau %d\n" | 
|---|
|  | 147 | ,idebug[0],idebug[1],idebug[2],idebug[3]); | 
|---|
|  | 148 | } else if( !strcmp(arg[i],"-mc") != 0 ) { | 
|---|
|  | 149 | i++; | 
|---|
|  | 150 | sscanf(arg[i],"%d",&mc.NGenStar); | 
|---|
|  | 151 | if(mc.NGenStar>0) mc.montecar=1; | 
|---|
|  | 152 | else {mc.montecar=mc.NGenStar; mc.NGenStar=0;} | 
|---|
|  | 153 | printf("MonteCarlo actif, %d generations par etoiles\n",mc.NGenStar); | 
|---|
|  | 154 | } else if( !strcmp(arg[i],"-u0") != 0 ) { | 
|---|
|  | 155 | i++; | 
|---|
|  | 156 | sscanf(arg[i],"%f,%f,%f",&mc.U0MinI,&mc.U0MaxI,&mc.U0SimI); | 
|---|
|  | 157 | printf("U0 generation de %g a %g ou %g\n" | 
|---|
|  | 158 | ,mc.U0MinI,mc.U0MaxI,mc.U0SimI); | 
|---|
|  | 159 | } else if( !strcmp(arg[i],"-tau") != 0 ) { | 
|---|
|  | 160 | i++; | 
|---|
|  | 161 | sscanf(arg[i],"%f,%f,%f",&mc.TauMinI,&mc.TauMaxI,&mc.TauSimI); | 
|---|
|  | 162 | printf("Tau generation de %g a %g ou %g\n" | 
|---|
|  | 163 | ,mc.TauMinI,mc.TauMaxI,mc.TauSimI); | 
|---|
|  | 164 | } else if( !strcmp(arg[i],"-t0") != 0 ) { | 
|---|
|  | 165 | i++; | 
|---|
|  | 166 | sscanf(arg[i],"%lf,%lf,%lf",&mc.T0MinI,&mc.T0MaxI,&mc.T0SimI); | 
|---|
|  | 167 | printf("T0 generation de %g a %g ou %g\n" | 
|---|
|  | 168 | ,mc.T0MinI,mc.T0MaxI,mc.T0SimI); | 
|---|
|  | 169 | } else if( !strcmp(arg[i],"-tf") != 0 ) { | 
|---|
|  | 170 | i++; | 
|---|
|  | 171 | sscanf(arg[i],"%d,%f,%f,%f,%f" | 
|---|
|  | 172 | ,&mc.Taille_Finie,&mc.UMinI,&mc.UMaxI,&mc.USimI,&mc.Usu0_Cut); | 
|---|
|  | 173 | printf("Taille finie %d generation de U %g a %g ou %g (prec=%g)\n" | 
|---|
|  | 174 | ,mc.Taille_Finie,mc.UMinI,mc.UMaxI,mc.USimI,mc.Usu0_Cut); | 
|---|
|  | 175 | } else if( !strcmp(arg[i],"-bl") != 0 ) { | 
|---|
|  | 176 | i++; | 
|---|
|  | 177 | sscanf(arg[i],"%d",&mc.Blending); | 
|---|
|  | 178 | printf("Blending %d\n",mc.Blending); | 
|---|
|  | 179 | } else if( !strcmp(arg[i],"-seed") != 0 ) { | 
|---|
|  | 180 | i++; | 
|---|
|  | 181 | sscanf(arg[i],"%d,%d,%d",&mc.iseed1,&mc.iseed2,&mc.iseed3); | 
|---|
|  | 182 | printf("Seed %d %d %d\n",mc.iseed1,mc.iseed2,mc.iseed3); | 
|---|
|  | 183 | } else if( !strcmp(arg[i],"-kill") != 0 ) { | 
|---|
|  | 184 | i++; | 
|---|
|  | 185 | while ( i<narg ) { | 
|---|
|  | 186 | if ( arg[i][0] != '-' ) { | 
|---|
|  | 187 | if ( nkillms<NKILLMSMX ) { | 
|---|
|  | 188 | sscanf(arg[i],"%d",&killms[nkillms]); | 
|---|
|  | 189 | nkillms++; | 
|---|
|  | 190 | i++; | 
|---|
|  | 191 | } else { | 
|---|
|  | 192 | printf("Trop de mesures a tuer! nkillms=%d / %d\n",nkillms,NKILLMSMX); | 
|---|
|  | 193 | exit(-1); | 
|---|
|  | 194 | } | 
|---|
|  | 195 | } else { i--; break;} | 
|---|
|  | 196 | } | 
|---|
|  | 197 | printf("Kill: %d mesures a tuer:",nkillms); | 
|---|
|  | 198 | if(nkillms>0) for(ic=0;ic<nkillms;ic++) printf(" %d",killms[ic]); | 
|---|
|  | 199 | printf("\n"); | 
|---|
|  | 200 | } else { | 
|---|
|  | 201 | printf("arguments: cas non prevu: %s\n",arg[i]); usage(0); | 
|---|
|  | 202 | } | 
|---|
|  | 203 | i++; | 
|---|
|  | 204 | } | 
|---|
|  | 205 | ietlim[0] = ( ietlim[0] <= 0 ) ? 1 : ietlim[0] ; | 
|---|
|  | 206 | ietlim[1] = ( ietlim[1] < ietlim[0] ) ? IGRAND : ietlim[1] ; | 
|---|
|  | 207 | printf("Etoiles traitees de %d a %d\n",ietlim[0],ietlim[1]); | 
|---|
|  | 208 |  | 
|---|
|  | 209 | /*----------------------------------------------------------------*/ | 
|---|
|  | 210 | /*----- Lecture nom de fichier data et selection des etoiles -----*/ | 
|---|
|  | 211 | /*----------------------------------------------------------------*/ | 
|---|
|  | 212 |  | 
|---|
|  | 213 | printf("Fichier de donnees suivi: %s\n",arg[1]); | 
|---|
|  | 214 | if( (dataccd = fopen(arg[1],"r") ) == 0 ) { | 
|---|
|  | 215 | printf("impossible d'ouvrir .dataccd\n"); exit(-1); | 
|---|
|  | 216 | } | 
|---|
|  | 217 |  | 
|---|
|  | 218 | GET_STAR_ID(); | 
|---|
|  | 219 |  | 
|---|
|  | 220 | /*-----------------------------------------*/ | 
|---|
|  | 221 | /*-------- Initialisation generale --------*/ | 
|---|
|  | 222 | /*-----------------------------------------*/ | 
|---|
|  | 223 |  | 
|---|
|  | 224 | /* initialisation des compteurs et des variables */ | 
|---|
|  | 225 |  | 
|---|
|  | 226 | numccd = nstdeb = netoiles = 0; | 
|---|
|  | 227 |  | 
|---|
|  | 228 | rewind(dataccd); | 
|---|
|  | 229 | if( fgets(str,NBSREAD_LSTR,dataccd) == 0 ) | 
|---|
|  | 230 | {printf("fichier dataccd illisible\n"); exit(-1);} | 
|---|
|  | 231 | nbccd = -1; | 
|---|
|  | 232 | sscanf(str,"%d",&nbccd); | 
|---|
|  | 233 | printf("on veut traiter %d ccd\n",nbccd); | 
|---|
|  | 234 | if( nbccd <= 0 ) exit(-1); | 
|---|
|  | 235 |  | 
|---|
|  | 236 | /* initialisation USER */ | 
|---|
|  | 237 |  | 
|---|
|  | 238 | Calibration_Absolue = 0; | 
|---|
|  | 239 | Calibration_Absolue_UParms = 0; | 
|---|
|  | 240 | UINIT(); | 
|---|
|  | 241 |  | 
|---|
|  | 242 | /* initialisation montecarlo */ | 
|---|
|  | 243 |  | 
|---|
|  | 244 | AMPLML( 1 ); | 
|---|
|  | 245 |  | 
|---|
|  | 246 | /* gestion des interrupts */ | 
|---|
|  | 247 |  | 
|---|
|  | 248 | Nbsread_SigCatchInit(); | 
|---|
|  | 249 |  | 
|---|
|  | 250 | /*-------------------------------------------------------*/ | 
|---|
|  | 251 | /*-------- Boucle sur les CCD (ou paves Plaques) --------*/ | 
|---|
|  | 252 | /*-------------------------------------------------------*/ | 
|---|
|  | 253 |  | 
|---|
|  | 254 | while ( fgets(str,NBSREAD_LSTR,dataccd) != 0 ) {   /* While... */ | 
|---|
|  | 255 |  | 
|---|
|  | 256 | strip(str,'B',' '); | 
|---|
|  | 257 | printf("%s\n",str); | 
|---|
|  | 258 |  | 
|---|
|  | 259 | if ( strstr(str,"@END") == str ) break; | 
|---|
|  | 260 |  | 
|---|
|  | 261 | if( strstr(str,"@CCD") == str) { | 
|---|
|  | 262 |  | 
|---|
|  | 263 | numccd++; | 
|---|
|  | 264 | sscanf(&str[4],"%d",&ccdnum); | 
|---|
|  | 265 | printf("Nouveau CCD: c'est le %d ieme, de numero %d\n",numccd,ccdnum); | 
|---|
|  | 266 | szMXBYTE=0; | 
|---|
|  | 267 | nbmsMX=0; | 
|---|
|  | 268 | for (ic=0;ic<NCOULMX;ic++) { | 
|---|
|  | 269 | nbfil[ic] = iet[ic] = net[ic] = nmes[ic]= 0; | 
|---|
|  | 270 | for (i=0;i<NBFILMX;i++) nbms[ic][i] = nms1fil[ic][i] = 0; | 
|---|
|  | 271 | } | 
|---|
|  | 272 |  | 
|---|
|  | 273 | } else if( strstr(str,"@FINCCD") == str) { | 
|---|
|  | 274 |  | 
|---|
|  | 275 | for(ic=0;ic<NCOULMX;ic++) { | 
|---|
|  | 276 | if( nbfil[ic] <= 0 ) continue; | 
|---|
|  | 277 | /* printf("Main_Debug: lunfil[%d][0]=%ld\n",ic,lunfil[ic][0]); */ | 
|---|
|  | 278 | sztmi[ic] = lunfil[ic][0]->Head.RecSize[3] / lunfil[ic][0]->Head.NItem; | 
|---|
|  | 279 | szmes[ic] = lunfil[ic][0]->Head.RecSize[4] / lunfil[ic][0]->Head.NItem; | 
|---|
|  | 280 | if( szMXBYTE < sztmi[ic] ) szMXBYTE = sztmi[ic]; | 
|---|
|  | 281 | if( szMXBYTE < szmes[ic] ) szMXBYTE = szmes[ic]; | 
|---|
|  | 282 | if(ffprt>0) printf("coul=%3d sztmi=%d szmes=%d\n",ic+1,sztmi[ic],szmes[ic]); | 
|---|
|  | 283 | } | 
|---|
|  | 284 | if(ffprt>0) printf("szMXBYTE=%d\n",szMXBYTE); | 
|---|
|  | 285 |  | 
|---|
|  | 286 | DO_MALLOC(); | 
|---|
|  | 287 | for (ic=0;ic<NCOULMX;ic++) OPENSUIV(ic); | 
|---|
|  | 288 | for (ic=0;ic<NCOULMX;ic++) DATCLEAN(ic); | 
|---|
|  | 289 | for (ic=0;ic<NCOULMX;ic++) DATSORT (ic); /* fill indexu */ | 
|---|
|  | 290 | TFIRST = Tfirst[0]; TLAST  = Tlast[0]; | 
|---|
|  | 291 | for (ic=1;ic<NCOULMX;ic++) { | 
|---|
|  | 292 | if( Tfirst[ic] != -1. && Tfirst[ic]<TFIRST ) TFIRST = Tfirst[ic]; | 
|---|
|  | 293 | if( Tlast[ic]  != -1. && Tlast[ic] >TLAST  ) TLAST  = Tlast[ic]; | 
|---|
|  | 294 | } | 
|---|
|  | 295 | if(ffprt>0) printf("Tfirst=%.2f (1=.2%f,2=%.2f)  Tlast=%.2f (1=%.2f,2=%.2f)\n" | 
|---|
|  | 296 | ,TFIRST,Tfirst[0],Tfirst[1],TLAST,Tlast[0],Tlast[1]); | 
|---|
|  | 297 | UINITCCD(); | 
|---|
|  | 298 | AMPLML( 2 ); | 
|---|
|  | 299 |  | 
|---|
|  | 300 | iet1 = ( ietlim[0] > 0 ) ? ietlim[0] : 1; | 
|---|
|  | 301 | iet2 = ( ietlim[1] > net[0] ) ? net[0] : ietlim[1]; | 
|---|
|  | 302 |  | 
|---|
|  | 303 | for(iet0=iet1;iet0<=iet2; iet0+=ietinc) {   /* boucle sur les etoiles */ | 
|---|
|  | 304 |  | 
|---|
|  | 305 | netoiles++; | 
|---|
|  | 306 |  | 
|---|
|  | 307 | for (ic=0;ic<NCOULMX;ic++) iet[ic]=iet0; | 
|---|
|  | 308 |  | 
|---|
|  | 309 | debug=0; | 
|---|
|  | 310 | if( iet0>=idebug[0] && iet0<=idebug[1] && ( ccdnum==idebug[2] || idebug[2]<0) ) { | 
|---|
|  | 311 | nstdeb++; | 
|---|
|  | 312 | debug=idebug[3]; | 
|---|
|  | 313 | } | 
|---|
|  | 314 | if(debug!=0) printf("\n\n************** DEBUG CCD %d ET %d LUES %d \n" | 
|---|
|  | 315 | ,ccdnum,iet0,netoiles); | 
|---|
|  | 316 |  | 
|---|
|  | 317 | /* lecture des starinfos */ | 
|---|
|  | 318 | for (ic=0;ic<NCOULMX;ic++) { | 
|---|
|  | 319 | if( ic == 0 ) {   /*fichier non-composite ou couleur 1*/ | 
|---|
|  | 320 | READST(ic); | 
|---|
|  | 321 | } else { | 
|---|
|  | 322 | iet[ic] = staru[0].XRef; | 
|---|
|  | 323 | READST(ic); | 
|---|
|  | 324 | } | 
|---|
|  | 325 | } | 
|---|
|  | 326 |  | 
|---|
|  | 327 | /* calibration absolue */ | 
|---|
|  | 328 | starcal.Mag_B= starcal.Mag_V= starcal.Mag_R | 
|---|
|  | 329 | = starcal.Mag_I= starcal.Rstar= -GRAND; | 
|---|
|  | 330 | starcal.Rtype = -1; | 
|---|
|  | 331 | if( iet[0]>0 && iet[1]>0 && Calibration_Absolue!=0 ) | 
|---|
|  | 332 | Calibration_Absolue(staru[0].FluxRef,staru[1].FluxRef, | 
|---|
|  | 333 | &starcal,Calibration_Absolue_UParms); | 
|---|
|  | 334 |  | 
|---|
|  | 335 | /* on saute l'etoile et la lecture des mesures ? */ | 
|---|
|  | 336 | if(starcut.Mag_B_cut>0 && | 
|---|
|  | 337 | (starcal.Mag_B<starcut.Mag_B_min || starcal.Mag_B>starcut.Mag_B_max) ) continue; | 
|---|
|  | 338 | if(starcut.Mag_V_cut>0 && | 
|---|
|  | 339 | (starcal.Mag_V<starcut.Mag_V_min || starcal.Mag_V>starcut.Mag_V_max) ) continue; | 
|---|
|  | 340 | if(starcut.Mag_R_cut>0 && | 
|---|
|  | 341 | (starcal.Mag_R<starcut.Mag_R_min || starcal.Mag_R>starcut.Mag_R_max) ) continue; | 
|---|
|  | 342 | if(starcut.Mag_I_cut>0 && | 
|---|
|  | 343 | (starcal.Mag_I<starcut.Mag_I_min || starcal.Mag_I>starcut.Mag_I_max) ) continue; | 
|---|
|  | 344 | if(starcut.Rstar_cut>0 && | 
|---|
|  | 345 | (starcal.Rstar<starcut.Rstar_min || starcal.Rstar>starcut.Rstar_max) ) continue; | 
|---|
|  | 346 |  | 
|---|
|  | 347 | if(starcut.Rtype_cut>0 && | 
|---|
|  | 348 | (starcal.Rtype<starcut.Rtype_min || starcal.Rtype>starcut.Rtype_max) ) continue; | 
|---|
|  | 349 |  | 
|---|
|  | 350 | if(starcut.Mag_BV_cut>0 && | 
|---|
|  | 351 | (starcal.Mag_B-starcal.Mag_V<starcut.Mag_BV_min || | 
|---|
|  | 352 | starcal.Mag_B-starcal.Mag_V>starcut.Mag_BV_max) ) continue; | 
|---|
|  | 353 | if(starcut.Mag_BR_cut>0 && | 
|---|
|  | 354 | (starcal.Mag_B-starcal.Mag_R<starcut.Mag_BR_min || | 
|---|
|  | 355 | starcal.Mag_B-starcal.Mag_R>starcut.Mag_BR_max) ) continue; | 
|---|
|  | 356 | if(starcut.Mag_VR_cut>0 && | 
|---|
|  | 357 | (starcal.Mag_V-starcal.Mag_R<starcut.Mag_VR_min || | 
|---|
|  | 358 | starcal.Mag_V-starcal.Mag_R>starcut.Mag_VR_max) ) continue; | 
|---|
|  | 359 | if(starcut.Mag_RI_cut>0 && | 
|---|
|  | 360 | (starcal.Mag_R-starcal.Mag_I<starcut.Mag_RI_min || | 
|---|
|  | 361 | starcal.Mag_R-starcal.Mag_I>starcut.Mag_RI_max) ) continue; | 
|---|
|  | 362 |  | 
|---|
|  | 363 | /* l'etoile a t-elle ete selectionnee ? */ | 
|---|
|  | 364 | SELSTAR(); | 
|---|
|  | 365 |  | 
|---|
|  | 366 | /* lecture des mesures */ | 
|---|
|  | 367 | for (ic=0;ic<NCOULMX;ic++) READET(ic); | 
|---|
|  | 368 |  | 
|---|
|  | 369 | ietmax = (mc.montecar>0 && mc.NGenStar>0) ? mc.NGenStar : 1; | 
|---|
|  | 370 | ietgen=0; | 
|---|
|  | 371 | while( ietgen < ietmax ) { | 
|---|
|  | 372 | if(mc.montecar>0) AMPLML( 3 ); | 
|---|
|  | 373 | UEVT(); | 
|---|
|  | 374 | ietgen++; | 
|---|
|  | 375 | } | 
|---|
|  | 376 |  | 
|---|
|  | 377 | }      /* fin de boucle sur les etoiles */ | 
|---|
|  | 378 |  | 
|---|
|  | 379 | UENDCCD(); | 
|---|
|  | 380 |  | 
|---|
|  | 381 | printf("on ferme les fichiers de suivi du ccd %d\n",ccdnum); | 
|---|
|  | 382 | DO_FREE(); | 
|---|
|  | 383 | for(ic=0;ic<NCOULMX;ic++) { | 
|---|
|  | 384 | printf("Couleur: %d\n",ic+1); | 
|---|
|  | 385 | for(i=0;i<nbfil[ic];i++) { | 
|---|
|  | 386 | printf("fichier %d\n",i); | 
|---|
|  | 387 | SuiviClose(lunfil[ic][i]); | 
|---|
|  | 388 | } } | 
|---|
|  | 389 |  | 
|---|
|  | 390 | } else if( strstr(str,"@COUL") == str) { | 
|---|
|  | 391 |  | 
|---|
|  | 392 | sscanf(&str[5],"%d",&ic); | 
|---|
|  | 393 | printf("Couleur: %d\n",ic); | 
|---|
|  | 394 | ic--; | 
|---|
|  | 395 |  | 
|---|
|  | 396 | } else { | 
|---|
|  | 397 | str[strlen(str)-1] = ' ';   /*  lu par fgets() */ | 
|---|
|  | 398 | strip(str,'B',' '); | 
|---|
|  | 399 | DECODESUIVINAME(str); | 
|---|
|  | 400 | printf("%s\n",str); | 
|---|
|  | 401 | strcpy(lunnam[ic][nbfil[ic]], str); | 
|---|
|  | 402 | printf("lunnam[%d][nbfil[%d]] == lunnam[%d][%d] = %s\n" | 
|---|
|  | 403 | ,ic,ic,ic,nbfil[ic],lunnam[ic][nbfil[ic]]); | 
|---|
|  | 404 | if( (lunfil[ic][nbfil[ic]] = SuiviOpen(str,OpenType)) == 0 ) { | 
|---|
|  | 405 | printf("Impossible d'ouvrir le fichier %s\n",str); | 
|---|
|  | 406 | exit(-1); | 
|---|
|  | 407 | } | 
|---|
|  | 408 | /* lecture du nombre de mesures */ | 
|---|
|  | 409 | nbms[ic][nbfil[ic]] = SuiviGetNbMesures(lunfil[ic][nbfil[ic]]); | 
|---|
|  | 410 | if(ffprt>1) printf("Ouverture lunfil[%3d][%5d] = %d mes\n" | 
|---|
|  | 411 | ,ic,nbfil[ic],nbms[ic][nbfil[ic]]); | 
|---|
|  | 412 | if( nbms[ic][nbfil[ic]] > nbmsMX ) nbmsMX = nbms[ic][nbfil[ic]]; | 
|---|
|  | 413 | /* numero du 1er fichier de l'unite nbfil[ic]: va de 0->nmes */ | 
|---|
|  | 414 | nms1fil[ic][nbfil[ic]] = nmes[ic]; | 
|---|
|  | 415 | nmes[ic] += nbms[ic][nbfil[ic]]; | 
|---|
|  | 416 | nbfil[ic]++; | 
|---|
|  | 417 |  | 
|---|
|  | 418 | } | 
|---|
|  | 419 | }   /* Fin du While... */ | 
|---|
|  | 420 |  | 
|---|
|  | 421 | UEND(); | 
|---|
|  | 422 | AMPLML( 5 ); | 
|---|
|  | 423 | if( StId1 != 0 ) free(StId1); | 
|---|
|  | 424 | if( StId2 != 0 ) free(StId2); | 
|---|
|  | 425 | fclose(dataccd); | 
|---|
|  | 426 |  | 
|---|
|  | 427 | printf("Nombre total d'etoiles lues %d\n",netoiles); | 
|---|
| [3615] | 428 | delete RandGen; | 
|---|
| [3308] | 429 |  | 
|---|
| [3615] | 430 | return(0); | 
|---|
| [3308] | 431 | } | 
|---|
|  | 432 |  | 
|---|
|  | 433 | /*==========================================================================*/ | 
|---|
|  | 434 | void INIT_NBSR(void) | 
|---|
|  | 435 | { | 
|---|
|  | 436 | int i; | 
|---|
|  | 437 |  | 
|---|
|  | 438 | OpenType= SUOF_RO_MEM2; | 
|---|
|  | 439 | GRAND2_KILL = 5. * GRAND2; | 
|---|
|  | 440 |  | 
|---|
|  | 441 | ietlim[0]= -IGRAND; | 
|---|
|  | 442 | ietlim[1]= IGRAND; | 
|---|
|  | 443 | idebug[0]=idebug[1]=idebug[2]=idebug[3]=0; | 
|---|
|  | 444 | NStId = NSelStId = FgSelSt = 0; | 
|---|
|  | 445 | StId1 = StId2 = 0; | 
|---|
|  | 446 | nkillms = 0; for(i=0;i<NKILLMSMX;i++) killms[i]=0; | 
|---|
|  | 447 | ffprt=0; | 
|---|
|  | 448 |  | 
|---|
|  | 449 | starcut.Mag_B_cut  = 0;   starcut.Mag_B_min  = starcut.Mag_B_max = 0.; | 
|---|
|  | 450 | starcut.Mag_V_cut  = 0;   starcut.Mag_V_min  = starcut.Mag_V_max = 0.; | 
|---|
|  | 451 | starcut.Mag_R_cut  = 0;   starcut.Mag_R_min  = starcut.Mag_R_max = 0.; | 
|---|
|  | 452 | starcut.Mag_I_cut  = 0;   starcut.Mag_I_min  = starcut.Mag_I_max = 0.; | 
|---|
|  | 453 | starcut.Mag_BV_cut = 0;   starcut.Mag_BV_min = starcut.Mag_BV_max = 0.; | 
|---|
|  | 454 | starcut.Mag_BR_cut = 0;   starcut.Mag_BR_min = starcut.Mag_BR_max = 0.; | 
|---|
|  | 455 | starcut.Mag_VR_cut = 0;   starcut.Mag_VR_min = starcut.Mag_VR_max = 0.; | 
|---|
|  | 456 | starcut.Mag_RI_cut = 0;   starcut.Mag_RI_min = starcut.Mag_RI_max = 0.; | 
|---|
|  | 457 | starcut.Rstar_cut  = 0;   starcut.Rstar_min  = starcut.Rstar_max = 0.; | 
|---|
|  | 458 | starcut.Rtype_cut  = 0;   starcut.Rtype_min  = starcut.Rtype_max = 0; | 
|---|
|  | 459 |  | 
|---|
|  | 460 | mc.montecar=0; | 
|---|
|  | 461 | mc.Taille_Finie=0; | 
|---|
|  | 462 | mc.Blending=0; | 
|---|
|  | 463 | mc.NGenStar=1; | 
|---|
|  | 464 | mc.Usu0_Cut = 0.001; | 
|---|
|  | 465 | mc.U0SimI=0.; mc.U0MinI=0.; mc.U0MaxI=0.; | 
|---|
|  | 466 | mc.TireU0 = 0; | 
|---|
|  | 467 | mc.T0SimI= -1.; mc.T0MinI=1.; mc.T0MaxI= -1.; | 
|---|
|  | 468 | mc.TauSimI=0.; mc.TauMinI=0.01; mc.TauMaxI=365.; | 
|---|
|  | 469 | mc.TireTau = 0; | 
|---|
|  | 470 | mc.USimI=0.; mc.UMinI=0.; mc.UMaxI=0.; | 
|---|
|  | 471 | mc.TireU = 0; | 
|---|
|  | 472 | mc.Get_Par_Blending = 0; | 
|---|
|  | 473 | mc.coeff_Arec1[0] = mc.coeff_Arec1[1] = 0.; | 
|---|
|  | 474 | mc.coeff_Arec2[0] = mc.coeff_Arec2[1] = 0.; | 
|---|
|  | 475 | mc.starcal1.Rstar = mc.starcal2.Rstar = 0.; | 
|---|
|  | 476 | mc.iseed1 = 36117; | 
|---|
|  | 477 | mc.iseed2 = 51106; | 
|---|
|  | 478 | mc.iseed3 = 21478; | 
|---|
|  | 479 |  | 
|---|
|  | 480 | } | 
|---|
|  | 481 |  | 
|---|
|  | 482 | /*==========================================================================*/ | 
|---|
|  | 483 | void OPENSUIV(int ic) | 
|---|
|  | 484 | /* ic = couleur (0 a 1) */ | 
|---|
|  | 485 | { | 
|---|
|  | 486 | int_4 i,j,rc; | 
|---|
|  | 487 | int_4 l, i1, i2; | 
|---|
|  | 488 | int lp; | 
|---|
|  | 489 |  | 
|---|
|  | 490 | if(ffprt>0) printf("===> OPENSUIV couleur %3d\n",ic+1); | 
|---|
|  | 491 |  | 
|---|
|  | 492 | if( nbfil[ic] <= 0 ) return; | 
|---|
|  | 493 |  | 
|---|
|  | 494 | if(nmes[ic]>0 && ffprt>0) { | 
|---|
|  | 495 | printf("Coul %2d nmes %5d on lit %4d fichiers, nbmsMAX %5d\n" | 
|---|
|  | 496 | ,ic+1,nmes[ic],nbfil[ic],nbmsMX); | 
|---|
|  | 497 | if(ffprt>1) { | 
|---|
|  | 498 | printf("nbms:\n"); | 
|---|
|  | 499 | for(i=0;i<nbfil[ic];i++) {printf(" %6d",nbms[ic][i]); if(i%10==9) printf("\n");} | 
|---|
|  | 500 | if((nbfil[ic]-1)%10!=9) printf("\n"); | 
|---|
|  | 501 |  | 
|---|
|  | 502 | printf("nms1fil:\n"); | 
|---|
|  | 503 | for(i=0;i<nbfil[ic];i++) {printf(" %6d",nms1fil[ic][i]); if(i%10==9) printf("\n");} | 
|---|
|  | 504 | if((nbfil[ic]-1)%10!=9) printf("\n"); | 
|---|
|  | 505 | } } | 
|---|
|  | 506 |  | 
|---|
|  | 507 | for(i=0;i<nbfil[ic];i++) { | 
|---|
|  | 508 |  | 
|---|
|  | 509 | l = SuiviGetType(lunfil[ic][i]); | 
|---|
|  | 510 |  | 
|---|
|  | 511 | /* type de fichier de suivi */ | 
|---|
|  | 512 | if( i==0 && ic==0 ) { | 
|---|
|  | 513 | typsuivi=l; | 
|---|
|  | 514 | printf("Type du fichier de Suivi: %d\n",typsuivi); | 
|---|
|  | 515 | } else if ( typsuivi != l ) { | 
|---|
|  | 516 | printf("couleur %3d fichier de suivi %5d mauvais type %d %d\n" | 
|---|
|  | 517 | ,ic+1,i+1,l,typsuivi); | 
|---|
|  | 518 | exit(-1); | 
|---|
|  | 519 | } | 
|---|
|  | 520 |  | 
|---|
|  | 521 | /* lecture de global info */ | 
|---|
|  | 522 | if( ( rc=SuiviReadGlobInfo( lunfil[ic][i],(char *) (&glinf) ) ) != 0 ) { | 
|---|
|  | 523 | printf("Problemes lecture global info coul %3d fichier %d, rc=%d\n",ic+1,i+1,rc); | 
|---|
|  | 524 | exit(-1); | 
|---|
|  | 525 | } | 
|---|
|  | 526 | DECODE_GLOBINFO(&glinf); | 
|---|
|  | 527 |  | 
|---|
|  | 528 | //if( ffprt>3 || (ffprt>0 && i==0) ) PrtGlobInfo(&glinf,ffprt-3); | 
|---|
|  | 529 | if( ffprt>3 || (ffprt>0 && i==0) ) PrtGlobInfo(&glinf,99); | 
|---|
|  | 530 |  | 
|---|
|  | 531 | /* lecture du nombre d'etoiles */ | 
|---|
|  | 532 | l= SuiviGetNbStars(lunfil[ic][i]); | 
|---|
|  | 533 | if( i==0 ) { | 
|---|
|  | 534 | net[ic] = SuiviGetNbStars(lunfil[ic][i]); | 
|---|
|  | 535 | } else if( l !=net[ic] ) { | 
|---|
|  | 536 | printf("Probleme dans nombre d'etoiles coul %3d fichier %d: %d %d\n" | 
|---|
|  | 537 | ,ic+1,i+1,l,net[ic]); | 
|---|
|  | 538 | exit(-1); | 
|---|
|  | 539 | } | 
|---|
|  | 540 |  | 
|---|
|  | 541 | } | 
|---|
|  | 542 |  | 
|---|
|  | 543 | /* REMARQUE | 
|---|
|  | 544 | lecture de timeinfo: | 
|---|
|  | 545 | attention: on passe par un buffer intermediaire car quand on definit | 
|---|
|  | 546 | une structure, la longueur est un nombre entier de fois l'element | 
|---|
|  | 547 | le plus long de la structure (ici (double)) et donc on a, pour TIMEINFO | 
|---|
|  | 548 | sizeof(TIMEINFO)=416 au lieu de 412 effectivement ecrit | 
|---|
|  | 549 | Depuis la version avec gestion du Byte swap entre machine il n'est | 
|---|
|  | 550 | plus possible de lire directement une serie de timeinfo (meme pb pour mesure), | 
|---|
|  | 551 | il faut boucler sur toutes les photos! (debug 13/03/98 Reza) | 
|---|
|  | 552 | Voici le commentaire exact de Reza: | 
|---|
|  | 553 | "On ne peut plus lire un groupe de mesure ou de timeinfo s'il faut | 
|---|
|  | 554 | ByteSwaper et si Taille RecSuivi <> sizeof(structure) | 
|---|
|  | 555 | il faut lire les mesures/timeinfo un a un" | 
|---|
|  | 556 | Versions CVS ou il y avait encore la lecture par buffer: | 
|---|
|  | 557 | nbsread.h 1.14 , nbsread.c 1.30 | 
|---|
|  | 558 | */ | 
|---|
|  | 559 |  | 
|---|
|  | 560 | lp = ffprt-2; | 
|---|
|  | 561 |  | 
|---|
|  | 562 | if(nmes[ic]>0) { | 
|---|
|  | 563 | for(i=0;i<nbfil[ic];i++) { | 
|---|
|  | 564 | i2=nbms[ic][i]; | 
|---|
|  | 565 | i1=nms1fil[ic][i]; | 
|---|
|  | 566 | for(j=0;j<i2;j++) { | 
|---|
|  | 567 | if( (rc=SuiviReadTimeInfo(lunfil[ic][i], j+1, j+1, (char *)(&timinf))) != 0 ) { | 
|---|
|  | 568 | printf("Problemes lecture timinf info coul %3d fichier %5d, rc=%d\n" | 
|---|
|  | 569 | ,ic+1,i+1,rc); | 
|---|
|  | 570 | exit(-1); | 
|---|
|  | 571 | } | 
|---|
|  | 572 | l = j+i1; | 
|---|
|  | 573 | DECODE_TIMEINFO(&timinf,ic,l); | 
|---|
|  | 574 | indexu[ic][l] = 0; | 
|---|
|  | 575 | date  [ic][l] = (double) timeu[ic][l].TStart / JourSec; | 
|---|
|  | 576 | ampli [ic][l] = 1.; | 
|---|
|  | 577 | meslun[ic][l] = i; | 
|---|
|  | 578 | if( ffprt>1 ) { | 
|---|
|  | 579 | PrtTimeInfo (&timinf,l,ffprt-2); | 
|---|
|  | 580 | if( ffprt>5 ) PrtTimeInfoU (&timeu[ic][l],l,1); | 
|---|
|  | 581 | } | 
|---|
|  | 582 | } | 
|---|
|  | 583 | } | 
|---|
|  | 584 | } | 
|---|
|  | 585 |  | 
|---|
|  | 586 | /* some prints ? */ | 
|---|
|  | 587 | if(nmes[ic]>0 && ffprt>0) { | 
|---|
|  | 588 | printf("date:\n"); | 
|---|
|  | 589 | for(i=0;i<nmes[ic];i++) {printf(" %9.2f",date[ic][i]); if(i%10==9) printf("\n");} | 
|---|
|  | 590 | if((nmes[ic]-1)%10!=9) printf("\n"); | 
|---|
|  | 591 | if(lp>=3) { | 
|---|
|  | 592 | printf("meslun:\n"); | 
|---|
|  | 593 | for(i=0;i<nmes[ic];i++) {printf(" %9d",meslun[ic][i]); if(i%10==9) printf("\n");} | 
|---|
|  | 594 | if((nmes[ic]-1)%10!=9) printf("\n"); | 
|---|
|  | 595 | } } | 
|---|
|  | 596 |  | 
|---|
|  | 597 | } | 
|---|
|  | 598 |  | 
|---|
|  | 599 | /*==========================================================================*/ | 
|---|
|  | 600 | void READST(int ic) | 
|---|
|  | 601 | /* ic = couleur (0 a 1) */ | 
|---|
|  | 602 | { | 
|---|
|  | 603 | int_4 i,rc; | 
|---|
|  | 604 |  | 
|---|
|  | 605 | staru[ic].XRef=0; | 
|---|
|  | 606 |  | 
|---|
|  | 607 | if(nmes[ic]>0) | 
|---|
|  | 608 | for(i=0;i<nmes[ic];i++) mesu[ic][i].Flux=mesu[ic][i].Fond=0.; | 
|---|
|  | 609 |  | 
|---|
|  | 610 | if(debug>0) printf("READST: coul %3d et %d\n",ic+1,iet[ic]); | 
|---|
|  | 611 |  | 
|---|
|  | 612 | if( iet[ic]<=0 || iet[ic]>net[ic] ) return; | 
|---|
|  | 613 |  | 
|---|
|  | 614 | /*lecture de star info sur premier fichier */ | 
|---|
|  | 615 | if((rc=SuiviReadStarInfo(lunfil[ic][0],iet[ic],(char *)(&star))) != 0) { | 
|---|
|  | 616 | printf("Problemes lecture star info coul %3d etoile %d, rc=%d\n" | 
|---|
|  | 617 | ,ic+1,iet[ic],rc); | 
|---|
|  | 618 | exit(-1); | 
|---|
|  | 619 | } | 
|---|
|  | 620 |  | 
|---|
|  | 621 | DECODE_STARINFO(&star,ic); | 
|---|
|  | 622 |  | 
|---|
|  | 623 | if(debug>1) { | 
|---|
|  | 624 | printf("starinfo: coul %3d nbfil=%5d\n",ic+1,nbfil[ic]); | 
|---|
|  | 625 | PrtStarInfo(&staru[ic],ic,5); | 
|---|
|  | 626 | } | 
|---|
|  | 627 |  | 
|---|
|  | 628 | } | 
|---|
|  | 629 |  | 
|---|
|  | 630 | /*==========================================================================*/ | 
|---|
|  | 631 | void READET(int ic) | 
|---|
|  | 632 | /* ic = couleur (0 a 1) */ | 
|---|
|  | 633 | { | 
|---|
|  | 634 | int_4 i,j,rc; | 
|---|
|  | 635 | int_4 i1,i2; | 
|---|
|  | 636 |  | 
|---|
|  | 637 | if( iet[ic]<=0 || iet[ic]>net[ic] ) return; | 
|---|
|  | 638 | if( nmes[ic]<=0 ) return; | 
|---|
|  | 639 |  | 
|---|
|  | 640 | /* lecture des mesures: cf lecture expliquee pour timeinfo */ | 
|---|
|  | 641 | for(i=0;i<nbfil[ic];i++) { | 
|---|
|  | 642 | if(debug>1) printf("    Fichier %5d nbms %5d\n",i,nbms[ic][i]); | 
|---|
|  | 643 | i2=nbms[ic][i]; | 
|---|
|  | 644 | i1=nms1fil[ic][i]; | 
|---|
|  | 645 | for(j=0;j<i2;j++) { | 
|---|
|  | 646 | if((rc=SuiviReadMesures(lunfil[ic][i],iet[ic],j+1,j+1,(char *)(&mes))) != 0) { | 
|---|
|  | 647 | printf("Problemes lecture mes coul %3d etoile %d lim %5d %5d, rc=%d\n" | 
|---|
|  | 648 | ,ic+1,iet[ic],i1,i2,rc); | 
|---|
|  | 649 | exit(-1); | 
|---|
|  | 650 | } | 
|---|
|  | 651 | DECODE_MESURE(&mes,ic,j+i1); | 
|---|
|  | 652 | if(debug>5) PrtMesure(&mes,j+i1,5); | 
|---|
|  | 653 | } | 
|---|
|  | 654 | } | 
|---|
|  | 655 |  | 
|---|
|  | 656 |  | 
|---|
|  | 657 | if(debug>3) { | 
|---|
|  | 658 | if(debug>4) for(i=0;i<nmes[ic];i++) PrtMesureU(&mesu[ic][i],i,5); | 
|---|
|  | 659 | printf("\nmesu.Flux couleur=%d:\n",ic); | 
|---|
|  | 660 | for(i=0;i<nmesure[ic];i++) { | 
|---|
|  | 661 | j=indexu[ic][i]; | 
|---|
|  | 662 | printf(" %12.5g",mesu[ic][j].Flux); | 
|---|
|  | 663 | if(i%10==9 || i==nmesure[ic]-1) printf("\n"); | 
|---|
|  | 664 | } | 
|---|
|  | 665 | if(debug>4) { | 
|---|
|  | 666 | printf("mesu.ErrFlux couleur=%d:\n",ic); | 
|---|
|  | 667 | for(i=0;i<nmesure[ic];i++) { | 
|---|
|  | 668 | j=indexu[ic][i]; printf(" %12.5g",mesu[ic][j].ErrFlux); | 
|---|
|  | 669 | if(i%10==9 || i==nmesure[ic]-1) printf("\n"); | 
|---|
|  | 670 | } | 
|---|
|  | 671 | printf("mesu.FluxB couleur=%d:\n",ic); | 
|---|
|  | 672 | for(i=0;i<nmesure[ic];i++) { | 
|---|
|  | 673 | j=indexu[ic][i]; printf(" %12.5g",mesu[ic][j].FluxB); | 
|---|
|  | 674 | if(i%10==9 || i==nmesure[ic]-1) printf("\n"); | 
|---|
|  | 675 | } | 
|---|
|  | 676 | } | 
|---|
|  | 677 | } | 
|---|
|  | 678 |  | 
|---|
|  | 679 | } | 
|---|
|  | 680 |  | 
|---|
|  | 681 | /*==========================================================================*/ | 
|---|
|  | 682 | void DATCLEAN(int ic) | 
|---|
|  | 683 | /* ic = couleur (0 a 1) */ | 
|---|
|  | 684 | { | 
|---|
|  | 685 | int_4 i,j,k; | 
|---|
|  | 686 | double d1,d2; | 
|---|
|  | 687 |  | 
|---|
|  | 688 | if(ffprt>0) printf("=====> DATCLEAN coul=%3d ccd %5d\n",ic+1,ccdnum); | 
|---|
|  | 689 |  | 
|---|
|  | 690 | if(nmes[ic]<=0) return; | 
|---|
|  | 691 |  | 
|---|
|  | 692 | /* on tue selon les criteres utilisateur */ | 
|---|
|  | 693 | UDATCLEAN(ic+1); | 
|---|
|  | 694 | /* a ce niveau les dates=GRAND2_KILL ne doivent absolument plus servir */ | 
|---|
|  | 695 |  | 
|---|
|  | 696 | /* on tue les mesures 'n' pour chaque fichier de suivi */ | 
|---|
|  | 697 | if( nbfil[ic] > 0 ) { | 
|---|
|  | 698 | for(i=0;i<nbfil[ic];i++) { | 
|---|
|  | 699 | if( nbms[ic][i]<= 0 ) continue; | 
|---|
|  | 700 | for(j=0;j<nbms[ic][i];j++) { | 
|---|
|  | 701 | if( date[ic][nms1fil[ic][i]+j] >= GRAND2_KILL) continue; | 
|---|
|  | 702 | for(k=0;k<nkillms;k++) if ( j+1 == killms[k] ) { | 
|---|
|  | 703 | if(ffprt>1) | 
|---|
|  | 704 | printf(" Kill: mesure %6d (seq=%6d) du fichier suivi %4d\n" | 
|---|
|  | 705 | ,j,nms1fil[ic][i]+j,i); | 
|---|
|  | 706 | date[ic][nms1fil[ic][i]+j] = GRAND2; | 
|---|
|  | 707 | } | 
|---|
|  | 708 | } | 
|---|
|  | 709 | } | 
|---|
|  | 710 | } | 
|---|
|  | 711 |  | 
|---|
|  | 712 |  | 
|---|
|  | 713 | /* on tue les temps en double et on prend le dernier */ | 
|---|
|  | 714 | if( nmes[ic]>1 ) { | 
|---|
|  | 715 | for(i=0;i<nmes[ic]-1;i++) { | 
|---|
|  | 716 | d1=date[ic][i]; | 
|---|
|  | 717 | if( d1 >= GRAND2 ) continue; | 
|---|
|  | 718 | for(j=i+1;j<nmes[ic];j++) { | 
|---|
|  | 719 | d2=date[ic][j]; | 
|---|
|  | 720 | if( d2 >= GRAND2 ) continue; | 
|---|
|  | 721 | if( fabs(d1-d2) < (double) 0.00000001 ) { | 
|---|
|  | 722 | if(ffprt>1) | 
|---|
|  | 723 | printf(" Kill: %5d t=%f car dupliquee avec %5d t=%f soit %f\n" | 
|---|
|  | 724 | ,i,d1,j,d2,fabs(d1-d2)); | 
|---|
|  | 725 | date[ic][i] = GRAND2; | 
|---|
|  | 726 | break; | 
|---|
|  | 727 | } | 
|---|
|  | 728 | } | 
|---|
|  | 729 | } | 
|---|
|  | 730 | } | 
|---|
|  | 731 |  | 
|---|
|  | 732 | } | 
|---|
|  | 733 |  | 
|---|
|  | 734 | /*==========================================================================*/ | 
|---|
|  | 735 | void DATSORT(int ic) | 
|---|
|  | 736 | /* ic = couleur (0 a 1) */ | 
|---|
|  | 737 | { | 
|---|
|  | 738 | int_4 i,j; | 
|---|
|  | 739 |  | 
|---|
|  | 740 | if(ffprt>0) printf("DATSORT: coul %3d ccd %5d\n",ic+1,ccdnum); | 
|---|
|  | 741 |  | 
|---|
|  | 742 | nmesure[ic]=0; | 
|---|
|  | 743 | Tfirst[ic] = Tlast[ic] = -1.; | 
|---|
|  | 744 |  | 
|---|
|  | 745 | if(nmes[ic]<=0) return; | 
|---|
|  | 746 |  | 
|---|
|  | 747 | tri_double (date[ic],indexu[ic],nmes[ic]); | 
|---|
|  | 748 |  | 
|---|
|  | 749 | for(i=0;i<nmes[ic];i++) if(date[ic][i]<GRAND2) nmesure[ic]++; | 
|---|
|  | 750 |  | 
|---|
|  | 751 | if(nmesure[ic]>0) { | 
|---|
|  | 752 | Tfirst[ic]=date[ic][indexu[ic][0]]; | 
|---|
|  | 753 | Tlast[ic]=date[ic][indexu[ic][nmesure[ic]-1]]; | 
|---|
|  | 754 | } | 
|---|
|  | 755 |  | 
|---|
|  | 756 | if(ffprt>0) { | 
|---|
|  | 757 | printf("coul %3d nmesure %6d nmes %6d Tint %.3f %.3f\n" | 
|---|
|  | 758 | ,ic+1,nmesure[ic],nmes[ic],Tfirst[ic],Tlast[ic]); | 
|---|
|  | 759 | if(ffprt>1) { | 
|---|
|  | 760 | printf("date:\n"); | 
|---|
|  | 761 | for(i=0;i<nmes[ic];i++) | 
|---|
|  | 762 | { | 
|---|
|  | 763 | j=indexu[ic][i]; | 
|---|
|  | 764 | if(date[ic][j]<GRAND2) printf(" %9.2f",date[ic][j]); | 
|---|
|  | 765 | else printf(" %9.2f",-1.); | 
|---|
|  | 766 | if(i%10==9) printf("\n"); | 
|---|
|  | 767 | } | 
|---|
|  | 768 | if((nmes[ic]-1)%10!=9) printf("\n"); | 
|---|
|  | 769 |  | 
|---|
|  | 770 | printf("timeu.NumPhoto:\n"); | 
|---|
|  | 771 | for(i=0;i<nmes[ic];i++) { | 
|---|
|  | 772 | j=indexu[ic][i]; printf(" %9d",timeu[ic][j].NumPhoto); if(i%10==9) printf("\n");} | 
|---|
|  | 773 | if((nmes[ic]-1)%10!=9) printf("\n"); | 
|---|
|  | 774 |  | 
|---|
|  | 775 | if(ffprt>2) { | 
|---|
|  | 776 | printf("indexu:\n"); | 
|---|
|  | 777 | for(i=0;i<nmes[ic];i++) { | 
|---|
|  | 778 | printf(" %9d",indexu[ic][i]); if(i%10==9) printf("\n");} | 
|---|
|  | 779 | if((nmes[ic]-1)%10!=9) printf("\n"); | 
|---|
|  | 780 | } } } | 
|---|
|  | 781 |  | 
|---|
|  | 782 | } | 
|---|
|  | 783 |  | 
|---|
|  | 784 | /*==========================================================================*/ | 
|---|
|  | 785 | int DECODESUIVINAME(char* str) | 
|---|
|  | 786 | /* | 
|---|
|  | 787 | Pour decoder les noms des variables d'environnement dans une chaine de characteres | 
|---|
|  | 788 | - La chaine "str" est mofifiee (et doit donc etre modifiable) | 
|---|
|  | 789 | - Variable d'environnement = /home/.../toto/ ou /home/.../toto (avec ou sans / final) | 
|---|
|  | 790 | - La chaine "str" peut etre: | 
|---|
|  | 791 | $AAA ${AAA} $(AAA) $AAA/blabla ${AAA}/blabla $(AAA)/blabla /.../$AAA/... etc... | 
|---|
|  | 792 | Le cas ${AAA}blabla $(AAA)blabla n'est pas traite (/ impose en fin de nom de variable) | 
|---|
|  | 793 | - Retourne: -1 si echec, 0 si pas de variable a decoder, sinon nombre de variables decodees | 
|---|
|  | 794 | */ | 
|---|
|  | 795 | { | 
|---|
|  | 796 | char *str1,*vnam,*cenv; | 
|---|
|  | 797 | int ls=0,lce,rc=0,i,ip,jp; | 
|---|
|  | 798 |  | 
|---|
|  | 799 | ls = strlen(str); | 
|---|
|  | 800 | /* Pas de $ ou chaine trop courte */ | 
|---|
|  | 801 | if(posc(str,'$')<0 || ls<1) return rc; | 
|---|
|  | 802 | str1 = (char *) malloc((NBSREAD_LSTR+5)*sizeof(char)); | 
|---|
|  | 803 | vnam = (char *) malloc(NBSREAD_LSTR*sizeof(char)); | 
|---|
|  | 804 |  | 
|---|
|  | 805 | i= ip = rc = 0; | 
|---|
|  | 806 | while( i<ls ) { | 
|---|
|  | 807 | if(str[i] == ' ') {               /* on vire les blancs */ | 
|---|
|  | 808 | i++; | 
|---|
|  | 809 | } else if(str[i] == '/') {        /* on vire les doubles "/" */ | 
|---|
|  | 810 | if(str1[ip]=='/') i++; else {str1[ip] = str[i]; ip++; i++;} | 
|---|
|  | 811 | } else if(str[i] != '$') {        /* pas de variable d'environnement */ | 
|---|
|  | 812 | str1[ip] = str[i]; ip++; i++; | 
|---|
|  | 813 | } else {                          /* variable d'environnement */ | 
|---|
|  | 814 | jp = 0; | 
|---|
|  | 815 | while( i<ls ) { | 
|---|
|  | 816 | if(str[i]=='/') {i++; break;} | 
|---|
|  | 817 | else if(str[i]=='$'||str[i]=='{'||str[i]=='}'||str[i]=='('||str[i]==')')  i++; | 
|---|
|  | 818 | else {vnam[jp]=str[i]; jp++; i++;} | 
|---|
|  | 819 | } | 
|---|
|  | 820 | vnam[jp] = '\0'; | 
|---|
|  | 821 | if( (cenv=getenv(vnam)) == NULL ) | 
|---|
|  | 822 | {printf("variable inconnue=%s.\n",vnam); free(str1); free(vnam); return -1;} | 
|---|
|  | 823 | lce = strlen(cenv); | 
|---|
|  | 824 | rc++; | 
|---|
|  | 825 | if(lce>0) { | 
|---|
|  | 826 | jp = 0; | 
|---|
|  | 827 | while( jp<lce ) { | 
|---|
|  | 828 | /* on evite TOTO=/home/toto/ et blabla/$TOTO -> blabla//home/toto */ | 
|---|
|  | 829 | if(ip>0) if(jp==0 && cenv[jp]=='/' && str1[ip-1]=='/') {jp++; continue;} | 
|---|
|  | 830 | str1[ip] = cenv[jp]; ip++; jp++; | 
|---|
|  | 831 | } | 
|---|
|  | 832 | /* on evite TOTO=/home/toto/ et $TOTO/blabla -> /home/toto//blabla */ | 
|---|
|  | 833 | if(cenv[lce-1]!='/') {str1[ip] = '/'; ip++;} | 
|---|
|  | 834 | } | 
|---|
|  | 835 | } | 
|---|
|  | 836 | } | 
|---|
|  | 837 | str1[ip] = '\0'; | 
|---|
|  | 838 | strcpy(str,str1); | 
|---|
|  | 839 |  | 
|---|
|  | 840 | free(str1); free(vnam); | 
|---|
|  | 841 | return rc; | 
|---|
|  | 842 | } | 
|---|
|  | 843 |  | 
|---|
|  | 844 | /*==========================================================================*/ | 
|---|
|  | 845 | void DECODE_GLOBINFO(GLOBINFO *p) | 
|---|
|  | 846 | { | 
|---|
|  | 847 | globu = *p; | 
|---|
|  | 848 | } | 
|---|
|  | 849 |  | 
|---|
|  | 850 | /*==========================================================================*/ | 
|---|
|  | 851 | void DECODE_TIMEINFO(TIMEINFO *p, int ic, int imes) | 
|---|
|  | 852 | /* ic = couleur (0 a 1), imes = mesure (0 a nmes-1) */ | 
|---|
|  | 853 | { | 
|---|
|  | 854 | DecodeTim( p , &timeu[ic][imes]); | 
|---|
|  | 855 | } | 
|---|
|  | 856 |  | 
|---|
|  | 857 | /*==========================================================================*/ | 
|---|
|  | 858 | void DECODE_STARINFO(STARINFO *p, int ic) | 
|---|
|  | 859 | /* ic = couleur (0 a 1) */ | 
|---|
|  | 860 | { | 
|---|
|  | 861 | staru[ic] = *p; | 
|---|
|  | 862 | } | 
|---|
|  | 863 |  | 
|---|
|  | 864 | /*==========================================================================*/ | 
|---|
|  | 865 | void DECODE_MESURE(MESURE *p, int ic, int imes) | 
|---|
|  | 866 | /* ic = couleur (0 a 1), imes = mesure (0 a nmes-1) */ | 
|---|
|  | 867 | { | 
|---|
|  | 868 | if(date[ic][imes]<GRAND2_KILL) { | 
|---|
|  | 869 | DecodeMes( p , &mesu[ic][imes] ); | 
|---|
|  | 870 | Calibre_F_E( &mesu[ic][imes], &timeu[ic][imes]); | 
|---|
|  | 871 | } else { | 
|---|
|  | 872 | Mes_a_zero(&mesu[ic][imes]); | 
|---|
|  | 873 | } | 
|---|
|  | 874 | } | 
|---|
|  | 875 |  | 
|---|
|  | 876 | /*==========================================================================*/ | 
|---|
|  | 877 | void DO_MALLOC(void) | 
|---|
|  | 878 | { | 
|---|
|  | 879 | int n,ic; | 
|---|
|  | 880 | size_t ll,sof, sofM, sofT; | 
|---|
|  | 881 |  | 
|---|
|  | 882 | if(ffprt>1) | 
|---|
|  | 883 | printf("DO_MALLOC: nbmsMX=%d  szMXBYTE=%d\n",nbmsMX,szMXBYTE); | 
|---|
|  | 884 |  | 
|---|
|  | 885 | for(ic=0;ic<NCOULMX;ic++) {          /* BOUCLE SUR LES COULEURS */ | 
|---|
|  | 886 |  | 
|---|
|  | 887 | n = (nmes[ic] > 0) ? nmes[ic] : 1; | 
|---|
|  | 888 |  | 
|---|
|  | 889 | sofT = sizeof(TIMEINFOU); | 
|---|
|  | 890 | ll= n * sofT; | 
|---|
|  | 891 | if(ffprt>0) | 
|---|
|  | 892 | printf("timeu: allocation de %5d unites de %d bytes soit %d\n" | 
|---|
|  | 893 | ,n,(int)sofT,(int)ll); | 
|---|
|  | 894 | if( ( timeu[ic] = (TIMEINFOU *) malloc(ll) ) == 0 ) { | 
|---|
|  | 895 | printf("impossible d'allouer *timeu par malloc coul %3d\n",ic+1); | 
|---|
|  | 896 | exit(-1); | 
|---|
|  | 897 | } | 
|---|
|  | 898 |  | 
|---|
|  | 899 | sofM = sizeof(MESUREU); | 
|---|
|  | 900 | ll= n * sofM; | 
|---|
|  | 901 | if(ffprt>0) | 
|---|
|  | 902 | printf("mesu: allocation de %5d unites de %d bytes soit %d\n" | 
|---|
|  | 903 | ,n,(int)sofM,(int)ll); | 
|---|
|  | 904 | if( (mesu[ic] = (MESUREU *) malloc(ll) ) == 0 ) { | 
|---|
|  | 905 | printf("impossible d'allouer *mesu par malloc coul %3d\n",ic+1); | 
|---|
|  | 906 | exit(-1); | 
|---|
|  | 907 | } | 
|---|
|  | 908 |  | 
|---|
|  | 909 | sof = sizeof(int_4); | 
|---|
|  | 910 | ll= n * sof; | 
|---|
|  | 911 | if(ffprt>0) | 
|---|
|  | 912 | printf("indexu: allocation de %5d unites de %d bytes soit %d\n" | 
|---|
|  | 913 | ,n,(int)sof,(int)ll); | 
|---|
|  | 914 | if( (indexu[ic] = (int_4 *) malloc(ll) ) == 0 ) { | 
|---|
|  | 915 | printf("impossible d'allouer *indexu par malloc coul %3d\n",ic+1); | 
|---|
|  | 916 | exit(-1); | 
|---|
|  | 917 | } | 
|---|
|  | 918 |  | 
|---|
|  | 919 | sof = sizeof(unsigned short); | 
|---|
|  | 920 | ll= n * sof; | 
|---|
|  | 921 | if(ffprt>0) | 
|---|
|  | 922 | printf("meslun: allocation de %5d unites de %d bytes soit %d\n" | 
|---|
|  | 923 | ,n,(int)sof,(int)ll); | 
|---|
|  | 924 | if( (meslun[ic] = (unsigned short *) malloc(ll) ) == 0 ) { | 
|---|
|  | 925 | printf("impossible d'allouer *meslun par malloc coul %3d\n",ic+1); | 
|---|
|  | 926 | exit(-1); | 
|---|
|  | 927 | } | 
|---|
|  | 928 |  | 
|---|
|  | 929 | sof = sizeof(double); | 
|---|
|  | 930 | ll= n * sof; | 
|---|
|  | 931 | if(ffprt>0) | 
|---|
|  | 932 | printf("date: allocation de %5d unites de %d bytes soit %d\n" | 
|---|
|  | 933 | ,n,(int)sof,(int)ll); | 
|---|
|  | 934 | if( (date[ic] = (double *) malloc(ll) ) == 0 ) { | 
|---|
|  | 935 | printf("impossible d'allouer *date par malloc coul %3d\n",ic+1); | 
|---|
|  | 936 | exit(-1); | 
|---|
|  | 937 | } | 
|---|
|  | 938 |  | 
|---|
|  | 939 | sof = sizeof(float); | 
|---|
|  | 940 | ll= n * sof; | 
|---|
|  | 941 | if(ffprt>0) | 
|---|
|  | 942 | printf("ampli: allocation de %5d unites de %d bytes soit %d\n" | 
|---|
|  | 943 | ,n,(int)sof,(int)ll); | 
|---|
|  | 944 | if( (ampli[ic] = (float *) malloc(ll) ) == 0 ) { | 
|---|
|  | 945 | printf("impossible d'allouer *ampli par malloc coul %3d\n",ic+1); | 
|---|
|  | 946 | exit(-1); | 
|---|
|  | 947 | } | 
|---|
|  | 948 |  | 
|---|
|  | 949 | }             /* BOUCLE SUR LES COULEURS */ | 
|---|
|  | 950 |  | 
|---|
|  | 951 | } | 
|---|
|  | 952 |  | 
|---|
|  | 953 | /*==========================================================================*/ | 
|---|
|  | 954 | void DO_FREE(void) | 
|---|
|  | 955 | { | 
|---|
|  | 956 | int ic; | 
|---|
|  | 957 | for(ic=0;ic<NCOULMX;ic++) { | 
|---|
|  | 958 | free(timeu[ic]); | 
|---|
|  | 959 | free(mesu[ic]); | 
|---|
|  | 960 | free(indexu[ic]); | 
|---|
|  | 961 | free(date[ic]); | 
|---|
|  | 962 | free(ampli[ic]); | 
|---|
|  | 963 | } | 
|---|
|  | 964 | } | 
|---|
|  | 965 |  | 
|---|
|  | 966 | /*==========================================================================*/ | 
|---|
|  | 967 | int read_timeinfo(int ic,int imes,TIMEINFO *tim) | 
|---|
|  | 968 | /* | 
|---|
|  | 969 | Lecture de timeinfo pour la couleur ic (0->1), mesure imes (0->nmes[ic]-1) | 
|---|
|  | 970 | return 0 si OK, <0 si problemes | 
|---|
|  | 971 | */ | 
|---|
|  | 972 | { | 
|---|
|  | 973 | int rc,ifil,ime; | 
|---|
|  | 974 |  | 
|---|
|  | 975 | if ( imes<0 || imes>=nmes[ic] ) return(-1); | 
|---|
|  | 976 | ifil = meslun[ic][imes]; | 
|---|
|  | 977 | if ( ifil<0 || ifil>=nbfil[ic] ) return(-2); | 
|---|
|  | 978 | ime = imes-nms1fil[ic][ifil]; | 
|---|
|  | 979 | if ( ime<0 || ime>=nbms[ic][ifil] ) return(-3); | 
|---|
|  | 980 |  | 
|---|
|  | 981 | rc=SuiviReadTimeInfo(lunfil[ic][ifil], ime+1, ime+1, (char *)(tim)); | 
|---|
|  | 982 | if( rc != 0 ) { | 
|---|
|  | 983 | printf("read_timeinfo: problemes lecture timinf info coul %3d fichier %5d, rc=%d\n" | 
|---|
|  | 984 | ,ic+1,imes+1,rc); | 
|---|
|  | 985 | return(-4); | 
|---|
|  | 986 | } | 
|---|
|  | 987 |  | 
|---|
|  | 988 | /* | 
|---|
|  | 989 | printf("ic=%2d imes=%5d ifil=%4d ime=%5d NumPhoto=%d TStart=%d Expose=%d\n" | 
|---|
|  | 990 | ,ic,imes,ifil,ime,tim->NumPhoto,tim->TStart,tim->Expose); | 
|---|
|  | 991 | printf("          Calib=%f %f sig=%f %f %f\n" | 
|---|
|  | 992 | ,tim->Calib[0][0],tim->Calib[0][1],tim->SigX,tim->SigY,tim->Rho); | 
|---|
|  | 993 | */ | 
|---|
|  | 994 |  | 
|---|
|  | 995 | return(0); | 
|---|
|  | 996 | } | 
|---|
|  | 997 |  | 
|---|
|  | 998 | /*==========================================================================*/ | 
|---|
|  | 999 | void SELSTAR(void) | 
|---|
|  | 1000 | /* selection de l etoile courante ? */ | 
|---|
|  | 1001 | { | 
|---|
|  | 1002 | int i; | 
|---|
|  | 1003 | FgSelSt = 0; | 
|---|
|  | 1004 | if( NSelStId <= 0 || NStId <= 0 || StId1 == 0 || StId2 == 0 ) return; | 
|---|
|  | 1005 | for(i=0;i<NSelStId;i++) | 
|---|
|  | 1006 | if( StId1[i]<=iet[0] && iet[0]<=StId2[i] ) {FgSelSt = iet[0]; break;} | 
|---|
|  | 1007 | } | 
|---|
|  | 1008 |  | 
|---|
|  | 1009 | /*==========================================================================*/ | 
|---|
|  | 1010 | void GET_STAR_ID(void) | 
|---|
|  | 1011 | /* | 
|---|
|  | 1012 | Lecture du fichier dataccd pour identifier les cartes de selection des etoiles. | 
|---|
|  | 1013 | */ | 
|---|
|  | 1014 | { | 
|---|
|  | 1015 | char str[NBSREAD_LSTR]; | 
|---|
|  | 1016 | int nallmin = 50, l; | 
|---|
|  | 1017 |  | 
|---|
|  | 1018 | NStId = NSelStId = FgSelSt = 0; | 
|---|
|  | 1019 | if( StId1 != 0 ) { free(StId1); StId1 = 0;} | 
|---|
|  | 1020 | if( StId2 != 0 ) { free(StId2); StId2 = 0;} | 
|---|
|  | 1021 |  | 
|---|
|  | 1022 | StId1 = (int *)malloc(nallmin*sizeof(int)); | 
|---|
|  | 1023 | StId2 = (int *)malloc(nallmin*sizeof(int)); | 
|---|
|  | 1024 | if( StId1==0 || StId2==0 ) { | 
|---|
|  | 1025 | printf("GET_STAR_ID: Impossible d allouer StId1/2 pour la premiere fois %d\n" | 
|---|
|  | 1026 | ,nallmin); | 
|---|
|  | 1027 | return; | 
|---|
|  | 1028 | } else NStId = nallmin; | 
|---|
|  | 1029 |  | 
|---|
|  | 1030 | rewind(dataccd); | 
|---|
|  | 1031 | while ( fgets(str,NBSREAD_LSTR,dataccd) != 0 ) { | 
|---|
|  | 1032 | strip(str,'B',' '); | 
|---|
|  | 1033 | if ( strstr(str,"@SELET") != str ) continue; | 
|---|
|  | 1034 | if( NSelStId >= NStId ) { | 
|---|
|  | 1035 | l = NStId + nallmin; | 
|---|
|  | 1036 | StId1 = (int *)realloc(StId1,l*sizeof(int)); | 
|---|
|  | 1037 | StId2 = (int *)realloc(StId2,l*sizeof(int)); | 
|---|
|  | 1038 | if( StId1==0 || StId2==0 ) { | 
|---|
|  | 1039 | printf("GET_STAR_ID: Impossible de re-allouer %d pour StId1/2\n",l); | 
|---|
|  | 1040 | return; | 
|---|
|  | 1041 | } else { | 
|---|
|  | 1042 | NStId = l; | 
|---|
|  | 1043 | /* printf("GET_STAR_ID: reallocation de %d pour StId1/2 reussie\n",NStId); */ | 
|---|
|  | 1044 | } | 
|---|
|  | 1045 | } | 
|---|
|  | 1046 | StId1[NSelStId]=StId2[NSelStId]=-1; | 
|---|
|  | 1047 | sscanf(&str[6],"%d %d",&StId1[NSelStId],&StId2[NSelStId]); | 
|---|
|  | 1048 | if( StId2[NSelStId]<StId1[NSelStId] ) StId2[NSelStId]=StId1[NSelStId]; | 
|---|
|  | 1049 | NSelStId++; | 
|---|
|  | 1050 | } | 
|---|
|  | 1051 |  | 
|---|
|  | 1052 | if(ffprt>0) { | 
|---|
|  | 1053 | printf("GET_STAR_ID: %d selections d etoiles (lim=%d)\n",NSelStId,NStId); | 
|---|
|  | 1054 | if(ffprt>5) | 
|---|
|  | 1055 | for(l=0;l<NSelStId;l++) { | 
|---|
|  | 1056 | printf("    sel[%d]   et %d",l+1,StId1[l]); | 
|---|
|  | 1057 | if( StId1[l]!=StId2[l] ) printf("  a %d\n",StId2[l]); | 
|---|
|  | 1058 | else printf("\n"); | 
|---|
|  | 1059 | } | 
|---|
|  | 1060 | } | 
|---|
|  | 1061 |  | 
|---|
|  | 1062 | } | 
|---|
|  | 1063 |  | 
|---|
|  | 1064 | /*==========================================================================*/ | 
|---|
|  | 1065 | void Nbsread_SigCatchInit(void) | 
|---|
|  | 1066 | { | 
|---|
|  | 1067 | int rc; | 
|---|
|  | 1068 | #ifdef OSF1 | 
|---|
|  | 1069 | Nbsread_Action.sa_mask = 0; | 
|---|
|  | 1070 | Nbsread_Action.sa_flags = SA_RESTART; | 
|---|
|  | 1071 | #endif | 
|---|
|  | 1072 | #ifdef HPUX | 
|---|
|  | 1073 | memset( &(Nbsread_Action.sa_mask), 0, sizeof(sigset_t) ); | 
|---|
|  | 1074 | Nbsread_Action.sa_flags = 0; | 
|---|
|  | 1075 | #endif | 
|---|
|  | 1076 | #ifdef Linux | 
|---|
|  | 1077 | memset( &(Nbsread_Action.sa_mask), 0, sizeof(sigset_t) ); | 
|---|
|  | 1078 | Nbsread_Action.sa_flags = 0; | 
|---|
|  | 1079 | #endif | 
|---|
|  | 1080 | Nbsread_Action.sa_handler = Nbsread_SigCatch; | 
|---|
|  | 1081 |  | 
|---|
|  | 1082 | if( (rc=sigaction(SIGINT, &Nbsread_Action, NULL)) != 0 ) | 
|---|
|  | 1083 | printf("Nbsread_SigCatchInit_Error: signal SIGINT=%d rc=%d\n",SIGINT,rc); | 
|---|
|  | 1084 | if( (rc=sigaction(SIGUSR1, &Nbsread_Action, NULL)) != 0 ) | 
|---|
|  | 1085 | printf("Nbsread_SigCatchInit_Error: signal SIGUSR1=%d rc=%d\n",SIGUSR1,rc); | 
|---|
|  | 1086 | if( (rc=sigaction(SIGUSR2, &Nbsread_Action, NULL)) != 0 ) | 
|---|
|  | 1087 | printf("Nbsread_SigCatchInit_Error: signal SIGUSR2=%d rc=%d\n",SIGUSR2,rc); | 
|---|
|  | 1088 | } | 
|---|
|  | 1089 |  | 
|---|
|  | 1090 | /*==========================================================================*/ | 
|---|
|  | 1091 | void Nbsread_SigCatch(int s) | 
|---|
|  | 1092 | { | 
|---|
|  | 1093 | switch(s) { | 
|---|
|  | 1094 | case SIGINT : | 
|---|
|  | 1095 | printf("\n\nNbsread_SigCatch: signal SIGINT=%d catched\n\n",s); | 
|---|
|  | 1096 | break; | 
|---|
|  | 1097 | case SIGUSR1 : | 
|---|
|  | 1098 | printf("n\nNbsread_SigCatch: signal SIGUSR1=%d catched\n\n",s); | 
|---|
|  | 1099 | break; | 
|---|
|  | 1100 | case SIGUSR2 : | 
|---|
|  | 1101 | printf("n\nNbsread_SigCatch: signal SIGUSR2=%d catched\n\n",s); | 
|---|
|  | 1102 | break; | 
|---|
|  | 1103 | default : | 
|---|
|  | 1104 | printf("n\nNbsread_SigCatch: signal 1=%d catched et non traite\n\n",s); | 
|---|
|  | 1105 | break; | 
|---|
|  | 1106 | } | 
|---|
|  | 1107 | printf("UENDCCD is called\n"); | 
|---|
|  | 1108 | UENDCCD(); | 
|---|
|  | 1109 | printf("UEND is called\n"); | 
|---|
|  | 1110 | UEND(); | 
|---|
|  | 1111 | printf("exit is called\n"); | 
|---|
|  | 1112 | exit(-1); | 
|---|
|  | 1113 | } | 
|---|
|  | 1114 |  | 
|---|
|  | 1115 |  | 
|---|
|  | 1116 | /*************************************************************************/ | 
|---|
|  | 1117 | /*************************************************************************/ | 
|---|
|  | 1118 | /*******************  Commentaire nbsread et nbgene **********************/ | 
|---|
|  | 1119 | /*************************************************************************/ | 
|---|
|  | 1120 | /*************************************************************************/ | 
|---|
|  | 1121 | /* | 
|---|
|  | 1122 | ++ | 
|---|
|  | 1123 | Module        nbsread (C et C++) | 
|---|
|  | 1124 | Lib   libnbsread++.a et libnbsread.a | 
|---|
|  | 1125 | include       nbsread.h nbgene.h | 
|---|
|  | 1126 | | | 
|---|
|  | 1127 | *- nbsread* | 
|---|
|  | 1128 |  | 
|---|
|  | 1129 | C'est un programme qui permet de lire des fichiers de suivi | 
|---|
|  | 1130 | pour 2 couleurs associees. Il fournit des points d'entrees permettant | 
|---|
|  | 1131 | a l'utilisateur de piloter une analyse sans devoir s'occuper de | 
|---|
|  | 1132 | la machinerie relative a la lecture de fichiers de suivis. | 
|---|
|  | 1133 | |   nbsread  nbsread.dataccd.Exemple | 
|---|
|  | 1134 | Les noms des fichiers de suivi a lire doivent etre mis dans un fichier | 
|---|
|  | 1135 | dont un descriptif est donne dans le fichier | 
|---|
|  | 1136 | `AnaSuiv/nbsread.dataccd.Exemple'. La lecture de plusieurs fichiers | 
|---|
|  | 1137 | de suivi pour plusieurs CCD dans 2 couleurs est permise. | 
|---|
|  | 1138 | Ce fichier permet aussi de selectionner des etoiles par leur | 
|---|
|  | 1139 | numero ou un intervalle de numeros, le programme renvoie `FgSelSt' | 
|---|
|  | 1140 | non nulle si l'etoile a ete selectionnee par les datacards. | 
|---|
|  | 1141 | | | 
|---|
|  | 1142 | *- Structure des donnees* | 
|---|
|  | 1143 |  | 
|---|
|  | 1144 | Le programme lit les etoiles les unes apres les autres. | 
|---|
|  | 1145 | Pour chaque etoile il remplit diverses structure ou tableau | 
|---|
|  | 1146 | de structures permettant l'analyse de sa courbe de lumiere | 
|---|
|  | 1147 | (la description des structures se trouve dans `fsvst.h'): | 
|---|
|  | 1148 | |  EXTERN GLOBINFO globu : decodage de GLOBINFO | 
|---|
|  | 1149 | |  EXTERN STARINFO staru[NCOULMX] : decodage de STARINFO | 
|---|
|  | 1150 | |  EXTERN int_4 nmes[NCOULMX] : nombre de mesures pour le CCD courant | 
|---|
|  | 1151 | |                               et les couleurs 0 et 1 | 
|---|
|  | 1152 | |  EXTERN TIMEINFOU *timeu[NCOULMX] : tableau de structures TIMEINFOU | 
|---|
|  | 1153 | |  EXTERN MESUREU *mesu[NCOULMX] : tableau de structures MESUREU | 
|---|
|  | 1154 | |  EXTERN double *date[NCOULMX] : tableau des dates en jours | 
|---|
|  | 1155 | |  EXTERN float *ampli[NCOULMX] : tableau des amplifications montecarlo | 
|---|
|  | 1156 | |  EXTERN int_4 nmesure[NCOULMX] : nombre de mesure valides | 
|---|
|  | 1157 | |                                  pour le CCD courant | 
|---|
|  | 1158 | |  EXTERN int_4 *indexu[NCOULMX] : tableau des images valides | 
|---|
|  | 1159 | |                                  rangees chronologiquement | 
|---|
|  | 1160 | |  EXTERN STARCALU starcal : strucure de magnitude absolue | 
|---|
|  | 1161 | |  EXTERN STARCUTU starcut : structure de coupure sur les magnitudes | 
|---|
|  | 1162 | |                            et les couleurs (permet de ne pas lire | 
|---|
|  | 1163 | |                            certaines etoiles pour gagner du temps) | 
|---|
|  | 1164 |  | 
|---|
|  | 1165 | Les tableaux de structures ont `nmes[0] / nmes[1]' elements correspondant | 
|---|
|  | 1166 | au nombre total d'images pour les couleurs 0 et 1 dans les fichiers | 
|---|
|  | 1167 | de suivi d'un CCD. | 
|---|
|  | 1168 | | | 
|---|
|  | 1169 | *- Les points d'entree utilisateurs et structure de nbsread* | 
|---|
|  | 1170 |  | 
|---|
|  | 1171 | Ce sont les routine commencant par la lettre `U...()' | 
|---|
|  | 1172 | ayant un nom en majuscule. | 
|---|
|  | 1173 |  | 
|---|
|  | 1174 | |  Initialisation du job { | 
|---|
|  | 1175 | | | 
|---|
|  | 1176 | |    void UINIT(void);  <*********** USER | 
|---|
|  | 1177 | |    Initialisation montecarlo | 
|---|
|  | 1178 | | | 
|---|
|  | 1179 | |    Boucle sur les CCD a lire { | 
|---|
|  | 1180 | | | 
|---|
|  | 1181 | |      ---> Lecture de GLOBINFO et de TIMEINFOU pour un CCD | 
|---|
|  | 1182 | |      void UDATCLEAN(int coul);  <*********** USER | 
|---|
|  | 1183 | |      Classement des images valides par dates croissantes | 
|---|
|  | 1184 | |      void UINITCCD(void);  <*********** USER | 
|---|
|  | 1185 | |      Initialisation montecarlo pour le CCD courant | 
|---|
|  | 1186 | | | 
|---|
|  | 1187 | |      Boucle sur les etoiles a lire { | 
|---|
|  | 1188 | | | 
|---|
|  | 1189 | |        ---> lecture de MESUREU | 
|---|
|  | 1190 | |        Calcul des magnitudes absolues | 
|---|
|  | 1191 | |        Coupure sur les magnitudes absolues et la couleur des etoiles | 
|---|
|  | 1192 | |        Generation montecarlo pour chaque etoile | 
|---|
|  | 1193 | |          (eventuellement plusieurs generation sur la meme etoile) | 
|---|
|  | 1194 | |        void UEVT(void);   <*********** USER | 
|---|
|  | 1195 | | | 
|---|
|  | 1196 | |      } Fin de la boucle sur les etoiles | 
|---|
|  | 1197 | | | 
|---|
|  | 1198 | |      void UENDCCD(void);  <*********** USER | 
|---|
|  | 1199 | | | 
|---|
|  | 1200 | |    } Fin de la boucle sur les CCD | 
|---|
|  | 1201 | | | 
|---|
|  | 1202 | |    void UEND(void);  <*********** USER | 
|---|
|  | 1203 | |    Fin du montecarlo, impression des statistiques des generations | 
|---|
|  | 1204 | | | 
|---|
|  | 1205 | |  } Fin du job | 
|---|
|  | 1206 | | | 
|---|
|  | 1207 | *- void UINIT(void)* | 
|---|
|  | 1208 |  | 
|---|
|  | 1209 | Tout ce qui ne doit etre fait qu'une fois par job | 
|---|
|  | 1210 | definitions de parametres generaux, ouverture hbook etc... | 
|---|
|  | 1211 | | | 
|---|
|  | 1212 | *- UDATCLEAN(int icoul)* | 
|---|
|  | 1213 |  | 
|---|
|  | 1214 | Permet de tuer des images | 
|---|
|  | 1215 | Si date[icoul][imes] est mise a `GRAND2' l'image correspondante | 
|---|
|  | 1216 | ne sera pas prise en compte dans la sequence en temps. | 
|---|
|  | 1217 | Si date[icoul][imes] est mise a `GRAND2_KILL', l'image correspondante | 
|---|
|  | 1218 | ne sera ni decodee ni prise en compte (structure `MESUREU' mis a zero). | 
|---|
|  | 1219 | Ceci permet d'eliminer des images ou il y a eu des erreurs de codage | 
|---|
|  | 1220 | qui conduisent a un core dump. | 
|---|
|  | 1221 | | | 
|---|
|  | 1222 | *- Classement et elimination des images* | 
|---|
|  | 1223 |  | 
|---|
|  | 1224 | Les images sont ensuite rangees chronologiquement en ne tenant pas | 
|---|
|  | 1225 | compte des images tuees. Pour les images ayant la meme date, seules | 
|---|
|  | 1226 | celles de plus grand indice sont prises en compte. | 
|---|
|  | 1227 | Le tableau `indexu[icoul][]' est fournit: il contient les indices des images | 
|---|
|  | 1228 | valides rangees chronologiquement et sans doublons. L'indice de indexu | 
|---|
|  | 1229 | varie de `0 a nmesure[icoul]' valeur qui represente le nombre d'images | 
|---|
|  | 1230 | utilisables pour l'analyse. | 
|---|
|  | 1231 | Par exemple, l'indice de la 5ieme image valide de la couleur bleue (reference | 
|---|
|  | 1232 | secondaire) est: | 
|---|
|  | 1233 | |   j = indexu[1][5]; | 
|---|
|  | 1234 | et l'acces au flux brut est donne par: | 
|---|
|  | 1235 | |   fb = mesu[1][j].FluxB; | 
|---|
|  | 1236 | Toutes les images sont encore accessibles directement, par exemple | 
|---|
|  | 1237 | le flux brut de la 7ieme image (la 7ieme des fichiers de suivi | 
|---|
|  | 1238 | sans aucun choix ni classement chronologique) est, pour la reference | 
|---|
|  | 1239 | primaire (couleur rouge): | 
|---|
|  | 1240 | |   fb = mesu[0][7].FluxB; | 
|---|
|  | 1241 | | | 
|---|
|  | 1242 | *- UINITCCD(void)* | 
|---|
|  | 1243 |  | 
|---|
|  | 1244 | C'est un point d'entree a la fin de l'initialisation | 
|---|
|  | 1245 | du CCD courant. A ce niveau toutes les informations de `TIMEINFOU', | 
|---|
|  | 1246 | les notions d'images valides et le classement chronologique sont | 
|---|
|  | 1247 | connus. Les variables `TFIRST' et `TLAST' representent respectivement | 
|---|
|  | 1248 | la valeur de `date[][]' la plus petit et la plus grande pour les images | 
|---|
|  | 1249 | valides. A ce niveau peuvent etre faites des initialisation montecarlo | 
|---|
|  | 1250 | propres a un CCD. | 
|---|
|  | 1251 | | | 
|---|
|  | 1252 | *- Calcul des magnitudes absolues* | 
|---|
|  | 1253 |  | 
|---|
|  | 1254 | Par defaut, il n'y a pas | 
|---|
|  | 1255 | de calcul de magnitudes absolues. L'utilisateur peut fournir une | 
|---|
|  | 1256 | routine de prototype: | 
|---|
|  | 1257 | |   void mycalib(float,float,STARCALU *); | 
|---|
|  | 1258 | puis la connecter (dans `UINIT' ou `UINITCCD') au prototype: | 
|---|
|  | 1259 | |   void (*Calibration_Absolue)(float,float,STARCALU *, void*); | 
|---|
|  | 1260 | en ecrivant: `Calibration_Absolue = mycalib;'. | 
|---|
|  | 1261 | Cette routine sera appelee automatiquement pour chaque etoile | 
|---|
|  | 1262 | avec les arguments: | 
|---|
|  | 1263 | |   Calibration_Absolue(staru[0].FluxRef,staru[1].FluxRef,&starcal,uparms); | 
|---|
|  | 1264 | et remplira la structure `starcal'. Dand sa propre routine, | 
|---|
|  | 1265 | l'utilisateur peut remplir des magnitudes `B,V,R,I' ainsi | 
|---|
|  | 1266 | que le type de l'etoile (`SP=1 ou GR=2 ou indefini=0') et | 
|---|
|  | 1267 | son rayon en unites de rayon solaire. Le remplissage de | 
|---|
|  | 1268 | toutes ces valeurs n'est pas obligatoire, il depend de ce qui | 
|---|
|  | 1269 | doit etre fait apres, soit par l'utilisateur dans son analyse, | 
|---|
|  | 1270 | soit par la simulation montecarlo (l'effet de taille finie par | 
|---|
|  | 1271 | exemple a besoin du rayon de l'etoile). | 
|---|
|  | 1272 | Pour passer des parametres supplementaires a la fonction, | 
|---|
|  | 1273 | il faut initialiser le pointeur par l'assignation: | 
|---|
|  | 1274 | |   Calibration_Absolue_UParms = &user_data_block | 
|---|
|  | 1275 | et l'adresse sera passee comme 4eme argument de Calibration_Absolue. | 
|---|
|  | 1276 | `user_data_block' doit etre declaree comme variable `globale' | 
|---|
|  | 1277 | dans le fichier ou comme variable `static' dans la routine | 
|---|
|  | 1278 | ou est faite l'assignation. | 
|---|
|  | 1279 | | | 
|---|
|  | 1280 | *- Coupure sur les magnitudes absolues et la couleur des etoiles* | 
|---|
|  | 1281 |  | 
|---|
|  | 1282 | Pour des raisons de rapidite, l'utilisateur peut couper sur la | 
|---|
|  | 1283 | magnitude absolue ou la couleur de l'etoile en remplissant la | 
|---|
|  | 1284 | structure `starcut'. Le temps de lecture de l'etoile est | 
|---|
|  | 1285 | economise, et le point d'entree `UEVT()' n'est pas appele. | 
|---|
|  | 1286 | | | 
|---|
|  | 1287 | *- Generation montecarlo pour chaque etoile* | 
|---|
|  | 1288 |  | 
|---|
|  | 1289 | L'effet de microlentille est simule sur chaque etoile | 
|---|
|  | 1290 | (ou plusieurs fois par etoile). Une description detaillee des | 
|---|
|  | 1291 | possibilites de simulation est donnee plus loin. | 
|---|
|  | 1292 | | | 
|---|
|  | 1293 | *- UEVT(void)* | 
|---|
|  | 1294 |  | 
|---|
|  | 1295 | C'est l'endroit ou l'utilisateur met le code | 
|---|
|  | 1296 | d'analyse et de traitement des courbes de lumieres. A ce niveau | 
|---|
|  | 1297 | les etoiles selectionnees dans le fichier datacard par une carte | 
|---|
|  | 1298 | `@SELET' sont identifier par le flag `FgSelSt>0'. Les variables | 
|---|
|  | 1299 | de niveau d'impression, debug, etc... sont accessibles: | 
|---|
|  | 1300 | |  iet[NCOULMX] : numero de l'etoile (ref ou ref sec) | 
|---|
|  | 1301 | |  FgSelSt : flag de selection | 
|---|
|  | 1302 | |  idebug[4] : niveau de debug [iet1,iet2,ccd,niveau de debug] | 
|---|
|  | 1303 | |  ffprt : niveau d'impression | 
|---|
|  | 1304 | |  etc... | 
|---|
|  | 1305 | | | 
|---|
|  | 1306 | *- void UENDCCD(void)* | 
|---|
|  | 1307 |  | 
|---|
|  | 1308 | Point d'entree a la fin du traitement | 
|---|
|  | 1309 | d'un CCD. Il permet de fermer ou d'imprimer toute structure | 
|---|
|  | 1310 | relative a un CCD. | 
|---|
|  | 1311 | | | 
|---|
|  | 1312 | *- void UEND(void)* | 
|---|
|  | 1313 |  | 
|---|
|  | 1314 | Point d'entree a la fin du job. C'est l'endroit | 
|---|
|  | 1315 | pour desallouer les tableaux et pour imprimer les conclusions du job | 
|---|
|  | 1316 | | | 
|---|
|  | 1317 | *- Arguments de l'executable* | 
|---|
|  | 1318 |  | 
|---|
|  | 1319 | |     [-h] :  help tres tres detaille | 
|---|
|  | 1320 | |     [-et et1,et2,etinc] :  numeros des etoiles a traiter | 
|---|
|  | 1321 | |     [-prt niv] :  niveau de print | 
|---|
|  | 1322 | |     [-dbg et1,et2,ccd,niv] : debug de certaine etoiles/ccd | 
|---|
|  | 1323 | |     [-kill mes1 mes2 mes3 ...] : pour tuer les images mes1... | 
|---|
|  | 1324 | -kill permet de tuer les images mes1,mes2,mes3,... de `chaque' | 
|---|
|  | 1325 | fichier de suivi pour un CCD et une couleur. C'est particulierement | 
|---|
|  | 1326 | utile si, par exemple, la premiere image de chaque fichier de suivi | 
|---|
|  | 1327 | est l'images de reference: on s'en debarasse en indiquant: | 
|---|
|  | 1328 | |  -kill 1 | 
|---|
|  | 1329 | | | 
|---|
|  | 1330 | Pour les arguments de nbsread, conformenent aux conventions prises | 
|---|
|  | 1331 | pour les routines de lecture de fichiers de suivi, | 
|---|
|  | 1332 | les numeros d'etoiles et d'images vont de `1 a nmes[]' | 
|---|
|  | 1333 | (et non pas de `0 a nmes[]-1'). | 
|---|
|  | 1334 | | | 
|---|
|  | 1335 | *- Comment creer ses propres routines utilisateur* | 
|---|
|  | 1336 |  | 
|---|
|  | 1337 | Il faut ecrire un fichier dans lequel sont definies | 
|---|
|  | 1338 | les point d'entree utilisateurs: | 
|---|
|  | 1339 | `UINIT(), UDATCLEAN(int), UINITCCD(), UEVT(), UENDCCD() et UEND()'. | 
|---|
|  | 1340 | Le nom du fichier doit obligatoirement s'appeler | 
|---|
|  | 1341 | |  nbsreadu_myroutine.cc  (meme si on compile en C) | 
|---|
|  | 1342 | |  nbsreaduF_myroutine.f  pour la partie Fortran (si il y a des hbook) | 
|---|
|  | 1343 | myroutine est un nom choisi librement par l'utilisateur. | 
|---|
|  | 1344 | La compilation et le link s'effectue en executant: | 
|---|
|  | 1345 | |  make -f Makeus++ nbsread_myroutine   (si on travaille en C++) | 
|---|
|  | 1346 | |  make -f Makeus   nbsread_myroutine   (si on travaille en C  ) | 
|---|
|  | 1347 | Un exemple detaille a ete sauve dans la base CVS: | 
|---|
|  | 1348 | |  nbsreadu_squel.cc , nbsreaduF_squel.f | 
|---|
|  | 1349 | Pour l'executer et regarder ses impressions, | 
|---|
|  | 1350 | copiez `nbsreadu_squel.cc' et `nbsreaduF_squel.f' dans un de | 
|---|
|  | 1351 | vos repertoires, et recuperez dans la base CVS `AnaSuiv/Makeus++' | 
|---|
|  | 1352 | (ou `AnaSuiv/Makeus' si vous voulez compiler et linker en C). | 
|---|
|  | 1353 | Compilez et linkez: | 
|---|
|  | 1354 | |  make -f Makeus++ nbsread_squel | 
|---|
|  | 1355 | |  (ou make -f Makeus nbsread_squel) | 
|---|
|  | 1356 | Creez un fichier `fichier.dataccd' contenant des fichiers de suivi. | 
|---|
|  | 1357 | Executez `nbsreadu_squel' en tapant la ligne de commande suivante: | 
|---|
|  | 1358 | |  nbsreadu_squel fichier.dataccd -prt 1 \ | 
|---|
|  | 1359 | |          -mc 2 -u0 0.01,0.5 -t0 1,-1,-1 -tau 2,10,-1 -tf 2,0,2 -bl 1 | 
|---|
|  | 1360 | (cette procedure est egalement decrite aussi dans `nbsreadu_squel.cc') | 
|---|
|  | 1361 | | | 
|---|
|  | 1362 | *- Initialisation du montecarlo et generation* | 
|---|
|  | 1363 |  | 
|---|
|  | 1364 | L'initialisatuon peut etre effectuee, soit par arguments de | 
|---|
|  | 1365 | l'executable: | 
|---|
|  | 1366 | |     [-mc ngenstar] | 
|---|
|  | 1367 | |     [-u0 U0MinI,U0MaxI,U0SimI] | 
|---|
|  | 1368 | |     [-t0 T0MinI,T0MaxI,T0SimI] | 
|---|
|  | 1369 | |     [-tau TauMinI,TauMaxI,TauSimI] | 
|---|
|  | 1370 | |     [-tf type(1ou2),UMinI,UMaxI,USimI,Usu0_Cut] | 
|---|
|  | 1371 | |     [-bl Blending (1ou2)] | 
|---|
|  | 1372 | |     [-seed seed1,seed2,seed3] | 
|---|
|  | 1373 | soit en remplissant directement la structure `MONTECARLO mc' dans | 
|---|
|  | 1374 | UINIT() et eventuellement UINITCCD() pour l'initialisation du `t0'. | 
|---|
|  | 1375 | `nbsread -h' donne un help online tres detaille sur la facon de piloter | 
|---|
|  | 1376 | la generation. La description des variables de la structure `mc' | 
|---|
|  | 1377 | se trouve dans le fichier `nbgene.h'. | 
|---|
|  | 1378 | La description des possibilites du montecarlo est donnee | 
|---|
|  | 1379 | ci-apres en fonction des variables de la structure `mc': | 
|---|
|  | 1380 |  | 
|---|
|  | 1381 | | ----- CHOIX DU TYPE DE SIMULATION ----- | 
|---|
|  | 1382 | | mc.Taille_Finie = 0 : generation taille ponctuelle | 
|---|
|  | 1383 | |                   1 :            taille finie tirage plat en U = Rs(proj)/Re | 
|---|
|  | 1384 | |                   2 :            taille finie tirage plat en UC (U = UC*Rs) | 
|---|
|  | 1385 | | mc.Blending = 1 : simulation du "blending" sur l'etoile principale (la + brillante) | 
|---|
|  | 1386 | |               2 : simulation du "blending" sur l'etoile cachee (la - brillante) | 
|---|
|  | 1387 | | | 
|---|
|  | 1388 | | ----- GENERATION PLATE ----- | 
|---|
|  | 1389 | | si max<=min | 
|---|
|  | 1390 | |   - TauSim=TauSimI Tau du phenomene | 
|---|
|  | 1391 | |   - T0Sim=T0SimI   instant du maximum si T0SimI>0 | 
|---|
|  | 1392 | |   - U0Sim=U0SimI   parametre d'impact (en Re) si U0SimI>0 | 
|---|
|  | 1393 | |   - USim=USimI     projection rayon etoile dans plan naine (en Re) si USimI>0 | 
|---|
|  | 1394 | | si max>min | 
|---|
|  | 1395 | |   - TauSim est engendre avec une loi plate entre TauMinI ET TauMaxI | 
|---|
|  | 1396 | |   - T0Sim  est engendre avec une loi plate entre T0MinI  ET T0MaxI | 
|---|
|  | 1397 | |            si T0MaxI<T0MinI et T0SimI<0 on prend plat sur toute la periode | 
|---|
|  | 1398 | |   - U0Sim  est engendre avec une loi plate entre U0MinI  ET U0MaxI | 
|---|
|  | 1399 | |   - USim   est engendre avec une loi plate entre UMinI ET UMaxI si mc.Taille_Finie=1 | 
|---|
|  | 1400 | |                                      entre UMinI*Rs ET UMaxI*Rs si mc.Taille_Finie=2 | 
|---|
|  | 1401 | | | 
|---|
|  | 1402 | | ----- GENERATION SELON UNE LOI DETERMINEE PAR L'UTILISATEUR ----- | 
|---|
|  | 1403 | | l'utilisateur peut fournir la loi de tirage aleatoire pour u0,tau et u: | 
|---|
|  | 1404 | |   - mc.TireU0(float), mc.TireT0(float), mc.TireTau(float) et | 
|---|
|  | 1405 | |        mc.TireU(float) sont 3 pointeurs sur des fonctions | 
|---|
|  | 1406 | |        "float (*TireU0)(float alea)" | 
|---|
|  | 1407 | |        Il sont initialises a 0 dans nbsread.c | 
|---|
|  | 1408 | |   - mise en oeuvre (ex: pour le tirage de tau plat en log): | 
|---|
|  | 1409 | |     1-/ dans nbsreadu.c, l'utilisateur ecrit les routines de tirage | 
|---|
|  | 1410 | |         ( alea est uniformement distribue entre [0.,1.[ ) | 
|---|
|  | 1411 | |       float my_tiretau(float alea) | 
|---|
|  | 1412 | |         { | 
|---|
|  | 1413 | |         float tau; | 
|---|
|  | 1414 | |         tau = log(mc.TauMinI) | 
|---|
|  | 1415 | |             + alea * ( log(mc.TauMaxI) - log(mc.TauMinI) ); | 
|---|
|  | 1416 | |         return( (float) exp( (double) tau ) ); | 
|---|
|  | 1417 | |         } | 
|---|
|  | 1418 | |      2-/ dans UINIT (par exemple) | 
|---|
|  | 1419 | |         mc.TireTau = my_tiretau; | 
|---|
|  | 1420 |  | 
|---|
|  | 1421 | Evidemment dans l'hypothese d'un tirage avec effet de taille finie | 
|---|
|  | 1422 | le rayon de l'etoile (starcal.Rstar) doit etre rempli | 
|---|
|  | 1423 | dans la calibration absolue donnee par l'utilisateur. | 
|---|
|  | 1424 |  | 
|---|
|  | 1425 | Pour une generation avec effet de blending, l'utilisateur doit | 
|---|
|  | 1426 | une routine de simulation de l'effet de blending et la connecter | 
|---|
|  | 1427 | au prototype mc.Get_Par_Blending dans UINIT() ou UINITCCD(). | 
|---|
|  | 1428 | |  mc.Get_Par_Blending = my_blending_gene | 
|---|
|  | 1429 |  | 
|---|
|  | 1430 | Pour une simulation avec effet de blending sur l'etoile la plus | 
|---|
|  | 1431 | brillante du couple, il faut remplir | 
|---|
|  | 1432 | |  mc.coeff_Arec1[ic] pour les 2 couleurs (ic=0,1) | 
|---|
|  | 1433 | Arec est le coefficient de blending: | 
|---|
|  | 1434 | |  Ampli(blend) = (Ampli-1.)*Arec +1 | 
|---|
|  | 1435 |  | 
|---|
|  | 1436 | Pour une simulation avec effet de blending sur l'etoile la moins | 
|---|
|  | 1437 | brillante du couple, il faut remplir | 
|---|
|  | 1438 | |  mc.coeff_Arec2[ic] pour les 2 couleurs (ic=0,1) | 
|---|
|  | 1439 |  | 
|---|
|  | 1440 | Pour une simulation avec effet de blending sur l'etoile la plus | 
|---|
|  | 1441 | brillante du couple et avec effet de taille finie, il faut remplir | 
|---|
|  | 1442 | |  mc.coeff_Arec1[ic] pour les 2 couleurs (ic=0,1) | 
|---|
|  | 1443 | |  mc.starcal1.Rstar :   rayon de l'etoile la plus brillante | 
|---|
|  | 1444 |  | 
|---|
|  | 1445 | Pour une simulation avec effet de blending sur l'etoile la moins | 
|---|
|  | 1446 | brillante du couple et avec effet de taille finie, il faut remplir | 
|---|
|  | 1447 | |  mc.coeff_Arec2[ic] pour les 2 couleurs (ic=0,1) | 
|---|
|  | 1448 | |  mc.starcal2.Rstar :   rayon de l'etoile la moins brillante | 
|---|
|  | 1449 | | | 
|---|
|  | 1450 | *- Initialisation des aleatoires* | 
|---|
|  | 1451 |  | 
|---|
|  | 1452 | Le generateur utilise est "drand48" standard unix. | 
|---|
|  | 1453 | Il est prevu 3 variables permettant d'initialiser le generateur: | 
|---|
|  | 1454 | |  mc.iseed1, mc.iseed2, mc.iseed3 | 
|---|
|  | 1455 | A la fin du job l'etat des graines est automatiquement imprime | 
|---|
|  | 1456 | et permet de redemarrer un autre job pour la suite de la | 
|---|
|  | 1457 | sequence d'aleatoires. | 
|---|
|  | 1458 | | | 
|---|
|  | 1459 | *- Exemple de fichier datacard* | 
|---|
|  | 1460 |  | 
|---|
|  | 1461 | Cf AnaSuiv/nbsread.dataccd.Exemple | 
|---|
|  | 1462 | |4                  nombre de CCD a traiter | 
|---|
|  | 1463 | |@CCD 03            numero du 1er CCD a traiter | 
|---|
|  | 1464 | |@COUL 1            numero de la couleur de reference | 
|---|
|  | 1465 | |/home/suivi/file1_coul1_ccd03.suivi | 
|---|
|  | 1466 | |/home/suivi/file2_coul1_ccd03.suivi | 
|---|
|  | 1467 | |@COUL 2            numero de la couleur secondaire (facultatif) | 
|---|
|  | 1468 | |/home/suivi/file1_coul2_ccd03.suivi | 
|---|
|  | 1469 | |/home/suivi/file2_coul2_ccd03.suivi | 
|---|
|  | 1470 | |/home/suivi/file3_coul2_ccd03.suivi | 
|---|
|  | 1471 | |@FINCCD            carte de fin de CCD | 
|---|
|  | 1472 | |@CCD 01            numero du 2sd CCD a traiter | 
|---|
|  | 1473 | |@COUL 1            numero de la couleur de reference | 
|---|
|  | 1474 | |/home/suivi/file1_coul1_ccd01.suivi | 
|---|
|  | 1475 | |/home/suivi/file2_coul1_ccd01.suivi | 
|---|
|  | 1476 | |@COUL 2            numero de la couleur secondaire (facultatif) | 
|---|
|  | 1477 | |/home/suivi/file1_coul2_ccd01.suivi | 
|---|
|  | 1478 | |@FINCCD            carte de fin de CCD | 
|---|
|  | 1479 | |@CCD 05            numero du 3ieme CCD a traiter | 
|---|
|  | 1480 | |@COUL 1            numero de la couleur de reference | 
|---|
|  | 1481 | |/home/suivi/file1_coul1_ccd05.suivi | 
|---|
|  | 1482 | |/home/suivi/file2_coul1_ccd05.suivi | 
|---|
|  | 1483 | |/home/suivi/file3_coul1_ccd05.suivi | 
|---|
|  | 1484 | |/home/suivi/file4_coul1_ccd05.suivi | 
|---|
|  | 1485 | |@COUL 2            numero de la couleur secondaire (facultatif) | 
|---|
|  | 1486 | |/home/suivi/file1_coul2_ccd05.suivi | 
|---|
|  | 1487 | |/home/suivi/file2_coul2_ccd05.suivi | 
|---|
|  | 1488 | |/home/suivi/file3_coul2_ccd05.suivi | 
|---|
|  | 1489 | |@FINCCD            carte de fin de CCD | 
|---|
|  | 1490 | |@CCD 07            numero du 4ieme CCD a traiter | 
|---|
|  | 1491 | |@COUL 1            numero de la couleur de reference | 
|---|
|  | 1492 | |/home/suivi/file1_coul1_ccd07.suivi | 
|---|
|  | 1493 | |/home/suivi/file2_coul1_ccd07.suivi | 
|---|
|  | 1494 | |/home/suivi/file3_coul1_ccd07.suivi | 
|---|
|  | 1495 | |@FINCCD            carte de fin de CCD | 
|---|
|  | 1496 | |@END               carte de fin de fichier datacard | 
|---|
|  | 1497 | | | 
|---|
|  | 1498 | |.... liste d etoiles a selectionner: FgSelSt != 0 dans nbsread.h | 
|---|
|  | 1499 | |@SELET 1001 | 
|---|
|  | 1500 | |@SELET 1234 | 
|---|
|  | 1501 | |@SELET 2032 2050 | 
|---|
|  | 1502 | |@SELET 5044 | 
|---|
|  | 1503 | |@SELET 10001 10100 | 
|---|
|  | 1504 | |@SELET 6022 | 
|---|
|  | 1505 |  | 
|---|
|  | 1506 | A l'exception de la 1ere carte et des noms de fichiers de suivi | 
|---|
|  | 1507 | toute carte valide commence par un caractere @. | 
|---|
|  | 1508 | Il est fournit un moyen de selectionner des etoiles dans le | 
|---|
|  | 1509 | fichier datacard et de les identifier dans `UEVT()'. | 
|---|
|  | 1510 | grace au flag `FgSelSt'. | 
|---|
|  | 1511 | |  @SELET 1001        selection de l'etoile 1001 (attention et=[1,...]) | 
|---|
|  | 1512 | |  @SELET 1001 2001   selection des etoiles de 1001 a 2001 inclusif | 
|---|
|  | 1513 | | | 
|---|
|  | 1514 | *- Commentaire sur les structures des fichers de suivi et de nbsread* | 
|---|
|  | 1515 |  | 
|---|
|  | 1516 | Dans le fichier de suivi sont codees les structures: | 
|---|
|  | 1517 | |     GLOBINFO STARINFO MESURE TIMEINFO | 
|---|
|  | 1518 | La description des diverses structures et variables qu'elles | 
|---|
|  | 1519 | contiennent se trouve dans `fsvst.h'. | 
|---|
|  | 1520 | Pour gagner de la place, certaines d'entre elles (`TIMEINFO,MESURE') | 
|---|
|  | 1521 | ont des variables codees de facon non triviale dans les mots | 
|---|
|  | 1522 | de 16 bits. A la relecture du fichier de suivi, `nbsread' | 
|---|
|  | 1523 | decode automatiquement les variables pour les ranger en clair | 
|---|
|  | 1524 | dans des structures utilisateurs (dont le nom se termine par un `U'). | 
|---|
|  | 1525 | Notamment la structure `MESUREU' decode la structure `MESURE' et | 
|---|
|  | 1526 | renvoit le flux et les erreurs calibrees et tenant compte des | 
|---|
|  | 1527 | informations codees dans la structure `TIMEINFO'. | 
|---|
|  | 1528 | |     TIMEINFO  -> TIMEINFOU (qui ne contient qu'une partie des infos) | 
|---|
|  | 1529 | |     MESURE    -> MESUREU | 
|---|
|  | 1530 | Les routines de decodage sont dans fsvst.h mais ne doivent | 
|---|
|  | 1531 | en pratique pas etre utilisees directement par | 
|---|
|  | 1532 | l'utilisateur de `nbsread': | 
|---|
|  | 1533 | |     TIMEINFOU * DecodeTim( TIMEINFO *time, TIMEINFOU *timeu); | 
|---|
|  | 1534 | |     MESUREU * DecodeMes( MESURE *mesc, MESUREU *mesu); | 
|---|
|  | 1535 | | | 
|---|
|  | 1536 | *- Routines pratiques utilisables dans nbsread* | 
|---|
|  | 1537 |  | 
|---|
|  | 1538 | |  int read_timeinfo(int ic,int imes,TIMEINFO *tim) | 
|---|
|  | 1539 | Comme `TIMEINFOU' ne contient qu'une partie des informations | 
|---|
|  | 1540 | de la structure `TIMEINFO' du fichier de suivi, il peut etre pratique | 
|---|
|  | 1541 | de pouvoir recuprer `TIMEINFO'. `read_timeinfo' permet de | 
|---|
|  | 1542 | recuperer `TIMEINFO' pour la couleur `ic (0,1)' et la mesure | 
|---|
|  | 1543 | `imes (0,nmes[ic]-1)'. | 
|---|
|  | 1544 | |    void PrtGlobInfo (GLOBINFO *glinf, int lp); | 
|---|
|  | 1545 | |    void PrtStarInfo (STARINFO *sti, int n, int lp); | 
|---|
|  | 1546 | |    void PrtMesure (MESURE *mes, int n, int lp); | 
|---|
|  | 1547 | |    void PrtMesureU (MESUREU *mesu, int n, int lp); | 
|---|
|  | 1548 | |    void PrtTimeInfo (TIMEINFO *tim, int n, int lp); | 
|---|
|  | 1549 | |    void PrtTimeInfoU (TIMEINFOU *tim, int n, int lp); | 
|---|
|  | 1550 | Ces routines permettent d'imprimer les diverses structures | 
|---|
|  | 1551 | d'un fichiers de suivi. Elles sont dans `fsvst.h' | 
|---|
|  | 1552 | | | 
|---|
|  | 1553 | *- Routines de travail avec les transformations* | 
|---|
|  | 1554 |  | 
|---|
|  | 1555 | Elles permettent, par exemple, de calculer les coordonnees | 
|---|
|  | 1556 | sur l'image courante a partir des coordonnees de references de STARINFO. | 
|---|
|  | 1557 | Les rputines se trouvent dans `fsvst.h' et `transfost.h'. | 
|---|
|  | 1558 | |    void GlobInfoToTransf(GLOBINFO *gli, TRANSFO *t1, TRANSFO *t2); | 
|---|
|  | 1559 | |    void TimeInfoToTransf(&timloc,&t1,&t2); | 
|---|
|  | 1560 | |    void CordTransf(double xS, double yS, double *xD, double *yD, | 
|---|
|  | 1561 | |                    TRANSFO *transf) | 
|---|
|  | 1562 | Voici un exemple d'utilisation a mettre dans `UEVT()' pour l'etoile | 
|---|
|  | 1563 | courante. | 
|---|
|  | 1564 | |   TIMEINFO timloc; | 
|---|
|  | 1565 | |   TRANSFO t1,t2; | 
|---|
|  | 1566 | |   double Xcur[2],Ycur[2],x,y; | 
|---|
|  | 1567 | |   for(ic=0;ic<NCOULMX;ic++) { | 
|---|
|  | 1568 | |     for(k=0;k<nmes[ic];k++) { | 
|---|
|  | 1569 | |       read_timeinfo(ic,k,&timloc); | 
|---|
|  | 1570 | |       TimeInfoToTransf(&timloc,&t1,&t2); | 
|---|
|  | 1571 | |       -- des coordonnees de reference vers les courantes | 
|---|
|  | 1572 | |       x = staru[ic].XPos; y = staru[ic].YPos; | 
|---|
|  | 1573 | |       CordTransf(x,y,&Xcur[ic],&Ycur[ic],&t1); | 
|---|
|  | 1574 | |       PrintTransfo(&t1); | 
|---|
|  | 1575 | |       PrintTransfo(&t2); | 
|---|
|  | 1576 | |       -- des coordonnees courantes vers celles de reference | 
|---|
|  | 1577 | |       CordTransf(Xcur[ic],Ycur[ic],&x,&y,&t2); | 
|---|
|  | 1578 | |     } | 
|---|
|  | 1579 | |   } | 
|---|
|  | 1580 |  | 
|---|
|  | 1581 | -- | 
|---|
|  | 1582 | */ | 
|---|