[3308] | 1 | /*
|
---|
| 2 | nbsreadu_squel fichier.dataccd -prt 1 \
|
---|
| 3 | -mc 2 -u0 0.01,0.5 -t0 1,-1,-1 -tau 2,10,-1 -tf 2,0,2 -bl 1
|
---|
| 4 | */
|
---|
| 5 | #include "machdefs.h"
|
---|
| 6 | #include <stdlib.h>
|
---|
| 7 | #include <math.h>
|
---|
| 8 | #include <stdio.h>
|
---|
| 9 | #include <string.h>
|
---|
| 10 |
|
---|
| 11 | #include "fsvcache.h"
|
---|
| 12 | #include "fsvst.h"
|
---|
| 13 | #include "fmath.h"
|
---|
| 14 | #include "nbmath.h"
|
---|
| 15 | #include "nbrandom.h"
|
---|
| 16 | #include "nbsread.h"
|
---|
| 17 | #include "nbgene.h"
|
---|
| 18 |
|
---|
| 19 | #ifdef __cplusplus
|
---|
| 20 | extern "C" {
|
---|
| 21 | #endif
|
---|
| 22 | /* Prototype des routines locales en C ou C++ */
|
---|
| 23 | void mycalib(float f1,float f2, STARCALU* stcal, void *user_parm);
|
---|
| 24 | void myblending(void);
|
---|
| 25 | float mytiretau(float);
|
---|
| 26 | #ifdef __cplusplus
|
---|
| 27 | }
|
---|
| 28 | #endif
|
---|
| 29 |
|
---|
| 30 | /*================================================================*/
|
---|
| 31 | void UINIT(void)
|
---|
| 32 | {
|
---|
| 33 | static char CcdParm[20];
|
---|
| 34 |
|
---|
| 35 | /* fonction utilisateur de calibration absolue */
|
---|
| 36 | Calibration_Absolue = mycalib;
|
---|
| 37 | strcpy(CcdParm,"CCD");
|
---|
| 38 | Calibration_Absolue_UParms = CcdParm;
|
---|
| 39 | /* fonction utilisateur de generation des parametres du blending */
|
---|
| 40 | mc.Get_Par_Blending = myblending;
|
---|
| 41 | /* fonction utilisateur de tirage du parametre Tau */
|
---|
| 42 | mc.TireTau = mytiretau;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | /*=================== ============================================*/
|
---|
| 46 | void UDATCLEAN(int coul)
|
---|
| 47 | /*
|
---|
| 48 | Attention ici coul = 1,2
|
---|
| 49 | donc pour tuer une image pour la couleur coul:
|
---|
| 50 | date[coul-1][...] = GRAND2;
|
---|
| 51 | */
|
---|
| 52 | {
|
---|
| 53 | int ic = coul - 1;
|
---|
| 54 | printf("UDATCLEAN: couleur %d, indice tableau %d\n",coul,ic);
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | /*================================================================*/
|
---|
| 58 | void UINITCCD(void)
|
---|
| 59 | {
|
---|
| 60 | printf("UINITCCD: Debut de l'etude du CCD %d %d\n",numccd,ccdnum);
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | /*================================================================*/
|
---|
| 64 | void UEVT(void)
|
---|
| 65 | {
|
---|
| 66 | int ic,i,j;
|
---|
| 67 | float xnt[30];
|
---|
| 68 | double fball[2], fbgood[2], w;
|
---|
| 69 |
|
---|
| 70 | if( ffprt > 0 || iet[0]%100==0 ) {
|
---|
| 71 | printf("****> Et= %d %d Sel=%d fref=%g,%g\n"
|
---|
| 72 | ,iet[0],iet[1],FgSelSt,staru[0].FluxRef,staru[1].FluxRef);
|
---|
| 73 | printf(" B=%g V=%g R=%g I=%g Rs=%g t=%d\n"
|
---|
| 74 | ,starcal.Mag_B,starcal.Mag_V,starcal.Mag_R,starcal.Mag_I
|
---|
| 75 | ,starcal.Rstar,starcal.Rtype);
|
---|
| 76 | printf(" u0=%g t0=%g tau=%g U=%g\n",mc.U0Sim,mc.T0Sim,mc.TauSim,mc.USim);
|
---|
| 77 | printf(" Arec1=%g,%g Arec2=%g,%g Rstar1=%g Rstar2=%g\n"
|
---|
| 78 | ,mc.coeff_Arec1[0],mc.coeff_Arec1[1],mc.coeff_Arec2[0],mc.coeff_Arec2[1]
|
---|
| 79 | ,mc.starcal1.Rstar,mc.starcal2.Rstar);
|
---|
| 80 | printf(" A0_pct=%g A0_tf=%g A0_blend=%g,%g\n"
|
---|
| 81 | ,mc.A0MaxPt,mc.A0Max,mc.A0Max_blend[0],mc.A0Max_blend[1]);
|
---|
| 82 | fflush(stdout);
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | /* moyenne des flux bruts de toutes les images et des images valides */
|
---|
| 86 | for(ic=0;ic<NCOULMX;ic++) {
|
---|
| 87 |
|
---|
| 88 | fball[ic] = w = 0.;
|
---|
| 89 | if( nmes[ic] > 0 ) {
|
---|
| 90 | for(i=0;i<nmes[ic];i++) {
|
---|
| 91 | if( mesu[ic][i].Xi2 < 0. ) continue;
|
---|
| 92 | if( mesu[ic][i].ErrFluxB <= 0. ) continue;
|
---|
| 93 | fball[ic] += mesu[ic][i].FluxB*mesu[ic][i].ErrFluxB;
|
---|
| 94 | w += mesu[ic][i].ErrFluxB;
|
---|
| 95 | }
|
---|
| 96 | if( w > 0. ) fball[ic] /= w;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | fbgood[ic] = w = 0.;
|
---|
| 100 | if( nmesure[ic] > 0 ) {
|
---|
| 101 | for(j=0;j<nmesure[ic];j++) {
|
---|
| 102 | i = indexu[ic][j];
|
---|
| 103 | if( mesu[ic][i].Xi2 < 0. ) continue;
|
---|
| 104 | if( mesu[ic][i].ErrFluxB <= 0. ) continue;
|
---|
| 105 | fbgood[ic] += mesu[ic][i].FluxB*mesu[ic][i].ErrFluxB;
|
---|
| 106 | w += mesu[ic][i].ErrFluxB;
|
---|
| 107 | }
|
---|
| 108 | if( w > 0. ) fbgood[ic] /= w;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | xnt[ 0] = iet[0];
|
---|
| 114 | xnt[ 1] = iet[1];
|
---|
| 115 | xnt[ 2] = staru[0].FluxRef;
|
---|
| 116 | xnt[ 3] = staru[1].FluxRef;
|
---|
| 117 | xnt[ 4] = starcal.Mag_B;
|
---|
| 118 | xnt[ 5] = starcal.Mag_V;
|
---|
| 119 | xnt[ 6] = starcal.Mag_R;
|
---|
| 120 | xnt[ 7] = starcal.Mag_I;
|
---|
| 121 | xnt[ 8] = starcal.Rstar;
|
---|
| 122 | xnt[ 9] = starcal.Rtype;
|
---|
| 123 | xnt[10] = mc.U0Sim;
|
---|
| 124 | xnt[11] = mc.T0Sim;
|
---|
| 125 | xnt[12] = mc.TauSim;
|
---|
| 126 | xnt[13] = mc.USim;
|
---|
| 127 | xnt[14] = mc.A0MaxPt;
|
---|
| 128 | xnt[15] = mc.A0Max;
|
---|
| 129 | xnt[16] = mc.A0Max_blend[0];
|
---|
| 130 | xnt[17] = mc.A0Max_blend[1];
|
---|
| 131 | xnt[18] = mc.starcal1.Rstar;
|
---|
| 132 | xnt[19] = mc.starcal2.Rstar;
|
---|
| 133 | xnt[20] = fball[0];
|
---|
| 134 | xnt[21] = fball[1];
|
---|
| 135 | xnt[22] = fbgood[0];
|
---|
| 136 | xnt[23] = fbgood[1];
|
---|
| 137 | // a stoquer dans votre fichier prefere
|
---|
| 138 |
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | /*================================================================*/
|
---|
| 142 | void UENDCCD(void)
|
---|
| 143 | {
|
---|
| 144 | printf("UENDCCD: Fin de l'etude du CCD %d %d\n",numccd,ccdnum);
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | /*================================================================*/
|
---|
| 148 | void UEND(void)
|
---|
| 149 | {
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | /*================================================================*/
|
---|
| 153 | void mycalib(float f1,float f2, STARCALU* stcal, void *user_parm)
|
---|
| 154 | /* fonction de calibration absolue completement idiote */
|
---|
| 155 | {
|
---|
| 156 | if(f1<=0. || f2<0.) return;
|
---|
| 157 | if( strcmp((char *) user_parm,"CCD") ) return;
|
---|
| 158 | stcal->Mag_B = stcal->Mag_V = -2.5*log10((double) f2);
|
---|
| 159 | stcal->Mag_R = stcal->Mag_I = -2.5*log10((double) f1);
|
---|
| 160 | stcal->Rtype = (int) (drand01()+1.5);
|
---|
| 161 | stcal->Rstar = 3.*drand01();
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | /*================================================================*/
|
---|
| 165 | void myblending(void)
|
---|
| 166 | /* fonction de generation de blending completement idiote */
|
---|
| 167 | {
|
---|
| 168 | mc.coeff_Arec1[0] = 0.5+drand01()/2.;
|
---|
| 169 | mc.coeff_Arec1[1] = 0.5+drand01()/2.;
|
---|
| 170 | mc.starcal1.Rstar = 3.*drand01();
|
---|
| 171 |
|
---|
| 172 | mc.coeff_Arec2[0] = 0.5-drand01()/2.;
|
---|
| 173 | mc.coeff_Arec2[1] = 0.5-drand01()/2.;
|
---|
| 174 | mc.starcal2.Rstar = 3.*drand01()/2.;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | /*================================================================*/
|
---|
| 178 | float mytiretau(float alea)
|
---|
| 179 | /* fonction de tirage aleatoire de Tau personnelle */
|
---|
| 180 | /* (tirage logarithmique en Tau) */
|
---|
| 181 | {
|
---|
| 182 | if( mc.TauMinI<=0. || mc.TauMaxI<=0. || mc.TauMaxI<=mc.TauMinI ) {
|
---|
| 183 | mc.TauMinI = 1.; mc.TauMaxI = 100.;
|
---|
| 184 | }
|
---|
| 185 | alea *= log(mc.TauMaxI/mc.TauMinI);
|
---|
| 186 | return( (float) mc.TauMinI*exp((double) alea) );
|
---|
| 187 | }
|
---|