OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
get_depth_classification.c
Go to the documentation of this file.
1 /* --------------------------------------------------------------- */
2 /* get_depth.c - water depth classification function for MSl12. */
3 /* */
4 /* Inputs: */
5 /* l2rec - level-2 structure containing one complete scan */
6 /* after atmospheric correction. */
7 /* Outputs: */
8 /* depth - water depth (m) */
9 /* */
10 /* Algorithm Provided By: R. A. Stumph, NOAA */
11 /* Written By: B. A. Franz, SAIC GSC, SIMBIOS Project, 9 July 1999 */
12 /* Updated: 29 July 2002, BAF */
13 /* */
14 /* --------------------------------------------------------------- */
15 
16 #include <stdlib.h>
17 #include <math.h>
18 #include "l12_proto.h"
19 
20 void get_depth_classification(l2str *l2rec, float depth[]) {
21  static float radeg = 3.141592654 / 180.;
22  static float *Fo;
23  static int firstCall = 1;
24 
25  int32_t ip, ipb;
26  int32_t ib, iib;
27  float mu0, mu;
28  float Rrs555;
29  float Rrs490;
30  float diff;
31 
32  l1str *l1rec = l2rec->l1rec;
33  int32_t nbands = l1rec->l1file->nbands;
34 
35  /* Need to reconstruct mean Fo or use nominal*/
36  if (firstCall) {
37  firstCall = 0;
38  if ((Fo = (float *) calloc(nbands, sizeof (float))) == NULL) {
39  printf("-E- : Error allocating memory to Fo in get_depth\n");
40  exit(FATAL_ERROR);
41  }
42 
43  for (ib = 0; ib < nbands; ib++) {
44  iib = l2rec->bindx[ib];
45  if (l1_input->outband_opt >= 2)
46  Fo[iib] = l1rec->l1file->Fonom[iib];
47  else
48  Fo[iib] = l1rec->l1file->Fobar[iib];
49  }
50  }
51 
52  for (ip = 0; ip < l1rec->npix; ip++) {
53 
54  ipb = nbands*ip;
55 
56  /* */
57  /* Is it land? */
58  /* We can't rely on the standard landmask, since reefs may */
59  /* get flagged as land if the navigation is off by a pixel.*/
60  /* Algorithm provided by F. S. Patt, SAIC GSC. */
61  /* */
62  mu0 = cos(l1rec->solz[ip] * radeg);
63  mu = cos(l1rec->senz[ip] * radeg);
64  diff = (l2rec->l1rec->Lt[ipb + 7] - 0.7 * l2rec->l1rec->Lt[ipb + 1]) / (1.0 + mu0 / mu);
65  if (diff > -1.5) {
66  depth[ip] = -1.0;
67  continue;
68  }
69 
70  /* */
71  /* Is it cloud, or other conditions which result in no */
72  /* Rrs retrieval? */
73  /* */
74  if (l2rec->nLw[ipb + 2] <= 0.0 || l2rec->nLw[ipb + 4] <= 0.0) {
75  depth[ip] = -2.0;
76  continue;
77  }
78 
79  Rrs490 = l2rec->nLw[ipb + 2] / Fo[2];
80  Rrs555 = l2rec->nLw[ipb + 4] / Fo[4];
81 
82  depth[ip] = 43.0 * (-0.95 + log(1000.0 * Rrs490) / log(1000.0 * Rrs555));
83  if (depth[ip] < 0.0) depth[ip] = 0.0;
84 
85  }
86 }
87 
88 
89 
90 /*
91 
92 SeaWiFS Corals. Here is the preliminary depth algorithm.
93 Replace the current depth algorithm with the following:
94 
95 Calculate the depth as:
96 depth = 0.43 * {-0.95 + ln[1000 Rrs(490)] / ln[1000 Rrs(555) }
97 
98 I am guessing that the coefficients of 1.4 and -0.95 are acceptable
99 for SeaWiFS.
100 
101 Use the same binning strategy.
102 Then
103 
104 shallow = NOT land and depth <=5 m
105 mod. shallow = 5- 10 m
106 mod. deep = 10-20 m
107 deep = 20-30 m
108 very deep = > 30 m
109 
110 The algorithm is insensitive to bottom cover.
111 
112  --rick
113 
114 _______________________________________________________________________
115 Richard P. Stumpf phone: 301-713-3028 x173
116 NOAA National Ocean Service fax: 301-713-4388
117 Center for Coastal Monitoring and Assessment
118 1305 East-West Highway, N/SCI1 rm 9115
119 Silver Spring, MD 20910 email:
120 richard.stumpf@noaa.gov
121 _______________________________________________________________________
122 
123  */
124 /*
125 From: richard.stumpf@noaa.gov
126 Date: Thu, 08 Jul 99 10:15:34 -0500
127 To: <gene>, <norman@tursiops>
128 Subject: SeaWiFS Coral Reef algorithm
129 
130 
131 Norm and Gene:
132 
133 Algorithm for using SeaWiFS to find potential coral reef environments.
134 We should keep in mind a paper in Eos or Oceanography and perhaps a RS journal.
135 
136 Settings are for 8 bit, all the information warranted at present.
137 If you prefer 16-bit output, set the intertidal, clouds, and land
138 to large numbers. I have tried to anticipate hypothetical future
139 improvements to the algorithm.
140 
141 Settings suggested color rgb
142 
143 0 = missing data black 0,0,0
144 5 = shallow water (<~5m) cyan 0,255,255
145 20 = medium water (~5m - ~20m) blue 0, 0, 255
146 100 = deep water purple 128,0, 128
147 
148 201 = intertidal not used yet
149 240 = clouds gray 200,200,200
150 250 = land dk.green 0,180,0
151 
152 For high pigment, either a similar color to corresponding shallow,
153  or the same color:
154 105 = pigmented bottom, shallow (prelim.) cyan/green 0,255,127 or 0,255,255
155 120 = pigmented bottom, mod. shallow (prelim.)dark cyan 0,127,127 or
156 0,255,255
157 
158 Here is the basic algorithm (in fake code form):
159 !------------------------------------------------------------------------------------
160 image = 0
161 if (Rrs(555) le 0.0035 and Rrs(555) gt 0.0)) then image = 100 !deep water
162 if (Rrs(555) gt 0.0035) then image = 20 !mod. shallow < ~20
163 m
164 if (Rrs(670) gt 0.0015) then image = 5 !shallow water < ~5
165 m
166 
167 
168 !At this 3-depth resolution, pigment should have a slight effect on the
169 results.
170 !The chlorophyll/pigment estimate inherently increases with shallowing water,
171 !with a bare sand bottom, this will reach a semi-analytical value of between
172 1.5
173 !and 2.0 ug/L. The settings for the pigmented bottom allow us to easily merge
174 !or separate from the non-pigmented bottom
175 
176 if (chl gt 1.5 and image gt 0) image = image+100 !allows easy management
177  !of rudimentary
178  !pigmented-bottom algorithm
179 
180 
181 ! use standard cloudmask, this will probably need to be changed if we need
182 ! to identify intertidal waters, as some pixels will flag out under both
183 ! the cloud mask and land mask.
184 
185 if (cloudmask) then image = 240 !if cloudmask is set change values
186 
187 ! land mask, note that this may nail some clouds,
188 ! it must be done after the cloud mask
189 ! In thinking about this, I believe that Rrs(670) will work, but See NOTE 1
190 below:
191 
192 if (Rrs(670) le 0.) then image = 250 ! land
193 
194 
195 !---------------------------------------------------------------------------------
196 
197 
198 NOTES:
199 1. For the landmask, the algorithm I have used for years for AVHRR and TM is:
200  Llm = (Lt(670) - Lr(670))/F0(670) - (Lt(865) - Lr(865))/F0(865)
201  if (Llm le 0) image = 250 !land
202  Using (Rrs(670) le 0) should give the same results.
203 
204 2. For compositing, take composite of all values
205 where(image gt 0 and image le 200).
206 Keep in mind that wind resuspension will be a problem, and could cause some
207 peculiar results. This is the best for now.
208 
209 My solution to resuspension has been to take averages, then find the minimum
210 value
211 of the averages. Taking minimum values of individual
212 scenes makes the result highly sensitive to one faulty scene. But if the
213 SeaWiFS
214 output is reliable enough, minimum non-cloud values will work.
215 
216 3. I have not resolved appropriate values to permit ready identification of
217 intertidal shallow water. The obvious method is to identify areas that shift
218 between
219 land and shallow water in different scenes. The problem is that the land mask
220 and
221 cloud mask do not discriminate well against each other. I will think about
222 this.
223 
224 Look forward to seeing some results.
225 --
226  --rick
227 _______________________________________________________________________________
228 Richard P. Stumpf phone: 301-713-3028 x173
229 NOAA National Ocean Service fax: 301-713-4388
230 Center for Coastal Monitoring and Assessment
231 1305 East-West Highway, N/SCI1 rm 9109
232 Silver Spring, MD 20910 email:
233  richard.stumpf@noaa.gov
234 _______________________________________________________________________________
235 
236 
237 
238 Subject:
239  Re: depth index, Florida test image
240  Date:
241  Wed, 14 Jul 99 13:36:42 -0500
242  From:
243  richard.stumpf@noaa.gov
244  To:
245  <franz>
246  CC:
247  <norman@tursiops>, <gene@tutuila>
248 
249 
250 
251 
252 Bryan:
253 
254 To compensate for the residual atmosphere, Rrs(555) > 0.004 will work.
255 
256 However, to compensate for the resuspension over west Florida, including the
257 entrainment of sediment into the Florida Current, Rrs(555) > 0.008, for < 20m.
258 This isn't too bad for most areas, but some of the Bahamas high chlorophyll areas
259 get flagged as deep water.
260 
261 That value will correspond to 20 m on the Florida shelf.
262 
263 This means that the shallow water value will also need to be boosted.
264 Rrs(555) is ok for shallow water, Rrs(555) > 0.015 would describe the shallow water
265 adequately for this scene, although over-compensating for the Bahamas Banks.
266 
267 (For shallow water with Rrs(670), my guess is to double the value to Rrs(670) > 0.003,
268 but we might as well use Rrs555 for this scene.)
269 
270 As a bonus, I put a gif version of the nautical chart for the region in.
271 Blue is <10 fathoms (almost 20m).
272 
273 orca.gsfc.nasa.gov/pub/incoming/chart_11013_1.gif
274 
275 
276 
277 
278 --
279  --rick
280 _______________________________________________________________________________
281 Richard P. Stumpf phone: 301-713-3028 x173
282 NOAA National Ocean Service fax: 301-713-4388
283 Center for Coastal Monitoring and Assessment
284 1305 East-West Highway, N/SCI1 rm 9109
285 Silver Spring, MD 20910 email:
286 richard.stumpf@noaa.gov
287 _______________________________________________________________________________
288 
289  */
#define NULL
Definition: decode_rs.h:63
read l1rec
float mu
void get_depth_classification(l2str *l2rec, float depth[])
l1_input_t * l1_input
Definition: l1_options.c:9
#define FATAL_ERROR
Definition: swl0_parms.h:5
subroutine diff(x, conec, n, dconecno, dn, dconecmk, units, u, inno, i, outno, o, input, deriv)
Definition: ffnet.f:205
int32_t nbands
float mu0