ocssw V2020
get_poc.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <math.h>
3 #include "l12_proto.h"
4 
5 static float badval = BAD_FLT;
6 static float minval = 0.0;
7 static float maxval = 10.0 * 1000;
8 
9 float poc_stramski_443(float *Rrs, float *wave) {
10  static int firstCall = 1;
11  static float a = 203.2;
12  static float b = -1.034;
13  static int ib1 = -1;
14  static int ib2 = -1;
15 
16  float poc = badval;
17  float Rrs1 = 0.0;
18  float Rrs2 = 0.0;
19 
20  if (firstCall) {
21  firstCall = 0;
22  ib1 = bindex_get(443);
23  ib2 = bindex_get(545);
24  if (ib2 < 0) ib2 = bindex_get(550);
25  if (ib2 < 0) ib2 = bindex_get(555);
26  if (ib2 < 0) ib2 = bindex_get(560);
27  if (ib1 < 0 || ib2 < 0) {
28  printf("-E- %s line %d: required bands not available for Stramski POC\n",
29  __FILE__, __LINE__);
30  exit(1);
31  }
32  }
33 
34  Rrs1 = Rrs[ib1];
35  Rrs2 = Rrs[ib2];
36 
37  if (Rrs1 >= 0.0 && Rrs2 > 0.0) {
38  Rrs2 = conv_rrs_to_555(Rrs2, wave[ib2]);
39  poc = a * pow(Rrs1 / Rrs2, b);
40  }
41 
42  return (poc);
43 }
44 
45 float poc_stramski_490(float *Rrs, float *wave) {
46  static int firstCall = 1;
47  static float a = 308.3;
48  static float b = -1.639;
49  static int ib1 = -1;
50  static int ib2 = -1;
51 
52  float poc = badval;
53  float Rrs1 = 0.0;
54  float Rrs2 = 0.0;
55 
56  if (firstCall) {
57  firstCall = 0;
58  ib1 = bindex_get(490);
59  ib2 = bindex_get(545);
60  if (ib2 < 0) ib2 = bindex_get(550);
61  if (ib2 < 0) ib2 = bindex_get(555);
62  if (ib2 < 0) ib2 = bindex_get(560);
63  if (ib1 < 0 || ib2 < 0) {
64  printf("-E- %s line %d: required bands not available for Stramski POC\n",
65  __FILE__, __LINE__);
66  exit(1);
67  }
68  }
69 
70  Rrs1 = Rrs[ib1];
71  Rrs2 = Rrs[ib2];
72 
73  if (Rrs1 >= 0.0 && Rrs2 > 0.0) {
74  Rrs2 = conv_rrs_to_555(Rrs2, wave[ib2]);
75  poc = a * pow(Rrs1 / Rrs2, b);
76  }
77 
78  return (poc);
79 }
80 
81 void get_poc(l2str *l2rec, int prodnum, float prod[]) {
82  int32_t ip;
83  l1str *l1rec = l2rec->l1rec;
84  int32_t nbands = l1rec->l1file->nbands;
85 
86  for (ip = 0; ip < l1rec->npix; ip++) {
87 
88  prod[ip] = badval;
89 
90  switch (prodnum) {
91 
93  prod[ip] = poc_stramski_443(&l2rec->Rrs[ip * nbands], l1rec->l1file->fwave);
94  break;
95 
97  prod[ip] = poc_stramski_490(&l2rec->Rrs[ip * nbands], l1rec->l1file->fwave);
98  break;
99 
100  default:
101  printf("Error: %s : Unknown product specifier: %d\n", __FILE__, prodnum);
102  exit(1);
103  break;
104  };
105 
106  if (prod[ip] == badval)
107  l1rec->flags[ip] |= PRODFAIL;
108  else if (prod[ip] < minval || prod[ip] > maxval)
109  l1rec->flags[ip] |= PRODWARN;
110 
111  }
112 
113 }
114 
#define CAT_poc_stramski_443
Definition: l2prod.h:175
#define CAT_poc_stramski_490
Definition: l2prod.h:176
read l1rec
#define PRODWARN
Definition: l2_flags.h:11
#define PRODFAIL
Definition: l2_flags.h:39
int bindex_get(int32_t wave)
Definition: windex.c:43
#define BAD_FLT
Definition: jplaeriallib.h:19
void get_poc(l2str *l2rec, int prodnum, float prod[])
Definition: get_poc.c:81
float poc_stramski_443(float *Rrs, float *wave)
Definition: get_poc.c:9
float poc_stramski_490(float *Rrs, float *wave)
Definition: get_poc.c:45
data_t b[NROOTS+1]
Definition: decode_rs.h:77
int32_t nbands
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 conv_rrs_to_555(float Rrs, float wave)
Definition: convert_band.c:17