6 static int wave_vc[] = {412, 443, 490, 510, 531, 555, 670};
8 static float Rrs_norm = 0.025;
9 static float ratio_531_norm = 2.;
12 static int firstCall = 1;
15 int ipb = ip * l2rec->l1rec->l1file->nbands;
16 static int iwave_nn[] = {412, 443, 490, 510, 555, 670};
17 float *
Rrs = &l2rec->Rrs[ipb];
19 float Rrs_vc = badval;
21 static struct fann *nntab;
25 char nnFile [FILENAME_MAX] =
"";
26 sprintf(nnFile,
"%s%s%d%s",
input->vcnnfile,
"_", wave_vc[4],
".dat");
27 nntab = fann_create_from_file(nnFile);
32 for (ib = 1; ib < 5; ib++) {
33 ipb = ip * l2rec->l1rec->l1file->nbands +
bindex_get(iwave_nn[ib]);
34 Rrs_in[ib - 1] = l2rec->Rrs[ipb] / Rrs_norm;
39 switch (wave_vc[ibvc]) {
53 Rrs_vc = (
float) *fann_run(nntab, Rrs_in) * ratio_531_norm *
Rrs[1];
67 static int firstCall = 1;
68 static int nband_nn = 7;
69 static int iwave_nn[] = {412, 443, 488, 531, 547, 667};
75 float Rrs_vc = badval;
77 if ((Rrs_in = (fann_type *) calloc(l2rec->l1rec->l1file->nbands, sizeof (fann_type))) ==
NULL) {
78 printf(
"-E- : Error allocating memory to Rrs_vc_modisa\n");
84 char nnFile [FILENAME_MAX] =
"";
85 for (ib = 0; ib < nband_nn; ib++) {
86 sprintf(nnFile,
"%s%s%d%s",
input->vcnnfile,
"_", wave_vc[ib],
".dat");
87 nntab[ib] = fann_create_from_file(nnFile);
93 for (ib = 0; ib < nband_nn - 1; ib++) {
94 ipb = ip * l2rec->l1rec->l1file->nbands +
bindex_get(iwave_nn[ib]);
95 Rrs_in[ib] = l2rec->Rrs[ipb] / Rrs_norm;
101 switch (wave_vc[ibvc]) {
108 Rrs_vc = (
float) *fann_run(nntab[ibvc], Rrs_in);
112 Rrs_vc = Rrs_in[3] / Rrs_in[1];
113 Rrs_vc *= (
float) *fann_run(nntab[ibvc], Rrs_in);
122 static int firstCall = 1;
123 static int nband_nn = 7;
124 static int iwave_nn[] = {412, 443, 488, 531, 547, 667};
130 float Rrs_vc = badval;
134 char nnFile [FILENAME_MAX] =
"";
135 for (ib = 0; ib < nband_nn; ib++) {
136 sprintf(nnFile,
"%s%s%d%s",
input->vcnnfile,
"_", wave_vc[ib],
".dat");
137 nntab[ib] = fann_create_from_file(nnFile);
141 if ((Rrs_in = (fann_type *) calloc(l2rec->l1rec->l1file->nbands, sizeof (fann_type))) ==
NULL) {
142 printf(
"-E- %s line %d : error allocating memory for Rrs_in in Rrs_vc_modist.\n",
148 for (ib = 0; ib < nband_nn - 1; ib++) {
149 ipb = ip * l2rec->l1rec->l1file->nbands +
bindex_get(iwave_nn[ib]);
150 Rrs_in[ib] = l2rec->Rrs[ipb] / Rrs_norm;
156 switch (wave_vc[ibvc]) {
163 Rrs_vc = (
float) *fann_run(nntab[ibvc], Rrs_in);
167 Rrs_vc = Rrs_in[3] / Rrs_in[1];
168 Rrs_vc *= (
float) *fann_run(nntab[ibvc], Rrs_in);
178 static int firstCall = 1;
179 static int nband_nn = 7;
180 static int iwave_nn[] = {410, 443, 486, 551, 671};
186 fann_type Rrs_531_in[4];
188 float Rrs_vc = badval;
192 char nnFile [FILENAME_MAX] =
"";
193 for (ib = 0; ib < nband_nn; ib++) {
194 sprintf(nnFile,
"%s%s%d%s",
input->vcnnfile,
"_", wave_vc[ib],
".dat");
195 nntab[ib] = fann_create_from_file(nnFile);
199 if ((Rrs_in = (fann_type *) calloc(l2rec->l1rec->l1file->nbands, sizeof (fann_type))) ==
NULL) {
200 printf(
"-E- %s line %d : error allocating memory for Rrs_in in Rrs_vc_modist.\n",
206 for (ib = 0; ib < nband_nn - 2; ib++) {
207 ipb = ip * l2rec->l1rec->l1file->nbands +
bindex_get(iwave_nn[ib]);
208 Rrs_in[ib] = l2rec->Rrs[ipb] / Rrs_norm;
209 if (ib > 0 && ib < 5)
210 Rrs_531_in[ib - 1] = l2rec->Rrs[ipb] / Rrs_norm;
215 switch (wave_vc[ibvc]) {
222 Rrs_vc = (
float) *fann_run(nntab[ibvc], Rrs_in) * Rrs_norm;
225 Rrs_vc = (
float) *fann_run(nntab[1], Rrs_in) * Rrs_norm;
226 Rrs_vc *= (
float) *fann_run(nntab[ibvc], Rrs_531_in) * ratio_531_norm;
234 switch (l2rec->l1rec->l1file->sensorID) {
253 printf(
"%s Line %d: VC Rrs conversion not defined for this sensor.\n", __FILE__, __LINE__);
260 static int firstCall = 1;
261 static float a[] = {0.2515, -2.3798, 1.5823, -0.6372, -0.5692};
267 float Rrs1, Rrs2, Rrs3;
281 minRrs =
MIN(Rrs1, Rrs2);
283 if (Rrs3 > 0.0 && Rrs2 > 0.0 && minRrs > -0.001) {
284 rat =
MAX(Rrs1, Rrs2) / Rrs3;
285 if (rat > minrat && rat < maxrat) {
287 chl = (
float) pow(10.0, (
a[0] + rat * (
a[1] + rat * (
a[2] + rat * (
a[3] + rat *
a[4])))));
288 chl = (chl > chlmin ? chl : chlmin);
289 chl = (chl < chlmax ? chl : chlmax);
297 int32_t prodnum =
p->cat_ix;
298 int32_t ibvc =
p->prod_ix;
304 for (ip = 0; ip < l2rec->l1rec->npix - 1; ip++) {
310 prod[ip] =
chl_vc(l2rec, ip);