13 void chand(
float xphi,
float xmuv,
float xmus,
float *xtau,
14 float *rhoray,
double *trup,
double *trdown,
int nbands);
17 static float pi = 3.141592654;
18 static float radeg = 180. / 3.141592654;
19 static float p0 = 1013.25;
21 float delphi =
l1rec->delphi[ip] + 180.0;
22 float mu0 = cos(
l1rec->solz[ip] / radeg);
23 float mu = cos(
l1rec->senz[ip] / radeg);
24 float airmass = 1.0 /
mu0 + 1.0 /
mu;
36 if ((Taur = (
float *) calloc(
nbands,
sizeof (
float))) ==
NULL) {
37 printf(
"-E- : Error allocating memory to Taur\n");
40 if ((rhor = (
float *) calloc(
nbands,
sizeof (
float))) ==
NULL) {
41 printf(
"-E- : Error allocating memory to rhor\n");
44 if ((trup = (
double *) calloc(
nbands,
sizeof (
double))) ==
NULL) {
45 printf(
"-E- : Error allocating memory to trup\n");
48 if ((trdown = (
double *) calloc(
nbands,
sizeof (
double))) ==
NULL) {
49 printf(
"-E- : Error allocating memory to trdown\n");
56 for (ib = 0; ib <
nbands; ib++) {
57 Taur[ib] =
l1rec->l1file->Tau_r[ib] *
l1rec->pr[ip] / p0;
68 for (ib = 0; ib <
l1rec->l1file->nbands; ib++) {
70 ipb = ip *
l1rec->l1file->nbands + ib;
75 ((2.0 / 3.0 +
mu0) + (2.0 / 3.0 -
mu0) * trdown[ib])
76 / (4.0 / 3.0 + Taur[ib]);
78 ((2.0 / 3.0 +
mu) + (2.0 / 3.0 -
mu) * trup [ib])
79 / (4.0 / 3.0 + Taur[ib]);
82 l1rec->polcor[ipb] = 1.0;
85 Tauoz =
l1rec->l1file->k_oz[ib] *
l1rec->oz[ip];
86 l1rec->tg_sol[ipb] = exp(-Tauoz /
mu0);
87 l1rec->tg_sen[ipb] = exp(-Tauoz /
mu);
92 l1rec->t_h2o[ipb] = 1.0;
94 l1rec->t_o2[ipb] = 1.0;
111 #define fac 0.0174532925199
113 void chand(
float xphi,
float xmuv,
float xmus,
float *xtau,
float *rhoray,
double *trup,
double *trdown,
int nbands) {
128 const double xfd = 0.958725775;
129 const float xbeta2 = 0.5;
131 double fs01, fs02, fs0, fs1, fs2;
132 const float as0[10] = {0.33243832, 0.16285370, -0.30924818, -0.10324388, 0.11493334,
133 -6.777104e-02, 1.577425e-03, -1.240906e-02, 3.241678e-02, -3.503695e-02};
134 const float as1[2] = {.19666292, -5.439061e-02};
135 const float as2[2] = {.14545937, -2.910845e-02};
136 float phios, xcosf1, xcosf2, xcosf3;
137 float xph1, xph2, xph3, xitm1, xitm2;
138 float xlntau, xitot1, xitot2, xitot3;
143 xcosf2 = cos(phios *
fac);
144 xcosf3 = cos(2 * phios *
fac);
145 xph1 = 1 + (3 * xmus * xmus - 1) * (3 * xmuv * xmuv - 1) * xfd / 8.;
146 xph2 = -xfd * xbeta2 * 1.5 * xmus * xmuv * sqrt(1 - xmus * xmus) * sqrt(1 - xmuv * xmuv);
147 xph3 = xfd * xbeta2 * 0.375 * (1 - xmus * xmus) * (1 - xmuv * xmuv);
151 pl[3] = xmus * xmus + xmuv * xmuv;
152 pl[4] = xmus * xmus * xmuv * xmuv;
154 for (
i = 0;
i < 5;
i++) fs01 += pl[
i] * as0[
i];
155 for (
i = 0;
i < 5;
i++) fs02 += pl[
i] * as0[5 +
i];
156 for (ib = 0; ib <
nbands; ib++) {
157 xlntau = log(xtau[ib]);
158 fs0 = fs01 + fs02 * xlntau;
159 fs1 = as1[0] + xlntau * as1[1];
160 fs2 = as2[0] + xlntau * as2[1];
161 trdown[ib] = exp(-xtau[ib] / xmus);
162 trup[ib] = exp(-xtau[ib] / xmuv);
163 xitm1 = (1 - trdown[ib] * trup[ib]) / 4. / (xmus + xmuv);
164 xitm2 = (1 - trdown[ib]) * (1 - trup[ib]);
165 xitot1 = xph1 * (xitm1 + xitm2 * fs0);
166 xitot2 = xph2 * (xitm1 + xitm2 * fs1);
167 xitot3 = xph3 * (xitm1 + xitm2 * fs2);
168 rhoray[ib] = xitot1 * xcosf1 + xitot2 * xcosf2 * 2 + xitot3 * xcosf3 * 2;