17 void chand(
float xphi,
float xmuv,
float xmus,
float *xtau,
18 float *rhoray,
double *trup,
double *trdown,
int nbands);
21 static float pi = 3.141592654;
22 static float radeg = 180. / 3.141592654;
23 static float p0 = 1013.25;
25 float delphi =
l1rec->delphi[ip] + 180.0;
26 float mu0 = cos(
l1rec->solz[ip] / radeg);
27 float mu = cos(
l1rec->senz[ip] / radeg);
28 float airmass = 1.0 /
mu0 + 1.0 /
mu;
38 if ((Taur = (
float *) calloc(
nbands,
sizeof (
float))) ==
NULL) {
39 printf(
"-E- : Error allocating memory to Taur\n");
42 if ((rhor = (
float *) calloc(
nbands,
sizeof (
float))) ==
NULL) {
43 printf(
"-E- : Error allocating memory to rhor\n");
46 if ((trup = (
double *) calloc(
nbands,
sizeof (
double))) ==
NULL) {
47 printf(
"-E- : Error allocating memory to trup\n");
50 if ((trdown = (
double *) calloc(
nbands,
sizeof (
double))) ==
NULL) {
51 printf(
"-E- : Error allocating memory to trdown\n");
56 for (ib = 0; ib <
nbands; ib++) {
57 l1rec->tg_sol[ipb + ib] = 1.0;
58 l1rec->tg_sen[ipb + ib] = 1.0;
59 l1rec->t_h2o [ipb + ib] = 1.0;
60 l1rec->t_o2 [ipb + ib] = 1.0;
66 for (ib = 0; ib <
nbands; ib++) {
67 Taur[ib] =
l1rec->l1file->Tau_r[ib] *
l1rec->pr[ip] / p0;
81 for (ib = 0; ib <
l1rec->l1file->nbands; ib++) {
83 ipb = ip *
l1rec->l1file->nbands + ib;
88 ((2.0 / 3.0 +
mu0) + (2.0 / 3.0 -
mu0) * trdown[ib])
89 / (4.0 / 3.0 + Taur[ib]);
91 ((2.0 / 3.0 +
mu) + (2.0 / 3.0 -
mu) * trup [ib])
92 / (4.0 / 3.0 + Taur[ib]);
95 l1rec->polcor[ipb] = 1.0;
116 #define fac 0.0174532925199
118 void chand(
float xphi,
float xmuv,
float xmus,
float *xtau,
float *rhoray,
double *trup,
double *trdown,
int nbands) {
133 const double xfd = 0.958725775;
134 const float xbeta2 = 0.5;
136 double fs01, fs02, fs0, fs1, fs2;
137 const float as0[10] = {0.33243832, 0.16285370, -0.30924818, -0.10324388, 0.11493334,
138 -6.777104e-02, 1.577425e-03, -1.240906e-02, 3.241678e-02, -3.503695e-02};
139 const float as1[2] = {.19666292, -5.439061e-02};
140 const float as2[2] = {.14545937, -2.910845e-02};
141 float phios, xcosf1, xcosf2, xcosf3;
142 float xph1, xph2, xph3, xitm1, xitm2;
143 float xlntau, xitot1, xitot2, xitot3;
148 xcosf2 = cos(phios *
fac);
149 xcosf3 = cos(2 * phios *
fac);
150 xph1 = 1 + (3 * xmus * xmus - 1) * (3 * xmuv * xmuv - 1) * xfd / 8.;
151 xph2 = -xfd * xbeta2 * 1.5 * xmus * xmuv * sqrt(1 - xmus * xmus) * sqrt(1 - xmuv * xmuv);
152 xph3 = xfd * xbeta2 * 0.375 * (1 - xmus * xmus) * (1 - xmuv * xmuv);
156 pl[3] = xmus * xmus + xmuv * xmuv;
157 pl[4] = xmus * xmus * xmuv * xmuv;
159 for (
i = 0;
i < 5;
i++) fs01 += pl[
i] * as0[
i];
160 for (
i = 0;
i < 5;
i++) fs02 += pl[
i] * as0[5 +
i];
161 for (ib = 0; ib <
nbands; ib++) {
162 xlntau = log(xtau[ib]);
163 fs0 = fs01 + fs02 * xlntau;
164 fs1 = as1[0] + xlntau * as1[1];
165 fs2 = as2[0] + xlntau * as2[1];
166 trdown[ib] = exp(-xtau[ib] / xmus);
167 trup[ib] = exp(-xtau[ib] / xmuv);
168 xitm1 = (1 - trdown[ib] * trup[ib]) / 4. / (xmus + xmuv);
169 xitm2 = (1 - trdown[ib]) * (1 - trup[ib]);
170 xitot1 = xph1 * (xitm1 + xitm2 * fs0);
171 xitot2 = xph2 * (xitm1 + xitm2 * fs1);
172 xitot3 = xph3 * (xitm1 + xitm2 * fs2);
173 rhoray[ib] = xitot1 * xcosf1 + xitot2 * xcosf2 * 2 + xitot3 * xcosf3 * 2;