OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
compute_alpha.c
Go to the documentation of this file.
1 #include <math.h>
2 
3 /* ----------------------------------------------------------------------------- */
4 /* compute_alpha() - computes polarization correction frame rotation angle */
5 /* */
6 /* algorithm provided by: F. S. Patt, SAIC, February 2003. */
7 /* ----------------------------------------------------------------------------- */
8 void compute_alpha(float lon[],
9  float lat[],
10  float senz[],
11  float sena[],
12  double mnorm[3],
13  int npix,
14  float alpha[]) {
15  static double radeg = 57.29577951;
16 
17  int ip, i;
18 
19  double slon, clon;
20  double slat, clat;
21  double szen, czen;
22  double sazi, cazi;
23 
24  double e[3], n[3], v[3], r[3], s[3];
25  double sdvcr, vdr, sdr, sdv;
26 
27  /* invert mirror normal */
28  for (i = 0; i < 3; i++)
29  r[i] = -mnorm[i];
30 
31  for (ip = 0; ip < npix; ip++) {
32  slon = sin(lon[ip] / radeg);
33  clon = cos(lon[ip] / radeg);
34  slat = sin(lat[ip] / radeg);
35  clat = cos(lat[ip] / radeg);
36  szen = sin(senz[ip] / radeg);
37  czen = cos(senz[ip] / radeg);
38  sazi = sin(sena[ip] / radeg);
39  cazi = cos(sena[ip] / radeg);
40 
41  /* pixel coordinate system (north, east, vertical) in ECR */
42  e[0] = -slon;
43  e[1] = clon;
44  e[2] = 0.0;
45 
46  n[0] = -slat * clon;
47  n[1] = -slat * slon;
48  n[2] = clat;
49 
50  v[0] = clat * clon;
51  v[1] = clat * slon;
52  v[2] = slat;
53 
54  /* sensor view vector in ECR */
55  for (i = 0; i < 3; i++)
56  s[i] = e[i] * szen * sazi + n[i] * szen * cazi + v[i] * czen;
57 
58  /* compute rotation angle (alpha) from pixel normal (v) to mirror */
59  /* normal (r) about sensor view vector (s) (Wertz, p. 757) */
60  sdvcr = s[0] * (v[1] * r[2] - v[2] * r[1])
61  + s[1] * (v[2] * r[0] - v[0] * r[2])
62  + s[2] * (v[0] * r[1] - v[1] * r[0]);
63 
64  vdr = v[0] * r[0] + v[1] * r[1] + v[2] * r[2];
65  sdr = s[0] * r[0] + s[1] * r[1] + s[2] * r[2];
66  sdv = v[0] * s[0] + v[1] * s[1] + v[2] * s[2];
67 
68  /* negated to be consistent with Gordon et al. */
69  alpha[ip] = -(radeg * atan2(sdvcr, (vdr - sdr * sdv)) - 90.0);
70  }
71 }
int r
Definition: decode_rs.h:73
double mnorm[3]
float * lat
void compute_alpha(float lon[], float lat[], float senz[], float sena[], double mnorm[3], int npix, float alpha[])
Definition: compute_alpha.c:8
float * lon
data_t s[NROOTS]
Definition: decode_rs.h:75
int i
Definition: decode_rs.h:71
int npix
Definition: get_cmp.c:27