OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
turbid.c
Go to the documentation of this file.
1 #include "l12_proto.h"
2 #define TI_BAD -999.
3 
4 void tindx_shi(l2str *l2rec, int32_t ipix, float *tindx) {
5  static int32_t mask = LAND | CLOUD;
6 
7  static int32_t ib748 = -1;
8  static int32_t ib1240 = -1;
9  static int32_t ib2130 = -1;
10 
11  float dr748;
12  float dr1240;
13  float dr2130;
14 
15  int32_t ip, ip1, ip2, ipb;
16 
17  l1str *l1rec = l2rec->l1rec;
18  filehandle *l1file = l1rec->l1file;
19  int32_t nbands = l1file->nbands;
20 
21  if (ipix < 0) {
22  ip1 = 0;
23  ip2 = l1rec->npix - 1;
24  } else {
25  ip1 = ipix;
26  ip2 = ipix;
27  }
28 
29  if (ib748 == -1) {
30  if ((ib748 = windex(748.0, l1file->fwave, nbands)) < 0) {
31  printf("tindx_shi: incompatible sensor wavelengths (no 748).\n");
32  exit(1);
33  }
34  if ((ib1240 = windex(1240.0, l1file->fwave, nbands)) < 0) {
35  printf("tindx_shi: incompatible sensor wavelengths (no 1240).\n");
36  exit(1);
37  }
38  if ((ib2130 = windex(2130.0, l1file->fwave, nbands)) < 0) {
39  printf("tindx_shi: incompatible sensor wavelengths (no 2130).\n");
40  exit(1);
41  }
42  }
43 
44  for (ip = ip1; ip <= ip2; ip++) {
45 
46  ipb = ip * nbands + ib748;
47  dr748 = (l1rec->Lt[ipb] / l1rec->tg_sol[ipb] / l1rec->tg_sen[ipb] - l1rec->Lr[ipb]) / l1file->Fobar[ib748 ];
48 
49  ipb = ip * nbands + ib1240;
50  dr1240 = (l1rec->Lt[ipb] / l1rec->tg_sol[ipb] / l1rec->tg_sen[ipb] - l1rec->Lr[ipb]) / l1file->Fobar[ib1240];
51 
52  ipb = ip * nbands + ib2130;
53  dr2130 = (l1rec->Lt[ipb] / l1rec->tg_sol[ipb] / l1rec->tg_sen[ipb] - l1rec->Lr[ipb]) / l1file->Fobar[ib2130];
54 
55  if (((l1rec->flags[ip] & mask) != 0) || dr1240 <= 0.0 || dr2130 <= 0.0)
56  *tindx++ = TI_BAD;
57  else
58  /* *tindx++ = (dr748/dr1240)*exp(-(492./890.)*log(dr1240/dr2130)); */
59  *tindx++ = (dr748 / dr1240) * pow((dr1240 / dr2130), -(492. / 890.));
60  }
61 
62  return;
63 }
64 
65 void tindx_morel(l2str *l2rec, int32_t ipix, float *tindx) {
66  static int32_t ib560 = -1;
67 
68  float chl;
69  float Rrs;
70  float Rrs_lim;
71  float X;
72  int32_t ip, ip1, ip2;
73 
74  l1str *l1rec = l2rec->l1rec;
75  filehandle *l1file = l1rec->l1file;
76  int32_t nbands = l1file->nbands;
77 
78  if (ipix < 0) {
79  ip1 = 0;
80  ip2 = l1rec->npix - 1;
81  } else {
82  ip1 = ipix;
83  ip2 = ipix;
84  }
85 
86  if (ib560 == -1) {
87  if ((ib560 = windex(560.0, l1file->fwave, nbands)) < 0) {
88  printf("turbid_morel: incompatible sensor wavelengths (no 560).\n");
89  exit(1);
90  }
91  printf("turbid_morel: using %f nm for 560.\n", l1file->fwave[ib560]);
92  }
93 
94  for (ip = ip1; ip <= ip2; ip++) {
95 
96  chl = l2rec->chl[ip];
97  Rrs = l2rec->Rrs[ip * nbands + ib560];
98 
99  if (l1rec->mask[ip] || chl <= 0.0 || Rrs <= 0.0) {
100  *tindx++ = TI_BAD;
101  l1rec->flags[ip] |= PRODFAIL;
102  } else if (chl <= 0.2) {
103  *tindx++ = -100;
104  } else {
105  X = log10(MIN(chl, 10));
106  Rrs_lim = 0.00331 + X * (0.002122 + X * (0.00031587 - X * 0.00023145));
107  *tindx++ = 100.0 * (Rrs - Rrs_lim) / Rrs;
108  }
109  }
110 
111  return;
112 }
113 
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
Definition: l1stat_chk.c:586
#define TI_BAD
Definition: turbid.c:2
#define MIN(x, y)
Definition: rice.h:169
read l1rec
#define PRODFAIL
Definition: l2_flags.h:41
character(len=1000) if
Definition: names.f90:13
a context in which it is NOT documented to do so subscript which cannot be easily calculated when extracting TONS attitude data from the Terra L0 files Corrected several defects in extraction of entrained ephemeris and and as HDF file for both the L1A and Geolocation enabling retrieval of South Polar DEM data Resolved Bug by changing to opent the geolocation file only after a successful read of the L1A and also by checking for fatal errors from not restoring C5 and to report how many of those high resolution values were water in the new WaterPresent SDS Added valid_range attribute to Land SeaMask Changed to bilinearly interpolate the geoid_height to remove artifacts at one degree lines Made corrections to const qualification of pointers allowed by new version of M API library Removed casts that are no longer for same not the geoid Corrected off by one error in calculation of high resolution offsets Corrected parsing of maneuver list configuration parameter Corrected to set Height SDS to fill values when geolocation when for elevation and land water mask
Definition: HISTORY.txt:114
#define CLOUD
Definition: l2_flags.h:20
#define LAND
Definition: l2_flags.h:12
void tindx_morel(l2str *l2rec, int32_t ipix, float *tindx)
Definition: turbid.c:65
int32_t nbands
int windex(float wave, float twave[], int ntwave)
Definition: windex.c:73
void tindx_shi(l2str *l2rec, int32_t ipix, float *tindx)
Definition: turbid.c:4