OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
out_band_corr.c
Go to the documentation of this file.
1 /*
2 
3  $Header$
4  $Log$
5 
6 
7 
8 From yeh@calval Tue Mar 19 16:04:26 1996
9 Received: from calval.gsfc.nasa.gov by manua.gsfc.nasa.gov via ESMTP (950911.SGI.8.6.12.PATCH825/931108.SGI.AUTO.ANONFTP)
10  for <frank@manua.gsfc.nasa.gov> id QAA24118; Tue, 19 Mar 1996 16:04:25 -0500
11 Received: by calval.gsfc.nasa.gov (950911.SGI.8.6.12.PATCH825/931108.SGI.AUTO.ANONFTP)
12  for frank@manua id QAA03350; Tue, 19 Mar 1996 16:04:24 -0500
13 From: yeh@calval (Eueng-nan Yeh)
14 Message-Id: <199603192104.QAA03350@calval.gsfc.nasa.gov>
15 Subject: out-of-band subroutine
16 To: frank
17 Date: Tue, 19 Mar 1996 16:04:18 -0500 (EST)
18 Reply-To: yeh@calval (Eueng-nan Yeh)
19 Organization: NASA/Goddard/Laboratory for Hydrospheric Processes/SeaWiFS
20 X-Mailer: ELM [version 2.4 PL0]
21 MIME-Version: 1.0
22 Content-Type: text/plain; charset=US-ASCII
23 Content-Length: 2794
24 Status: RO
25 
26  */
27 
28 
29 #include <stdio.h>
30 #define NBAND 8
31 #define NSAMPLE 1285
32 
33 
34 #ifdef __STDC__
35 int out_band_corr(float r[8][1285], float oxygen, int xsample)
36 #else
37 
38 int out_band_corr(r, oxygen, xsample)
39 /************************************************************2*******
40 /To perform out-of-band correction
41 /-------------------------------------------------------------
42 /Inputs:
43 / r float[8][1285] level-1 radiances (band 1 to 8) per line.
44 / oxygen float Oxygen correction factor; =1 if r(765nm) already
45 / corrected; =1.12 if not.
46 / xsample int Number of data points per line (max 1285).
47 /Outputs:
48 / r float[8][1285] Out-of-band corrected radiances per line.
49 / Return value=-1 for open data file failure; otherwise O.K.
50 /-------------------------------------------------------------
51 /
52 / Created by Eueng-nan Yeh GSC/SAIC 10/10/95
53 /
54 /%***********************************************************2******/
55 float r[NBAND][NSAMPLE];
56 float oxygen;
57 int xsample;
58 #endif /* __STDC__ */
59 {
60  int i, m, id = 1;
61 
62  float wl[9] = {412., 443., 490., 510., 555., 670., 765., 865., 965.};
63  /*Spectral response of band 8 divided into six components. */
64  float s[6] = {0.583, 0.829, 6.251, 13.533, 1013.592, 9.374};
65  float s5[3] = {5.261, 488.215, 7.475};
66  float s6[3] = {2.592, 491.802, 2.112};
67  /*Out of band ratio==within-band response/total response*/
68  float br[8] = {0.9943, 0.9949, 0.9930, 0.9934, 0.9734, 0.9856, 0.9844, 0.9417};
69  float x, ra, r5, r6, r8, r9, br5, br6, br8;
70  if (id == 1) { /*simple method */
71  ra = (wl[8] - wl[7]) / (wl[7] - wl[6]);
72  for (m = 0; m < xsample; m++) { /*process one line*/
73  r5 = r[4][m];
74  r6 = r[5][m];
75  r8 = r[7][m];
76  for (i = 0; i < 8; i++) r[i][m] *= br[i]; /*adjust 0-7 first */
77  r9 = r[7][m] + ra * (r[7][m] - oxygen * r[6][m]); /*r[6] for wl=765nm */
78  x = r[7][m] * s[4];
79  br8 = x / (r[0][m] * s[0] + r[3][m] * s[1] + r[4][m] * s[2]
80  + oxygen * r[6][m] * s[3] + x + r9 * s[5]);
81  r[7][m] = r8* br8;
82  x = r[5][m] * s6[1]; /* band 6*/
83  br6 = x / (r[2][m] * s6[0] + x + r[7][m] * s6[2]);
84  r[5][m] = r6*br6;
85  x = r[4][m] * s5[1]; /* band 5*/
86  br5 = x / (r[1][m] * s5[0] + x + r[5][m] * s5[2]);
87  r[4][m] = r5*br5;
88  }
89  }
90  return (0);
91 }
92 
93 #ifdef TEST_OOB
94 
95 void main() {
96  int i, j;
97  /* Typical SeaWiFS radiances TM 1 Table 1 or TM 22 Table 26. */
98  float rad[NBAND][NSAMPLE] = {
99  {9.10, 9.10, 9.10},
100  {8.41, 8.41, 8.41}
101  ,
102  {6.56, 6.56, 6.56},
103  {5.64, 5.64, 5.64}
104  ,
105  {4.57, 4.57, 4.57},
106  {2.46, 2.46, 2.46}
107  ,
108  {1.61, 1.61, 1.61},
109  {1.0, 1.0, 1.09}};
110  float r[NBAND][NSAMPLE], oxygen = 1.12; /*oxygen absorption correc. factor*/
111  float ra[NBAND];
112 
113  for (i = 0; i < 8; i++) printf("%7.5f ", rad[i][2]);
114  printf("\n");
115  for (i = 0; i < 8; i++) for (j = 0; j < 3; j++) r[i][j] = rad[i][j];
116  out_band_corr(r, oxygen, 3);
117  for (i = 0; i < 8; i++) printf("%7.5f ", r[i][2]);
118  printf("\n");
119  for (i = 0; i < 8; i++) ra[i] = r[i][2] / rad[i][2];
120  for (i = 0; i < 8; i++) printf("%7.5f ", ra[i]);
121  printf("\n\n");
122 
123  exit(0);
124 }
125 #endif /* TEST_OOB */
126 
127 /* Test Result
128 
129 From yeh@calval Tue Mar 19 16:09:54 1996
130 Received: from calval.gsfc.nasa.gov by manua.gsfc.nasa.gov via ESMTP (950911.SGI.8.6.12.PATCH825/931108.SGI.AUTO.ANONFTP)
131  for <frank@manua.gsfc.nasa.gov> id QAA24798; Tue, 19 Mar 1996 16:09:53 -0500
132 Received: by calval.gsfc.nasa.gov (950911.SGI.8.6.12.PATCH825/931108.SGI.AUTO.ANONFTP)
133  for frank@manua id QAA04098; Tue, 19 Mar 1996 16:09:52 -0500
134 From: yeh@calval (Eueng-nan Yeh)
135 Message-Id: <199603192109.QAA04098@calval.gsfc.nasa.gov>
136 Subject: out-of-band result
137 To: frank
138 Date: Tue, 19 Mar 1996 16:09:47 -0500 (EST)
139 Reply-To: yeh@calval (Eueng-nan Yeh)
140 Organization: NASA/Goddard/Laboratory for Hydrospheric Processes/SeaWiFS
141 X-Mailer: ELM [version 2.4 PL0]
142 MIME-Version: 1.0
143 Content-Type: text/plain; charset=US-ASCII
144 Content-Length: 220
145 Status: RO
146 
147 9.10000 8.41000 6.56000 5.64000 4.57000 2.46000 1.61000 1.09000
148 9.04813 8.36711 6.51408 5.60278 4.44292 2.42131 1.58488 1.02651
149 0.99430 0.99490 0.99300 0.99340 0.97219 0.98427 0.98440 0.94175
150 
151  */
int r
Definition: decode_rs.h:73
int j
Definition: decode_rs.h:73
#define NSAMPLE
Definition: out_band_corr.c:31
int out_band_corr(r, float oxygen, int xsample)
Definition: out_band_corr.c:38
#define NBAND
Definition: out_band_corr.c:30
int main(int argc, char *argv[])
Definition: afrt_nc4.cpp:30
data_t s[NROOTS]
Definition: decode_rs.h:75
int i
Definition: decode_rs.h:71