OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
get_rhown_nir.c
Go to the documentation of this file.
1 #include "l12_proto.h"
2 
3 
4 /* ---------------------------------------------------------------------- */
5 /* Convert Rrs[0+] to Rrs[0-] */
6 
7 /* ---------------------------------------------------------------------- */
8 float above_to_below(float Rrs) {
9  return (Rrs / (0.52 + 1.7 * Rrs));
10 }
11 
12 /* ---------------------------------------------------------------------- */
13 /* Convert Rrs[0-] to Rrs[0+] */
14 
15 /* ---------------------------------------------------------------------- */
16 float below_to_above(float Rrs) {
17  return (Rrs * 0.52 / (1 - 1.7 * Rrs));
18 }
19 
20 /* ------------------------------------------------------------------- */
21 /* Description: */
22 /* This computes the normalized water-leaving reflectances */
23 /* at the CZCS 670 channel. */
24 /* */
25 /* Outputs: */
26 /* rhown(670) */
27 /* */
28 /* Algorithm Author: */
29 /* Sean Bailey, Futuretech Corporation */
30 /* based largely on the work of R. Arnone and R. Stumpf */
31 /* using eta relationship from Z. Lee */
32 
33 /* ------------------------------------------------------------------- */
34 
35 void rhown_red(char *fqfile, float chl, float aw[], float bbw[], float Rrs[],
36  float wave[], int32_t nwave, int32_t ib_red, float rhown[]) {
37  static int firstCall = 1;
38  static int32_t ib5;
39  static float eta = 0.5;
40  float static chl_min = 0.2;
41  float static chl_max = 30.;
42 
43  float aw_red, apg_red, bb5;
44  float a, bb, chl_in;
45  float salbedo;
46  float Rrs_red;
47  float Rrs5;
48  float foq[nwave];
49 
50  if (firstCall) {
51  ib5 = windex(555, wave, nwave);
52  if (fabs(555 - wave[ib5]) > 15) {
53  printf("%s line %d: can't find reasonable green band\n", __FILE__, __LINE__);
54  printf("looking for 555, found %f\n", wave[ib5]);
55  exit(EXIT_FAILURE);
56  }
57 
58  firstCall = 0;
59  }
60 
61  chl_in = MAX(MIN(chl, chl_max), chl_min);
62 
63  aw_red = aw [ib_red];
64 
65  Rrs5 = Rrs[ib5];
66 
67  if (Rrs5 <= 0.0)
68  Rrs5 = 0.001;
69 
70  foqint_morel(fqfile, wave, nwave, 0.0, 0.0, 0.0, chl_in, foq);
71 
72  /* Compute total absorption at 670 */
73  // NOMAD fit of apg670 to chl
74  apg_red = exp(log(chl) * 0.9389 - 3.7589);
75  apg_red = MIN(MAX(apg_red, 0.0), 0.5);
76  a = aw_red + apg_red;
77 
78  /* Compute backscatter at 550 from Carder/Lee */
79  //bb5 = (-0.00182 + 2.058*Rrs5 + bbw5);
80  bb5 = (-0.00182 + 2.058 * Rrs5);
81 
82  /* Translate bb to NIR wavelength */
83  bb = bb5 * pow((wave[ib5] / wave[ib_red]), eta) + bbw[ib_red];
84 
85  /* Remote-sensing reflectance */
86  salbedo = bb / (a + bb);
87  Rrs_red = foq[ib_red] * salbedo;
88  /* Normalized water-leaving reflectance */
89  Rrs_red = below_to_above(Rrs_red);
90  rhown[ib_red] = PI*Rrs_red;
91 }
92 
93 
94 
95 /* ------------------------------------------------------------------- */
96 /* Description: */
97 /* This computes the normalized water-leaving reflectances */
98 /* for NIR bands using a bio-optical model and assuming that the */
99 /* NIR absorption is due to the water only. */
100 /* */
101 /* Algorithm Author: */
102 /* Sean Bailey, Futuretech Corporation */
103 /* based largely on the work of R. Arnone and R. Stumpf */
104 /* using eta relationship from Z. Lee */
105 
106 /* ------------------------------------------------------------------- */
107 
108 void rhown_nir(char *fqfile, float chl, float aw[], float bbw[], float Rrs[], float wave[],
109  int32_t nwave, float solz, float senz, float phi,
110  int32_t nir_s, int32_t nir_l, float rhown[]) {
111  static int firstCall = 1;
112  static int32_t ib2;
113  static int32_t ib5;
114  static int32_t ib6;
115 
116  float a6, aw6, apg6, bbp6;
117  float a, bb, eta;
118  float static chl_min = 0.2;
119  float static chl_max = 30.;
120  float foq[nwave];
121  float salbedo;
122  float Rrs_nir;
123  float Rrs2, Rrs5, Rrs6, Rrs6_star;
124  int32_t ib;
125  int32_t dnir = MAX(nir_l - nir_s, 1);
126 
127  if (firstCall) {
128  ib6 = windex(670, wave, nwave);
129  if (fabs(670 - wave[ib6]) > 50) {
130  printf("%s line %d: can't find reasonable red band\n", __FILE__, __LINE__);
131  printf("looking for 670, found %f\n", wave[ib6]);
132  exit(EXIT_FAILURE);
133  }
134 
135  ib5 = windex(555, wave, nwave);
136  if (fabs(555 - wave[ib5]) > 15) {
137  printf("%s line %d: can't find reasonable green band\n", __FILE__, __LINE__);
138  printf("looking for 555, found %f\n", wave[ib5]);
139  exit(EXIT_FAILURE);
140  }
141  ib2 = windex(443, wave, nwave);
142  if (fabs(443 - wave[ib2]) > 5) {
143  printf("%s line %d: can't find reasonable blue band\n", __FILE__, __LINE__);
144  printf("looking for 443, found %f\n", wave[ib2]);
145  exit(EXIT_FAILURE);
146  }
147  firstCall = 0;
148  }
149 
150  Rrs2 = Rrs[ib2];
151  Rrs5 = Rrs[ib5];
152  Rrs6 = Rrs[ib6];
153 
154  if (Rrs6 <= 0.0) {
155  for (ib = nir_s; ib <= nir_l; ib += dnir)
156  rhown[ib] = 0.0;
157  return;
158  }
159 
160  chl = MAX(MIN(chl, chl_max), chl_min);
161 
162  // NOMAD fit of apg670 to chl
163  apg6 = exp(log(chl) * 0.9389 - 3.7589);
164  apg6 = MIN(MAX(apg6, 0.0), 0.5);
165 
166  /* Compute total absorption at 670 */
167  aw6 = aw [ib6];
168  a6 = aw6 + apg6;
169 
170  /* Go below... */
171  Rrs2 = above_to_below(Rrs2);
172  Rrs5 = above_to_below(Rrs5);
173  Rrs6 = above_to_below(Rrs6);
174 
175  //foqint_morel(wave,nwave,0.0,0.0,0.0,chl_in,foq);
176  foqint_morel(fqfile, wave, nwave, solz, senz, phi, chl, foq);
177 
178  /* Compute the backscatter slope ala Lee */
179  eta = 0.0;
180  if (Rrs5 > 0.0 && Rrs2 > 0.0) {
181  eta = 2.0 * (1. - 1.2 * exp(-0.9 * (Rrs2 / Rrs5)));
182  eta = MIN(MAX(eta, 0.0), 1.0);
183  }
184 
185  /* Compute total backscatter at 670 */
186  Rrs6_star = Rrs6 / foq[ib6];
187  bbp6 = (Rrs6_star * a6 / (1. - Rrs6_star)) - bbw[ib6];
188 
189  /* Compute normalized water-leaving reflectance at each NIR wavelength */
190  for (ib = nir_s; ib <= nir_l; ib += dnir) {
191 
192  if (ib == ib6)
193  a = a6;
194  else
195  a = aw[ib];
196 
197  /* Translate bb to NIR wavelength */
198  bb = bbp6 * pow((wave[ib6] / wave[ib]), eta) + bbw[ib];
199 
200  /* Remote-sensing reflectance */
201  salbedo = bb / (a + bb);
202  Rrs_nir = foq[ib6] * salbedo;
203  /* Normalized water-leaving reflectance */
204  Rrs_nir = below_to_above(Rrs_nir);
205  rhown[ib] = PI*Rrs_nir;
206  }
207 }
208 
209 
210 /* ------------------------------------------------------------------- */
211 /* get_rhown_nir(): calls the appropriate function to compute the */
212 /* normalized water-leaving reflectance contribution in the NIR */
213 /* */
214 /* B.A. Franz, OBPG 25 January 2006 */
215 
216 /* ------------------------------------------------------------------- */
217 
218 void get_rhown_eval(char *fqfile, float Rrs[], float wave[], int32_t nir_s, int32_t nir_l,
219  int32_t nwave, float aw[], float bbw[], float chl,
220  float solz, float senz, float phi, float rhown[]) {
221 
222  if (wave[nir_l] < MAXWAVE_VIS) {
223  rhown_red(fqfile, chl, aw, bbw, Rrs, wave, nwave, nir_l, rhown);
224  } else {
225  rhown_nir(fqfile, chl, aw, bbw, Rrs, wave, nwave, solz, senz, phi, nir_s, nir_l, rhown);
226  }
227 
228  return;
229 }
230 
#define MAX(A, B)
Definition: swl0_utils.h:26
#define MIN(x, y)
Definition: rice.h:169
#define PI
Definition: l3_get_org.c:6
#define MAXWAVE_VIS
Definition: sensorDefs.h:51
void rhown_red(char *fqfile, float chl, float aw[], float bbw[], float Rrs[], float wave[], int32_t nwave, int32_t ib_red, float rhown[])
Definition: get_rhown_nir.c:35
float above_to_below(float Rrs)
Definition: get_rhown_nir.c:8
void foqint_morel(char *file, float wave[], int32_t nwave, float solz, float senzp, float phi, float chl, float brdf[])
Definition: brdf.c:314
void get_rhown_eval(char *fqfile, float Rrs[], float wave[], int32_t nir_s, int32_t nir_l, int32_t nwave, float aw[], float bbw[], float chl, float solz, float senz, float phi, float rhown[])
#define fabs(a)
Definition: misc.h:93
int windex(float wave, float twave[], int ntwave)
Definition: windex.c:73
void rhown_nir(char *fqfile, float chl, float aw[], float bbw[], float Rrs[], float wave[], int32_t nwave, float solz, float senz, float phi, int32_t nir_s, int32_t nir_l, float rhown[])
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424
float below_to_above(float Rrs)
Definition: get_rhown_nir.c:16