OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
mumm.c
Go to the documentation of this file.
1 /* =================================================================== */
2 /* MUMM module - turbid water correction for Gordon & Wang atmosphere */
3 /* */
4 /* Reference: */
5 /* */
6 /* Ruddick, K., F.Ovidio & M.Rijkeboer (2000). Atmospheric correction */
7 /* of SeaWiFS imagery for turbid coastal and inland waters, */
8 /* Applied Optics, 39(6), pp897-912. */
9 /* */
10 /* Written By: */
11 /* */
12 /* B. Franz, NASA/OBPG, 03 November 2006 (based on implementation from */
13 /* http://www.mumm.ac.be/OceanColour/Products/Software/index.php) */
14 /* W. Robinson, SAIC, 26 Apr 2017 add band dependence for solz */
15 /* */
16 /* =================================================================== */
17 
18 #include "l12_proto.h"
19 
20 /* ------------------------------------------------------------------- */
21 /* get_rho_mumm(): compute quasi-surface reflectance preferred by MUMM.*/
22 
23 /* ------------------------------------------------------------------- */
24 
25 void get_rho_mumm(l2str *l2rec, int32_t ipix, int32_t iw, float *rhom) {
26  int32_t ip, ip1, ip2, ipb;
27  float Ltemp;
28 
29  l1str *l1rec = l2rec->l1rec;
30  filehandle *l1file = l1rec->l1file;
31  int32_t nbands = l1file->nbands;
32  float solz;
33 
34  if (ipix < 0) {
35  ip1 = 0;
36  ip2 = l1rec->npix - 1;
37  } else {
38  ip1 = ipix;
39  ip2 = ipix;
40  }
41 
42  for (ip = ip1; ip <= ip2; ip++) {
43 
44  if (l1rec->mask[ip])
45  *rhom++ = 0.0;
46 
47  else {
48 
49  ipb = ip * nbands + iw;
50  solz = (l1rec->geom_per_band == NULL) ? l1rec->solz[ip] :
51  l1rec->geom_per_band->solz[ipb];
52 
53  Ltemp = (l2rec->l1rec->Lt[ipb]
54  / l1rec->tg_sol[ipb] / l1rec->tg_sen[ipb]
55  / l1rec->polcor[ipb]
56  - l1rec->tLf[ipb]
57  - l1rec->Lr[ipb]
58  ) / l1rec->t_o2[ipb]
59  - l1rec->TLg[ipb];
60 
61  *rhom++ = PI * Ltemp / l1rec->Fo[iw] / cos(solz / RADEG);
62 
63  }
64  }
65 }
66 
67 
68 /* ------------------------------------------------------------------- */
69 /* get_rhown_mumm(): compute the normalized water-leaving reflectance */
70 /* contribution in the NIR using MUMM algorithm. */
71 
72 /* ------------------------------------------------------------------- */
73 
74 void get_rhown_mumm(l2str *l2rec, int32_t ip, int32_t nir_s, int32_t nir_l, float rhown[]) {
75  float alpha = input->mumm_alpha;
76  float gamma = input->mumm_gamma;
77  float epsilon = input->mumm_epsilon;
78 
79  float rhom_s, rhom_l;
80  float rhoa_s, rhoa_l;
81 
82  get_rho_mumm(l2rec, ip, nir_s, &rhom_s);
83  get_rho_mumm(l2rec, ip, nir_l, &rhom_l);
84 
85  rhoa_l = MAX(MIN((rhom_l * gamma * alpha - rhom_s) / (gamma * alpha - epsilon), rhom_l), 0.0);
86  rhoa_s = MIN(epsilon*rhoa_l, rhom_s);
87 
88  rhown[nir_s] = rhom_s - rhoa_s;
89  rhown[nir_l] = rhom_l - rhoa_l;
90 
91  return;
92 }
93 
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
Definition: l1stat_chk.c:586
#define MAX(A, B)
Definition: swl0_utils.h:26
#define MIN(x, y)
Definition: rice.h:169
#define NULL
Definition: decode_rs.h:63
read l1rec
instr * input
#define PI
Definition: l3_get_org.c:6
void get_rho_mumm(l2str *l2rec, int32_t ipix, int32_t iw, float *rhom)
Definition: mumm.c:25
#define RADEG
Definition: czcs_ctl_pt.c:5
float gamma
Definition: color_dtdb.py:447
int32_t nbands
void get_rhown_mumm(l2str *l2rec, int32_t ip, int32_t nir_s, int32_t nir_l, float rhown[])
Definition: mumm.c:74