OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
chand.c
Go to the documentation of this file.
1 #include <math.h>
2 
3 #define fac 0.0174532925199 /* PI/180 */
4 
5 void chand(float xphi, float xmuv, float xmus, float *xtau, float *rhoray, double *trup, double *trdown, int nbands, char *process) {
6  /*
7  input parameters: xphi,xmus,xmuv,xtau
8  xphi: azimuthal difference between sun and observation (xphi=0,
9  in backscattering) and expressed in degree (0.:360.)
10  xmus: cosine of the sun zenith angle
11  xmuv: cosine of the observation zenith angle
12  xtau: molecular optical depth
13  output parameter: xrray : molecular reflectance (0.:1.)
14  constant : xdep: depolarization factor (0.0279)
15  xfd = (1-xdep/(2-xdep)) / (1 + 2*xdep/(2-xdep)) = 2 * (1 - xdep) / (2 + xdep) = 0.958725775
16  */
17  const double xfd = 0.958725775;
18  const float xbeta2 = 0.5;
19  float pl[5];
20  double fs01, fs02, fs0, fs1, fs2;
21  const float as0[10] = {0.33243832, 0.16285370, -0.30924818, -0.10324388, 0.11493334,
22  -6.777104e-02, 1.577425e-03, -1.240906e-02, 3.241678e-02, -3.503695e-02};
23  const float as1[2] = {.19666292, -5.439061e-02};
24  const float as2[2] = {.14545937, -2.910845e-02};
25  float phios, xcosf1, xcosf2, xcosf3;
26  float xph1, xph2, xph3, xitm1, xitm2;
27  float xlntau, xitot1, xitot2, xitot3;
28  int i, ib;
29 
30  phios = xphi + 180;
31  xcosf1 = 1.;
32  xcosf2 = cosf(phios * fac);
33  xcosf3 = cosf(2 * phios * fac);
34  xph1 = 1 + (3 * xmus * xmus - 1) * (3 * xmuv * xmuv - 1) * xfd / 8.;
35  xph2 = -xfd * xbeta2 * 1.5 * xmus * xmuv * sqrtf(1 - xmus * xmus) * sqrtf(1 - xmuv * xmuv);
36  xph3 = xfd * xbeta2 * 0.375 * (1 - xmus * xmus) * (1 - xmuv * xmuv);
37  pl[0] = 1.;
38  pl[1] = xmus + xmuv;
39  pl[2] = xmus * xmuv;
40  pl[3] = xmus * xmus + xmuv * xmuv;
41  pl[4] = xmus * xmus * xmuv * xmuv;
42  fs01 = fs02 = 0;
43  for (i = 0; i < 5; i++) fs01 += pl[i] * as0[i];
44  for (i = 0; i < 5; i++) fs02 += pl[i] * as0[5 + i];
45  for (ib = 0; ib < nbands; ib++) {
46  if (process[ib]) {
47  xlntau = logf(xtau[ib]);
48  fs0 = fs01 + fs02 * xlntau;
49  fs1 = as1[0] + xlntau * as1[1];
50  fs2 = as2[0] + xlntau * as2[1];
51  trdown[ib] = expf(-xtau[ib] / xmus);
52  trup[ib] = expf(-xtau[ib] / xmuv);
53  xitm1 = (1 - trdown[ib] * trup[ib]) / 4. / (xmus + xmuv);
54  xitm2 = (1 - trdown[ib]) * (1 - trup[ib]);
55  xitot1 = xph1 * (xitm1 + xitm2 * fs0);
56  xitot2 = xph2 * (xitm1 + xitm2 * fs1);
57  xitot3 = xph3 * (xitm1 + xitm2 * fs2);
58  rhoray[ib] = xitot1 * xcosf1 + xitot2 * xcosf2 * 2 + xitot3 * xcosf3 * 2;
59  }
60  }
61 
62 }
void chand(float xphi, float xmuv, float xmus, float *xtau, float *rhoray, double *trup, double *trdown, int nbands, char *process)
Definition: chand.c:5
#define fac
Definition: chand.c:3
int32_t nbands
int i
Definition: decode_rs.h:71