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