26 static int32 evalmask = 0;
49 #define NDIFFMAXv6v3 4
60 #define NDIFFMAXv6m4 4
137 static ssestabstrv6v sses_sstv6v;
138 static ssestabstrv6v3 sses_sst3v6v3;
186 static ssestabstrv6m sses_sstv6m;
187 static ssestabstrv6m4 sses_sst4v6m;
211 static ssestabstrv6a sses_sstv6a;
215 static s_array *sstq, *sst4q, *sst3q;
219 static float *treesum =
NULL;
223 static int8 *qual_sst =
NULL;
224 static int8 *qual_sst4 =
NULL;
225 static int8 *qual_sst3 =
NULL;
226 static float *bias_sst =
NULL;
227 static float *bias_sst4 =
NULL;
228 static float *bias_sst3 =
NULL;
229 static float *stdv_sst =
NULL;
230 static float *stdv_sst4 =
NULL;
231 static float *stdv_sst3 =
NULL;
232 static float *bias_mean_sst =
NULL;
233 static float *bias_mean_sst4 =
NULL;
234 static float *bias_mean_sst3 =
NULL;
238 static float *dsdi_correction =
NULL;
240 static float *d3940ref =
NULL;
243 static float *LtRED_maxmin =
NULL;
244 static float *Bt11_maxmin =
NULL;
245 static float *Bt11_max =
NULL;
246 static float *Bt11_min =
NULL;
247 static float *Bt11_stdev =
NULL;
248 static float *Bt12_maxmin =
NULL;
249 static float *Bt12_min =
NULL;
250 static float *Bt37_maxmin =
NULL;
251 static float *Bt37_stdev =
NULL;
252 static float *Bt39_maxmin =
NULL;
253 static float *Bt40_maxmin =
NULL;
255 static float *Bt40_stdev =
NULL;
256 static float *Bt85_min =
NULL;
257 static float *Bt73_max =
NULL;
258 static float *rhoCirrus_maxmin =
NULL;
259 static float *rhoCirrus_min =
NULL;
260 static float *rhoCirrus_max =
NULL;
261 static float *rhotRED_maxmin =
NULL;
262 static float *rhotRED_min =
NULL;
263 static float *rhotRED_max =
NULL;
264 static float *rhotNIR7_min =
NULL;
265 static float *rhot16_min =
NULL;
266 static float *rhotRED =
NULL;
267 static float *rhotNIR7 =
NULL;
268 static float *rhot16 =
NULL;
269 static float *sst_stdev =
NULL;
272 static int32_t recnumSST = -1;
273 static int haveSST4 = 0;
274 static int haveSST = 0;
275 static int haveSSES = 1;
276 static int haveRed = 0;
277 static int ib07 = -1;
278 static int ib08 = -1;
279 static int ib16 = -1;
280 static int ib37 = -1;
281 static int ib39 = -1;
282 static int ib40 = -1;
283 static int ib67 = -1;
284 static int ib73 = -1;
285 static int ib85 = -1;
286 static int ib11 = -1;
287 static int ib12 = -1;
288 static int ibred = -1;
289 static int nbvis = -1;
290 static int nbir = -1;
295 static int fullscanpix = 1354;
296 static int32_t cldbox = 3;
297 static int32_t cldboxv = 5;
298 static int sstboxcscan = -1;
299 static float cldthresh = 0.01;
300 static float cldthreshv = 0.04;
302 static int32_t btbox = 3;
306 static int32_t btboxv = 5;
307 static int32_t csstbox = -1;
308 static float hisenz = 55.0;
309 static float hisenza = 45.0;
310 static float vhisenz = 75.0;
311 static float vhisenza = 55.0;
312 static float vhisenzv2 = 65.0;
314 static float Btmin = -4.0;
315 static float Btmina = -10.0;
317 static float Btmax = 37.0;
318 static float Btmaxa = 37.0;
320 static float Btmax40 = 35.0;
322 static float SSTmin = -1.8;
323 static float SSTmax = 40.0;
324 static float SSTmaxa = 40.0;
325 static float SSTmaxn = 37.0;
326 static float glintmax = 0.005;
327 static float dBtmin = 0.0;
328 static float dBtmax = 3.6;
329 static float dBt4min = 0.0;
330 static float dBt4max = 8.0;
331 static float SSTdiffa = 2.0;
332 static float SSTdiff = 3.0;
341 static float SSTvdiff = 5.0;
342 static float SST4diff1 = -0.8;
343 static float SST4diff2 = -1.0;
344 static float SST3diff1 = 0.8;
345 static float SST3diff2 = 1.0;
347 static float Bt11unif1 = 0.7;
348 static float Bt12unif1 = 0.7;
349 static float Bt11unif2 = 1.2;
350 static float Bt12unif2 = 1.2;
351 static float Bt37unif1 = 0.7;
352 static float Bt37unif2 = 1.2;
353 static float Bt39unif1 = 0.7;
354 static float Bt40unif1 = 0.7;
355 static float Bt39unif2 = 1.2;
356 static float Bt40unif2 = 1.2;
357 static float dBtrefmin = -1.1;
358 static float dBtrefmax = 10.0;
360 static float equatorialNorth = 30.0;
361 static float equatorialSouth = -10.0;
362 static float equatorialWest = -105.0;
363 static float equatorialEast = 105.0;
368 static float latwin = 2.5;
370 static int32 tmonth = -1;
372 static int StartOfMonth[2][12] = {
373 { 0, 31, 59, 90, 120, 151, 181, 212, 243,
375 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}
384 float btrefdiffv6(int32_t ip,
float BT39,
float BT40, l2str *l2rec) {
396 satzdir = (l2rec->l1rec->pixnum[ip] < fullscanpix / 2) ? -1.0 : 1.0;
397 senz = l2rec->l1rec->senz[ip] * satzdir;
399 diff = BT39 - BT40 - tref;
418 char name[H4_MAX_NC_NAME] =
"";
419 char sdsname[H4_MAX_NC_NAME] =
"";
423 if (strcmp(
file,
"") == 0) {
424 printf(
"\nNo SSES data provided for this sensor.\n");
429 printf(
"\nLoading SSES table from %s\n",
file);
432 sd_id = SDstart(
file, DFACC_RDONLY);
434 printf(
"-E- %s line %d: Error opening file %s.\n", __FILE__, __LINE__,
442 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
446 "-E- %s line %d: Table dimensions for %s do not match expectation. got: %d expected %d\n",
455 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
456 __FILE__, __LINE__, sdsname);
461 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
462 __LINE__, sdsname,
file);
465 status = SDendaccess(sds_id);
468 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
472 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
473 __FILE__, __LINE__, sdsname);
481 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
482 __FILE__, __LINE__, sdsname);
487 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
488 __LINE__, sdsname,
file);
491 status = SDendaccess(sds_id);
495 strcpy(sdsname,
"bias_mean");
496 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
500 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
501 __FILE__, __LINE__, sdsname);
509 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
510 __FILE__, __LINE__, sdsname);
515 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
516 __LINE__, sdsname,
file);
519 status = SDendaccess(sds_id);
521 strcpy(sdsname,
"counts");
522 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
526 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
527 __FILE__, __LINE__, sdsname);
535 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
536 __FILE__, __LINE__, sdsname);
541 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
542 __LINE__, sdsname,
file);
545 status = SDendaccess(sds_id);
548 sses->nqual = dims[0];
549 sses->nlat = dims[1];
550 sses->ndiff = dims[2];
551 sses->nsenz = dims[3];
552 sses->nquar = dims[4];
553 sses->nday = dims[5];
554 sses->nsst = dims[6];
559 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
563 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
564 __LINE__, sdsname,
file);
567 status = SDendaccess(sds_id);
568 sses->nsst = dims[0];
571 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
575 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
576 __LINE__, sdsname,
file);
579 status = SDendaccess(sds_id);
580 sses->nsenz = dims[0];
582 strcpy(sdsname,
"BTdiff");
583 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
587 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
588 __LINE__, sdsname,
file);
591 status = SDendaccess(sds_id);
592 sses->ndiff = dims[0];
595 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
599 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
600 __LINE__, sdsname,
file);
603 status = SDendaccess(sds_id);
604 sses->nlat = dims[0];
624 char name[H4_MAX_NC_NAME] =
"";
625 char sdsname[H4_MAX_NC_NAME] =
"";
629 if (strcmp(
file,
"") == 0) {
630 printf(
"\nNo SSES data provided for this sensor.\n");
635 printf(
"\nLoading SSES table from %s\n",
file);
638 sd_id = SDstart(
file, DFACC_RDONLY);
640 printf(
"-E- %s line %d: Error opening file %s.\n", __FILE__, __LINE__,
648 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
652 "-E- %s line %d: Table dimensions for %s do not match expectation. got: %d expected %d\n",
661 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
662 __FILE__, __LINE__, sdsname);
667 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
668 __LINE__, sdsname,
file);
671 status = SDendaccess(sds_id);
674 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
678 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
679 __FILE__, __LINE__, sdsname);
687 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
688 __FILE__, __LINE__, sdsname);
693 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
694 __LINE__, sdsname,
file);
697 status = SDendaccess(sds_id);
701 strcpy(sdsname,
"bias_mean");
702 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
706 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
707 __FILE__, __LINE__, sdsname);
715 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
716 __FILE__, __LINE__, sdsname);
721 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
722 __LINE__, sdsname,
file);
725 status = SDendaccess(sds_id);
727 strcpy(sdsname,
"counts");
728 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
732 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
733 __FILE__, __LINE__, sdsname);
741 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
742 __FILE__, __LINE__, sdsname);
747 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
748 __LINE__, sdsname,
file);
751 status = SDendaccess(sds_id);
754 sses->nqual = dims[0];
755 sses->nlat = dims[1];
756 sses->ndiff = dims[2];
757 sses->nsenz = dims[3];
758 sses->nquar = dims[4];
759 sses->nday = dims[5];
760 sses->nsst = dims[6];
765 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
769 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
770 __LINE__, sdsname,
file);
773 status = SDendaccess(sds_id);
774 sses->nsst = dims[0];
777 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
781 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
782 __LINE__, sdsname,
file);
785 status = SDendaccess(sds_id);
786 sses->nsenz = dims[0];
788 strcpy(sdsname,
"BTdiff");
789 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
793 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
794 __LINE__, sdsname,
file);
797 status = SDendaccess(sds_id);
798 sses->ndiff = dims[0];
801 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
805 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
806 __LINE__, sdsname,
file);
809 status = SDendaccess(sds_id);
810 sses->nlat = dims[0];
830 char name[H4_MAX_NC_NAME] =
"";
831 char sdsname[H4_MAX_NC_NAME] =
"";
835 if (strcmp(
file,
"") == 0) {
836 printf(
"\nNo SSES data provided for this sensor.\n");
841 printf(
"\nLoading SSES table from %s\n",
file);
844 sd_id = SDstart(
file, DFACC_RDONLY);
846 printf(
"-E- %s line %d: Error opening file %s.\n", __FILE__, __LINE__,
854 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
858 "-E- %s line %d: Table dimensions for %s do not match expectation. got: %d expected %d\n",
866 printf(
"%d,%d,%d,%d,%d,%d,%d\n",dims[0],dims[1],dims[2],dims[3],dims[4],dims[5],dims[6]);
868 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
869 __FILE__, __LINE__, sdsname);
874 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
875 __LINE__, sdsname,
file);
878 status = SDendaccess(sds_id);
881 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
885 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
886 __FILE__, __LINE__, sdsname);
894 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
895 __FILE__, __LINE__, sdsname);
900 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
901 __LINE__, sdsname,
file);
904 status = SDendaccess(sds_id);
908 strcpy(sdsname,
"bias_mean");
909 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
913 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
914 __FILE__, __LINE__, sdsname);
922 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
923 __FILE__, __LINE__, sdsname);
958 status = SDendaccess(sds_id);
961 sses->nqual = dims[0];
962 sses->nlat = dims[1];
963 sses->ndiff = dims[2];
964 sses->nsenz = dims[3];
965 sses->nquar = dims[4];
966 sses->nday = dims[5];
967 sses->nsst = dims[6];
972 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
976 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
977 __LINE__, sdsname,
file);
980 status = SDendaccess(sds_id);
981 sses->nsst = dims[0];
984 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
988 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
989 __LINE__, sdsname,
file);
992 status = SDendaccess(sds_id);
993 sses->nsenz = dims[0];
995 strcpy(sdsname,
"BTdiff");
996 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1000 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1001 __LINE__, sdsname,
file);
1004 status = SDendaccess(sds_id);
1005 sses->ndiff = dims[0];
1008 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1012 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1013 __LINE__, sdsname,
file);
1016 status = SDendaccess(sds_id);
1017 sses->nlat = dims[0];
1020 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1024 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1025 __LINE__, sdsname,
file);
1028 status = SDendaccess(sds_id);
1029 sses->nlat = dims[0];
1049 char name[H4_MAX_NC_NAME] =
"";
1050 char sdsname[H4_MAX_NC_NAME] =
"";
1054 if (strcmp(
file,
"") == 0) {
1055 printf(
"\nNo SSES data provided for this sensor.\n");
1060 printf(
"\nLoading SSES table from %s\n",
file);
1063 sd_id = SDstart(
file, DFACC_RDONLY);
1065 printf(
"-E- %s line %d: Error opening file %s.\n", __FILE__, __LINE__,
1073 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1077 "-E- %s line %d: Table dimensions for %s do not match expectation. got: %d expected %d\n",
1085 printf(
"%d,%d,%d,%d,%d,%d,%d\n",dims[0],dims[1],dims[2],dims[3],dims[4],dims[5],dims[6]);
1087 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1088 __FILE__, __LINE__, sdsname);
1093 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1094 __LINE__, sdsname,
file);
1097 status = SDendaccess(sds_id);
1100 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1104 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1105 __FILE__, __LINE__, sdsname);
1113 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1114 __FILE__, __LINE__, sdsname);
1119 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1120 __LINE__, sdsname,
file);
1123 status = SDendaccess(sds_id);
1127 strcpy(sdsname,
"bias_mean");
1128 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1132 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1133 __FILE__, __LINE__, sdsname);
1141 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1142 __FILE__, __LINE__, sdsname);
1177 status = SDendaccess(sds_id);
1180 sses->nqual = dims[0];
1181 sses->nlat = dims[1];
1182 sses->ndiff = dims[2];
1183 sses->nsenz = dims[3];
1184 sses->nquar = dims[4];
1185 sses->nday = dims[5];
1186 sses->nsst = dims[6];
1191 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1195 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1196 __LINE__, sdsname,
file);
1199 status = SDendaccess(sds_id);
1200 sses->nsst = dims[0];
1203 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1207 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1208 __LINE__, sdsname,
file);
1211 status = SDendaccess(sds_id);
1212 sses->nsenz = dims[0];
1214 strcpy(sdsname,
"BTdiff");
1215 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1219 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1220 __LINE__, sdsname,
file);
1223 status = SDendaccess(sds_id);
1224 sses->ndiff = dims[0];
1227 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1231 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1232 __LINE__, sdsname,
file);
1235 status = SDendaccess(sds_id);
1236 sses->nlat = dims[0];
1239 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1243 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1244 __LINE__, sdsname,
file);
1247 status = SDendaccess(sds_id);
1248 sses->nlat = dims[0];
1268 char name[H4_MAX_NC_NAME] =
"";
1269 char sdsname[H4_MAX_NC_NAME] =
"";
1273 if (strcmp(
file,
"") == 0) {
1274 printf(
"\nNo SSES data provided for this sensor.\n");
1279 printf(
"\nLoading SSES table from %s\n",
file);
1282 sd_id = SDstart(
file, DFACC_RDONLY);
1284 printf(
"-E- %s line %d: Error opening file %s.\n", __FILE__, __LINE__,
1292 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1296 "-E- %s line %d: Table dimensions for %s do not match expectation. got: %d expected %d\n",
1304 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1305 __FILE__, __LINE__, sdsname);
1310 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1311 __LINE__, sdsname,
file);
1314 status = SDendaccess(sds_id);
1317 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1321 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1322 __FILE__, __LINE__, sdsname);
1329 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1330 __FILE__, __LINE__, sdsname);
1335 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1336 __LINE__, sdsname,
file);
1339 status = SDendaccess(sds_id);
1343 strcpy(sdsname,
"bias_mean");
1344 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1348 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1349 __FILE__, __LINE__, sdsname);
1356 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1357 __FILE__, __LINE__, sdsname);
1362 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1363 __LINE__, sdsname,
file);
1366 status = SDendaccess(sds_id);
1368 strcpy(sdsname,
"counts");
1369 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1373 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1374 __FILE__, __LINE__, sdsname);
1381 "-E- %s line %d: Table dimensions for %s do not match expectation.\n",
1382 __FILE__, __LINE__, sdsname);
1387 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1388 __LINE__, sdsname,
file);
1391 status = SDendaccess(sds_id);
1394 sses->nqual = dims[0];
1395 sses->nlat = dims[1];
1396 sses->ndiff = dims[2];
1397 sses->nsenz = dims[3];
1398 sses->nquar = dims[4];
1399 sses->nsst = dims[5];
1404 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1408 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1409 __LINE__, sdsname,
file);
1412 status = SDendaccess(sds_id);
1413 sses->nsst = dims[0];
1416 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1420 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1421 __LINE__, sdsname,
file);
1424 status = SDendaccess(sds_id);
1425 sses->nsenz = dims[0];
1427 strcpy(sdsname,
"BTdiff");
1428 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1432 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1433 __LINE__, sdsname,
file);
1436 status = SDendaccess(sds_id);
1437 sses->ndiff = dims[0];
1440 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
1444 printf(
"-E- %s line %d: Error reading SDS %s from %s.\n", __FILE__,
1445 __LINE__, sdsname,
file);
1448 status = SDendaccess(sds_id);
1449 sses->nlat = dims[0];
1457 char line [200] =
"";
1463 if (nc_open(
input->sstcoeffile, NC_NOWRITE, &ncid) != NC_NOERR) {
1465 if ((fp = fopen(
input->sstcoeffile,
"r")) ==
NULL) {
1467 "-E- %s line %d: unable to open sst coef file %s for reading\n",
1468 __FILE__, __LINE__,
input->sstcoeffile);
1472 while (fgets(
line, 200, fp)) {
1473 if (
line[0] ==
'#') {
1476 sscanf(
line,
"%4s %d", mission, &datechk);
1486 if ((strcmp(mission,
"VIIR") != 0) && (datechk > 1000)) {
1489 printf(
"Using V5 coefficients to compute SST\n");
1502 extern l1qstr
l1que;
1503 int32_t
npix = l2rec->l1rec->npix;
1505 evalmask =
input->evalmask;
1507 nbvis = l2rec->l1rec->l1file->nbands;
1516 ib37 =
bindex_get(3750) - l2rec->l1rec->l1file->nbands;
1517 ib39 =
bindex_get(3959) - l2rec->l1rec->l1file->nbands;
1518 ib40 =
bindex_get(4050) - l2rec->l1rec->l1file->nbands;
1519 ib67 =
bindex_get(6715) - l2rec->l1rec->l1file->nbands;
1520 ib73 =
bindex_get(7325) - l2rec->l1rec->l1file->nbands;
1521 ib85 =
bindex_get(8550) - l2rec->l1rec->l1file->nbands;
1522 ib11 =
bindex_get(11000) - l2rec->l1rec->l1file->nbands;
1523 ib12 =
bindex_get(12000) - l2rec->l1rec->l1file->nbands;
1525 if (l2rec->l1rec->l1file->sensorID ==
AVHRR) {
1526 if (strncmp(l2rec->l1rec->l1file->spatialResolution,
"4.6km", 5) == 0) {
1549 switch (l2rec->l1rec->l1file->subsensorID) {
1565 if (l2rec->l1rec->l1file->sensorID ==
VIIRSN) {
1576 cldthresh = cldthreshv;
1583 if (l2rec->l1rec->l1file->sensorID ==
MODIST || l2rec->l1rec->l1file->sensorID ==
MODISA) {
1584 if (
input->resolution == 250) {
1586 }
else if (
input->resolution == 500) {
1591 if (ib11 < 0 || ib12 < 0)
1596 if (ib39 < 0 || ib40 < 0)
1601 if (!haveSST && !haveSST4) {
1602 fprintf(
stderr,
"-E- %s line %d: no SST bands found.\n",
1603 __FILE__, __LINE__);
1613 satred = 1000.0 - 1.0;
1616 if (
l1que.nq < btbox) {
1617 fprintf(
stderr,
"-E- %s line %d: filter queue (l1que) is too small. Have %d need %d.\n",
1618 __FILE__, __LINE__,
l1que.nq, btbox);
1626 qual_sst = (int8*) calloc(
npix,
sizeof (int8));
1627 bias_sst = (
float*) calloc(
npix,
sizeof (
float));
1628 stdv_sst = (
float*) calloc(
npix,
sizeof (
float));
1629 bias_mean_sst = (
float*) calloc(
npix,
sizeof (
float));
1631 dsdi_correction = (
float*) calloc(
npix,
sizeof (
float));
1633 treesum = (
float*) calloc(
npix,
sizeof (
float));
1635 if (l2rec->l1rec->l1file->sensorID ==
AVHRR) {
1639 if (l2rec->l1rec->l1file->sensorID ==
VIIRSN) {
1650 if (l2rec->l1rec->l1file->sensorID ==
VIIRSN) {
1653 qual_sst3 = (int8*) calloc(
npix,
sizeof (int8));
1654 bias_sst3 = (
float*) calloc(
npix,
sizeof (
float));
1655 stdv_sst3 = (
float*) calloc(
npix,
sizeof (
float));
1656 bias_mean_sst3 = (
float*) calloc(
npix,
sizeof (
float));
1667 qual_sst4 = (int8*) calloc(
npix,
sizeof (int8));
1668 bias_sst4 = (
float*) calloc(
npix,
sizeof (
float));
1669 stdv_sst4 = (
float*) calloc(
npix,
sizeof (
float));
1670 bias_mean_sst4 = (
float*) calloc(
npix,
sizeof (
float));
1675 d3940ref = (
float*) calloc(
npix,
sizeof (
float));
1677 rhoCirrus_maxmin = (
float*) calloc(
npix,
sizeof (
float));
1678 rhoCirrus_min = (
float*) calloc(
npix,
sizeof (
float));
1679 rhoCirrus_max = (
float*) calloc(
npix,
sizeof (
float));
1682 LtRED_maxmin = (
float*) calloc(
npix,
sizeof (
float));
1683 rhotRED_maxmin = (
float*) calloc(
npix,
sizeof (
float));
1684 rhotRED_min = (
float*) calloc(
npix,
sizeof (
float));
1685 rhotRED_max = (
float*) calloc(
npix,
sizeof (
float));
1686 rhotRED = (
float*) calloc(
npix,
sizeof (
float));
1689 Bt11_maxmin = (
float*) calloc(
npix,
sizeof (
float));
1690 Bt11_max = (
float*) calloc(
npix,
sizeof (
float));
1691 Bt11_min = (
float*) calloc(
npix,
sizeof (
float));
1692 Bt11_stdev = (
float*) calloc(
npix,
sizeof (
float));
1695 Bt12_maxmin = (
float*) calloc(
npix,
sizeof (
float));
1696 Bt12_min = (
float*) calloc(
npix,
sizeof (
float));
1699 Bt37_maxmin = (
float*) calloc(
npix,
sizeof (
float));
1700 Bt37_stdev = (
float*) calloc(
npix,
sizeof (
float));
1703 Bt73_max = (
float*) calloc(
npix,
sizeof (
float));
1706 Bt85_min = (
float*) calloc(
npix,
sizeof (
float));
1709 rhotNIR7_min = (
float*) calloc(
npix,
sizeof (
float));
1710 rhotNIR7 = (
float*) calloc(
npix,
sizeof (
float));
1713 rhot16_min = (
float*) calloc(
npix,
sizeof (
float));
1714 rhot16 = (
float*) calloc(
npix,
sizeof (
float));
1717 Bt39_maxmin = (
float*) calloc(
npix,
sizeof (
float));
1720 Bt40_maxmin = (
float*) calloc(
npix,
sizeof (
float));
1721 Bt40_stdev = (
float*) calloc(
npix,
sizeof (
float));
1726 sst_stdev = (
float*) calloc(
npix,
sizeof (
float));
1728 csstbox =
l1que.nq / 2;
1749 void read_v5_sst_coeff(l2str *l2rec,
float **bounds,
float **coef,
float *sstrefoffday,
float *sstrefoffnight) {
1750 char mission[5] =
"";
1751 char mission2[5] =
"";
1754 char line [200] =
"";
1755 char odates [8] =
"";
1756 char sdates [8] =
"";
1757 char edates [8] =
"";
1766 int32
sensorID = l2rec->l1rec->l1file->sensorID;
1767 double pasutime = l2rec->l1rec->scantime;
1788 fp = fopen(
input->sstcoeffile,
"r");
1792 sprintf(odates,
"%4d%03d", year,
day);
1797 while (fgets(
line, 200, fp)) {
1798 if (
line[0] ==
'#') {
1800 if (!(
p = strchr(
line,
'=')))
1810 name[p2 -
p1 + 1] =
'\0';
1829 if (strncmp(
line, mission, 4) == 0) {
1830 sscanf(
line,
"%4s %7s %7s %f %f %f %f",
1831 mission2, sdates, edates, &coef[indx][0], &coef[indx][1], &coef[indx][2], &coef[indx][3]);
1832 coef[indx][4] = 0.0;
1833 if (strcmp(odates, sdates) >= 0 && (strcmp(odates, edates) <= 0
1834 || strcmp(edates,
"0000000") == 0
1835 || strcmp(edates,
"") == 0)) {
1846 if (found == 0 && year > 2004) {
1847 printf(
"Warning: No SST coefficients available for %s, reverting to previous year.\n", odates);
1857 printf(
"Loading SST coefficients from %s:\n",
input->sstcoeffile);
1858 printf(
"%s %s %6.3f %6.3f %6.3f %6.3f %6.3f\n", sdates, edates, coef[0][0], coef[0][1], coef[0][2], coef[0][3], coef[0][4]);
1859 printf(
"%s %s %6.3f %6.3f %6.3f %6.3f %6.3f\n\n", sdates, edates, coef[1][0], coef[1][1], coef[1][2], coef[1][3], coef[1][4]);
1861 printf(
" sst reference day offset = %f\n", *sstrefoffday);
1862 printf(
" sst reference night offset = %f\n", *sstrefoffnight);
1865 "-E- %s line %d: unable to locate valid SST coefficients for %s in %s\n",
1866 __FILE__, __LINE__, odates,
input->sstcoeffile);
1880 float *sstrefoffday,
float *sstrefoffnight) {
1881 char mission[5] =
"";
1882 char mission2[5] =
"";
1885 char line[200] =
"";
1886 char odatel[14] =
"";
1887 char sdatel[14] =
"";
1888 char edatel[14] =
"";
1889 char odates[8] =
"";
1890 char sdates[8] =
"";
1891 char edates[8] =
"";
1894 char *coeflabel[] ={
"day dry ",
"day moist ",
"night dry ",
"night moist "};
1902 int32 gotsstrefoffday = 0;
1903 int32 gotsstrefoffnight = 0;
1909 int32
sensorID = l2rec->l1rec->l1file->sensorID;
1910 double pasutime = l2rec->l1rec->scantime;
1941 if ((fp = fopen(
input->sstcoeffile,
"r")) ==
NULL) {
1943 "-E- %s line %d: unable to open sst coef file %s for reading\n",
1944 __FILE__, __LINE__,
input->sstcoeffile);
1950 for (tmonth = 11; tmonth >= 0; tmonth--) {
1952 if (
day > StartOfMonth[
leap][tmonth]) {
1969 ztime =
ydhmsf(pasutime,
'G');
1977 while (fgets(
line, 200, fp)) {
1978 if (
line[0] ==
'#') {
1980 if (!(
p = strchr(
line,
'=')))
1990 name[p2 -
p1 + 1] =
'\0';
2009 if (strcmp(
name,
"sstref_day_offset") == 0) {
2011 gotsstrefoffday = 1;
2013 if (strcmp(
name,
"sstref_night_offset") == 0) {
2015 gotsstrefoffnight = 1;
2020 if (strncmp(
line, mission, 4) == 0) {
2021 if (
input->viirsnosisaf == 1) {
2022 sscanf(
line,
"%4s %7s %7s %1s %f %f %f %f %f %f %f",
2023 mission2, sdates, edates, dorn,
2024 &coef[indx][0], &coef[indx][1], &coef[indx][2],
2025 &coef[indx][3], &coef[indx][4], &coef[indx][5],
2027 }
else if (
input->viirsnv7 >= 0) {
2030 "%4s %7s %6s %7s %6s %f %f %f %f %f %f %f %f %f",
2031 mission2, sdates, stime, edates, etime,
2032 &bounds[indx][0], &bounds[indx][1],
2033 &coef[indx][0], &coef[indx][1], &coef[indx][2],
2034 &coef[indx][3], &coef[indx][4], &coef[indx][5],
2036 sprintf(sdatel,
"%s%s", sdates, stime);
2037 sprintf(edatel,
"%s%s", edates, etime);
2038 if (strcmp(odatel, sdatel) >= 0
2039 && (strcmp(odatel, edatel) <= 0
2040 || strcmp(edates,
"0000000") == 0
2041 || strcmp(edates,
"") == 0)) {
2051 sscanf(
line,
"%4s %d %f %f %f %f %f %f %f %f",
2052 mission2, &month, &bounds[indx][0], &bounds[indx][1],
2053 &coef[indx][0], &coef[indx][1], &coef[indx][2],
2054 &coef[indx][3], &coef[indx][5], &coef[indx][6]);
2056 coef[indx][4] = 0.0;
2057 if (month == tmonth + 1) {
2075 while (fgets(
line, 200, fp)) {
2076 if (
line[0] ==
'#') {
2078 if (!(
p = strchr(
line,
'=')))
2088 name[p2 -
p1 + 1] =
'\0';
2107 if (strcmp(
name,
"sstref_day_offset") == 0) {
2109 gotsstrefoffday = 1;
2111 if (strcmp(
name,
"sstref_night_offset") == 0) {
2113 gotsstrefoffnight = 1;
2118 if (strncmp(
line, mission, 4) == 0) {
2119 if (l2rec->l1rec->l1file->sensorID ==
MODIST || l2rec->l1rec->l1file->sensorID ==
MODISA) {
2122 "%4s %d %f %f %f %f %f %f %f %f %f %d %f %f",
2123 mission2, &month, &bounds[indx][0],
2124 &bounds[indx][1], &coef[indx][0],
2125 &coef[indx][1], &coef[indx][2], &coef[indx][3],
2126 &coef[indx][4], &coef[indx][5], &coef[indx][6],
2127 &tmp1, &tmp2, &tmp3);
2130 sscanf(
line,
"%4s %d %f %f %f %f %f %f", mission2,
2131 &month, &bounds[indx][0], &bounds[indx][1],
2132 &coef[indx][0], &coef[indx][1], &coef[indx][2],
2134 coef[indx][4] = 0.0;
2135 coef[indx][5] = 0.0;
2136 coef[indx][6] = 0.0;
2138 if (month == tmonth + 1) {
2155 && (gotsstrefoffday == 0 || gotsstrefoffnight == 0)) {
2157 "-E- %s line %d: Day and night sst reference offsets not found in %s\n",
2158 __FILE__, __LINE__,
input->sstcoeffile);
2162 printf(
"Loading SST lat band coefficients from %s:\n",
2163 input->sstcoeffile);
2167 for (indx = 0; indx < 4; indx++) {
2168 printf(
"%s %s %s %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f\n",
2169 coeflabel[indx], sdates, edates, coef[indx][0], coef[indx][1], coef[indx][2],
2170 coef[indx][3], coef[indx][4], coef[indx][5], coef[indx][6]);
2173 for (indx = 0; indx < 7; indx++) {
2177 "%s %s %s %s %6.1f %6.1f %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f\n",
2178 sdates, stime, edates, etime, bounds[indx][0], bounds[indx][1],
2179 coef[indx][0], coef[indx][1], coef[indx][2], coef[indx][3],
2180 coef[indx][4], coef[indx][5], coef[indx][6]);
2184 "%d %6.1f %6.1f %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f\n",
2185 month, bounds[indx][0], bounds[indx][1], coef[indx][0],
2186 coef[indx][1], coef[indx][2], coef[indx][3],
2187 coef[indx][4], coef[indx][5], coef[indx][6]);
2191 printf(
" sst reference day offset = %f\n", *sstrefoffday);
2192 printf(
" sst reference night offset = %f\n", *sstrefoffnight);
2196 "-E- %s line %d: unable to locate valid SST coefficients for %s in %s\n",
2197 __FILE__, __LINE__, odates,
input->sstcoeffile);
2211 float **bounds,
float **coef) {
2217 line = (
char *) calloc(200,
sizeof (
char));
2247 fprintf(
stderr,
"-E- %s line %d: unable to open %s for reading\n",
2252 sprintf(odate,
"%4d%03d", year,
day);
2257 for (tmonth = 11; tmonth >= 0; tmonth--) {
2258 if (
day > StartOfMonth[
leap][tmonth]) {
2265 fprintf(
stderr,
" looking for month %d mission %s\n", tmonth + 1, mission);
2266 while (fgets(
line, 200, fp)) {
2268 if (strncmp(
line, mission, 4) == 0) {
2269 sscanf(
line,
"%4s %d %f %f %f %f %f %f %f %f %f", &mission2[0],
2270 &month, &bounds[indx][0], &bounds[indx][1], &coef[indx][0],
2271 &coef[indx][1], &coef[indx][2], &coef[indx][3],
2272 &coef[indx][4], &coef[indx][5], &coef[indx][6]);
2273 if (month == tmonth + 1) {
2287 printf(
"Loading SST4 lat band coefficients from %s:\n",
filename);
2288 for (indx = 0; indx < 7; indx++) {
2289 printf(
"%d %6.1f %6.1f %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f\n",
2290 month, bounds[indx][0], bounds[indx][1], coef[indx][0], coef[indx][1], coef[indx][2],
2291 coef[indx][3], coef[indx][4], coef[indx][5], coef[indx][6]);
2296 "-E- %s line %d: unable to locate valid SST4 coefficients for %s in %s\n",
2297 __FILE__, __LINE__, odate,
filename);
2312 extern l1qstr
l1que;
2333 "-E- %s line %d: L1 queue size of %d is too small for requested homogeneity test of %d x %d.\n",
2334 __FILE__, __LINE__,
l1que.nq,
nx, ny);
2339 if (
l1que.r[
is].solz[ip] >= solznight
2340 ||
l1que.r[
is].glint_coef[ip] > glintmax)
2369 for (
j = is1;
j <= is2;
j++)
2370 for (
i = ip1;
i <= ip2;
i++) {
2371 ipb =
i * nbvis + ibred;
2372 if (
l1que.r[
j].Lt[ipb] > 0.0 &&
l1que.r[
j].Lt[ipb] < satred) {
2377 maxv =
MAX(maxv, rhot);
2378 minv =
MIN(minv, rhot);
2384 if (cnt < 2 || (maxv - minv) > thresh) {
2396 extern l1qstr
l1que;
2398 static int32_t len = 0;
2403 int32_t
is,
i,
j, ix;
2405 static float *
x =
NULL;
2410 printf(
"-E- %s line %d: L1 queue size of %d is too small for %d x %d box stats.\n",
2411 __FILE__, __LINE__,
l1que.nq,
nx, ny);
2416 if (
x ==
NULL || len <
nx * ny) {
2419 if ((
x = (
float *) malloc(len *
sizeof (
float))) ==
NULL) {
2420 printf(
"-E- %s line %d: Unable to allocate workspace for median and stdev\n",
2421 __FILE__, __LINE__);
2450 statrec->min = -1.0 *
BAD_FLT;
2458 for (ix = 0; ix < len; ix++) {
2463 for (
j = is1;
j <= is2;
j++)
for (
i = ip1;
i <= ip2;
i++) {
2464 Bt =
l1que.r[
j].rho_cirrus[
i];
2466 statrec->max =
MAX(statrec->max, Bt);
2467 statrec->min =
MIN(statrec->min, Bt);
2468 if (statrec->cnt == 0) {
2473 statrec->sqr += Bt * Bt;
2474 x[statrec->cnt] = Bt;
2478 if (statrec->cnt > 2) {
2479 qsort(
x, statrec->cnt, sizeof (
float), (
int (*)(
const void *,
const void *))
compfloat);
2480 statrec->max =
x[statrec->cnt - 1];
2481 statrec->min =
x[0];
2482 if (statrec->cnt > 1) {
2483 statrec->sd = (statrec->sqr - statrec->avg * statrec->avg / statrec->cnt) / (statrec->cnt - 1);
2484 if (statrec->sd > 0.0) {
2485 statrec->sd = sqrt(statrec->sd);
2491 statrec->med =
x[statrec->cnt / 2];
2493 if (statrec->cnt > 0)
2494 statrec->avg /= statrec->cnt;
2496 return (statrec->cnt);
2506 extern l1qstr
l1que;
2508 static int32_t len = 0;
2513 int32_t
is,
i,
j, ix;
2517 static float *
x =
NULL;
2522 "-E- %s line %d: L1 queue size of %d is too small for %d x %d box stats.\n",
2523 __FILE__, __LINE__,
l1que.nq,
nx, ny);
2528 if (
x ==
NULL || len <
nx * ny) {
2531 if ((
x = (
float *) malloc(len *
sizeof (
float))) ==
NULL) {
2532 printf(
"-E- %s line %d: Unable to allocate workspace for median and stdev\n",
2533 __FILE__, __LINE__);
2562 statrec->min = -1.0 *
BAD_FLT;
2570 for (ix = 0; ix < len; ix++) {
2575 for (
j = is1;
j <= is2;
j++)
2576 for (
i = ip1;
i <= ip2;
i++) {
2579 if (
l1que.r[
j].Lt[ipb] > sstbad + 1.0 &&
l1que.r[
j].Lt[ipb] < 1000.0 - 1.0) {
2581 statrec->max =
MAX(statrec->max, rhot);
2582 statrec->min =
MIN(statrec->min, rhot);
2583 if (statrec->cnt == 0) {
2587 statrec->avg += rhot;
2588 statrec->sqr += rhot * rhot;
2589 x[statrec->cnt] = rhot;
2593 if (statrec->cnt > 2) {
2594 qsort(
x, statrec->cnt, sizeof (
float), (
int (*)(
const void *,
const void *))
compfloat);
2595 statrec->max =
x[statrec->cnt - 1];
2596 statrec->min =
x[0];
2597 if (statrec->cnt > 1) {
2598 statrec->sd = (statrec->sqr - statrec->avg * statrec->avg / statrec->cnt) / (statrec->cnt - 1);
2599 if (statrec->sd > 0.0) {
2600 statrec->sd = sqrt(statrec->sd);
2606 statrec->med =
x[statrec->cnt / 2];
2608 if (statrec->cnt > 0)
2609 statrec->avg /= statrec->cnt;
2611 return (statrec->cnt);
2622 extern l1qstr
l1que;
2624 static int32_t len = 0;
2629 int32_t
is,
i,
j, ix;
2632 static float *
x =
NULL;
2637 "-E- %s line %d: L1 queue size of %d is too small for %d x %d box stats.\n",
2638 __FILE__, __LINE__,
l1que.nq,
nx, ny);
2643 if (
x ==
NULL || len <
nx * ny) {
2646 if ((
x = (
float *) malloc(len *
sizeof (
float))) ==
NULL) {
2647 printf(
"-E- %s line %d: Unable to allocate workspace for median and stdev\n",
2648 __FILE__, __LINE__);
2677 statrec->min = -1.0 *
BAD_FLT;
2685 for (ix = 0; ix < len; ix++) {
2690 for (
j = is1;
j <= is2;
j++) {
2695 || (
l1que.r[
j].detnum != 0)) {
2697 for (
i = ip1;
i <= ip2;
i++) {
2701 statrec->max =
MAX(statrec->max, Bt);
2702 statrec->min =
MIN(statrec->min, Bt);
2703 if (statrec->cnt == 0) {
2709 statrec->sqr += Bt * Bt;
2710 x[statrec->cnt] = Bt;
2716 if (statrec->cnt > 2) {
2717 qsort(
x, statrec->cnt, sizeof (
float), (
int (*)(
const void *,
const void *))
compfloat);
2718 statrec->max =
x[statrec->cnt - 1];
2719 statrec->min =
x[0];
2720 if (statrec->cnt > 1) {
2721 statrec->sd = (statrec->sqr - statrec->avg * statrec->avg / statrec->cnt) / (statrec->cnt - 1);
2722 if (statrec->sd > 0.0) {
2723 statrec->sd = sqrt(statrec->sd);
2729 statrec->med =
x[statrec->cnt / 2];
2731 if (statrec->cnt > 0) {
2732 statrec->avg /= statrec->cnt;
2735 return (statrec->cnt);
2745 extern l1qstr
l1que;
2747 static int32_t len = 0;
2752 int32_t
is,
i,
j, ix;
2755 static float *
x =
NULL;
2760 "-E- %s line %d: sst queue size of %d is too small for %d x %d box stats.\n",
2761 __FILE__, __LINE__,
nscan,
nx, ny);
2766 if (
x ==
NULL || len <
nx * ny) {
2769 if ((
x = (
float *) malloc(len *
sizeof (
float))) ==
NULL) {
2770 printf(
"-E- %s line %d: Unable to allocate workspace for median and stdev\n",
2771 __FILE__, __LINE__);
2800 statrec->min = -1.0 *
BAD_FLT;
2808 for (ix = 0; ix < len; ix++) {
2813 for (
j = is1;
j <= is2;
j++) {
2814 for (
i = ip1;
i <= ip2;
i++) {
2816 if (sst >= SSTmin && sst <= SSTmax) {
2817 statrec->max =
MAX(statrec->max, sst);
2818 statrec->min =
MIN(statrec->min, sst);
2819 if (statrec->cnt == 0) {
2824 statrec->avg += sst;
2825 statrec->sqr += sst * sst;
2826 x[statrec->cnt] = sst;
2831 if (statrec->cnt > 2) {
2832 qsort(
x, statrec->cnt, sizeof (
float), (
int (*)(
const void *,
const void *))
compfloat);
2833 statrec->max =
x[statrec->cnt - 1];
2834 statrec->min =
x[0];
2835 if (statrec->cnt > 1) {
2836 statrec->sd = (statrec->sqr - statrec->avg * statrec->avg / statrec->cnt) / (statrec->cnt - 1);
2837 if (statrec->sd > 0.0) {
2838 statrec->sd = sqrt(statrec->sd);
2844 statrec->med =
x[statrec->cnt / 2];
2846 if (statrec->cnt > 0) {
2847 statrec->avg /= statrec->cnt;
2850 return (statrec->cnt);
2860 for (ip = 0; ip <
npix; ip++) {
2861 sst_stdev[ip] = sstbad;
2862 if (
sstboxstats(ip, btbox, btbox, &statrec) > 0) {
2863 sst_stdev[ip] = statrec.sd;
2876 for (ip = 0; ip <
npix; ip++) {
2877 minarr[ip] = sstbad;
2879 minarr[ip] = statrec.min;
2892 for (ip = 0; ip <
npix; ip++) {
2893 maxminarr[ip] = sstbad;
2894 maxarr[ip] = sstbad;
2896 maxminarr[ip] = statrec.max - statrec.min;
2897 maxarr[ip] = statrec.max;
2910 for (ip = 0; ip <
npix; ip++) {
2911 avgarr[ip] = sstbad;
2913 avgarr[ip] = statrec.avg;
2926 for (ip = 0; ip <
npix; ip++) {
2927 maxminarr[ip] = sstbad;
2929 maxminarr[ip] = statrec.max - statrec.min;
2941 for (ip = 0; ip <
npix; ip++) {
2942 minarr[ip] = sstbad;
2944 minarr[ip] = statrec.min;
2956 for (ip = 0; ip <
npix; ip++) {
2957 maxarr[ip] = sstbad;
2959 maxarr[ip] = statrec.max;
2968 for (ip = 0; ip <
npix; ip++) {
2969 maxminarr[ip] = sstbad;
2970 minarr[ip] = sstbad;
2971 maxarr[ip] = sstbad;
2973 maxminarr[ip] = statrec.max - statrec.min;
2974 minarr[ip] = statrec.min;
2975 maxarr[ip] = statrec.max;
2983 for (ip = 0; ip <
npix; ip++) {
2984 stdevarr[ip] = sstbad;
2986 stdevarr[ip] = statrec.sd;
2997 extern l1qstr
l1que;
3008 || (
l1que.r[
is].detnum != 0)) {
3010 "-E- %s line %d: btavg should only be used for AQUA detector zero Bt40.\n",
3011 __FILE__, __LINE__);
3021 if ((
nscan < (btbox + 2)) && (
is == 0 ||
is == btbox)) {
3023 "-E- %s line %d: L1 queue size of %d is too small for 3 line Bt40 average around line %d.\n",
3024 __FILE__, __LINE__,
l1que.nq,
is);
3033 statrec->min = -1.0 *
BAD_FLT;
3043 for (
j = is1;
j <= is2;
j += 2) {
3049 if (statrec->cnt == 0) {
3058 if (statrec->cnt > 0)
3059 statrec->avg /= statrec->cnt;
3061 return (statrec->cnt);
3081 extern l1qstr
l1que;
3092 "-E- %s line %d: L1 queue size of %d is too small for %d line box stats.\n",
3093 __FILE__, __LINE__,
l1que.nq, ny);
3104 cpix = (fullscanpix - 1) / 2;
3118 for (jj = 0; jj <
nscan - 1; jj++) {
3119 diflats[jj] =
l1que.r[jj].lat[cpix] -
l1que.r[jj + 1].lat[cpix];
3122 if ((diflats[
is - 1] > 0.0 && diflats[
is] > 0.0) ||
3123 (diflats[
is - 1] < 0.0 && diflats[
is] < 0.0)) {
3124 *diflat = diflats[
is];
3128 if ((diflats[
is] > 0.0 && diflats[
is + 1] > 0.0) ||
3129 (diflats[
is] < 0.0 && diflats[
is + 1] < 0.0)) {
3130 *diflat = diflats[
is];
3133 *diflat = diflats[
is - 1];
3140 if (*diflat < 0.0) {
3157 extern l1qstr
l1que;
3158 int32_t
npix = l2rec->l1rec->npix;
3160 int32_t ip, ipb, ipbir;
3179 float dBt_11_12, dBt_37_11, dBt_37_12, dBt_11_37, dBt_67_11;
3180 float dBt_40_11, dBt_85_11;
3182 float subsolar, xdoy, xrad;
3187 cpix = (fullscanpix - 1) / 2;
3194 for (ip = 0; ip <
npix; ip++) {
3197 if (
sstmasked(l2rec->l1rec->flags, ip)) {
3202 ipb = ip * l2rec->l1rec->l1file->nbands;
3207 Bt37 = l2rec->l1rec->Bt[ipbir + ib37];
3208 Bt85 = l2rec->l1rec->Bt[ipbir + ib85];
3209 Bt11 = l2rec->l1rec->Bt[ipbir + ib11];
3210 Bt12 = l2rec->l1rec->Bt[ipbir + ib12];
3212 LtRED = l2rec->l1rec->Lt[ipb + ibred];
3215 if (l2rec->l1rec->l1file->sensorID ==
AVHRR) {
3216 LtNIR8 = l2rec->l1rec->Lt[ipb + ib08];
3218 rhoCirrus = l2rec->l1rec->rho_cirrus[ip];
3219 if (l2rec->l1rec->l1file->sensorID ==
MODIST || l2rec->l1rec->l1file->sensorID ==
MODISA) {
3220 Bt39 = l2rec->l1rec->Bt[ipbir + ib39];
3222 if (l2rec->l1rec->l1file->sensorID ==
MODISA && l2rec->l1rec->detnum == 0) {
3230 Bt40 = l2rec->l1rec->Bt[ipbir + ib40];
3231 Bt67 = l2rec->l1rec->Bt[ipbir + ib67];
3232 }
else if (l2rec->l1rec->l1file->sensorID ==
VIIRSN) {
3233 Bt40 = l2rec->l1rec->Bt[ipbir + ib40];
3234 LtNIR7 = l2rec->l1rec->Lt[ipb + ib07];
3235 Lt16 = l2rec->l1rec->Lt[ipb + ib16];
3240 if (Bt11 < BT_LO + 0.1 || Bt11 >
BT_HI - 0.1 || Bt12 <
BT_LO + 0.1
3241 || Bt12 >
BT_HI - 0.1) {
3247 if (Bt11 < Btmin || Bt11 > Btmax || Bt12 < Btmin || Bt12 > Btmax)
3250 if (l2rec->l1rec->l1file->sensorID ==
AVHRR) {
3255 if (l2rec->l1rec->solz[ip] < solznight) {
3256 if (l2rec->l1rec->glint_coef[ip] > glintmax)
3272 if ((l2rec->l1rec->l1file->subsensorID ==
NO07
3273 || l2rec->l1rec->l1file->subsensorID ==
NO09
3274 || l2rec->l1rec->l1file->subsensorID ==
NO10
3275 || l2rec->l1rec->l1file->subsensorID ==
NO11
3276 || l2rec->l1rec->l1file->subsensorID ==
NO12
3277 || l2rec->l1rec->l1file->subsensorID ==
NO14
3278 || l2rec->l1rec->l1file->subsensorID ==
NO15)
3279 && (l2rec->l1rec->solz[ip] >= solznight
3280 || (l2rec->l1rec->solz[ip] < solznight
3281 && l2rec->l1rec->glint_coef[ip] <= glintmax))) {
3282 if (Bt37 < Btmin || Bt37 > Btmax) {
3288 if ((l2rec->l1rec->l1file->subsensorID ==
NO16
3289 || l2rec->l1rec->l1file->subsensorID ==
NO17
3290 || l2rec->l1rec->l1file->subsensorID ==
NO18
3291 || l2rec->l1rec->l1file->subsensorID ==
NO19)
3292 && l2rec->l1rec->solz[ip] >= solznight) {
3293 if (Bt37 < Btmin || Bt37 > Btmax) {
3306 if ((l2rec->l1rec->l1file->sensorID ==
MODIST || l2rec->l1rec->l1file->sensorID ==
MODISA)) {
3309 if (l2rec->l1rec->solz[ip] >= solznight
3310 && (Bt37 < Btmin || Bt37 > Btmax || Bt39 < Btmin
3311 || Bt39 > Btmax || Bt40 < Btmin || Bt40 > Btmax40)) {
3315 if ((l2rec->l1rec->solz[ip] < solznight
3316 && l2rec->l1rec->glint_coef[ip] <= glintmax)
3317 && (Bt37 < Btmin || Bt39 < Btmin || Bt40 < Btmin)) {
3322 if (l2rec->l1rec->l1file->sensorID ==
VIIRSN) {
3324 if (l2rec->l1rec->solz[ip] >= solznight
3325 && (Bt37 < Btmin || Bt37 > Btmax || Bt40 < Btmin
3326 || Bt40 > Btmax40)) {
3331 if ((l2rec->l1rec->solz[ip] < solznight
3332 && l2rec->l1rec->glint_coef[ip] <= glintmax)
3333 && (Bt37 < Btmin || Bt40 < Btmin)) {
3339 dBt_11_12 = Bt11 - Bt12;
3340 if (dBt_11_12 < dBtmin || dBt_11_12 > dBtmax)
3344 if ((sstq[csstbox][ip] < SSTmin)
3345 || (l2rec->l1rec->solz[ip] < solznight && sstq[csstbox][ip] > SSTmax)
3346 || (l2rec->l1rec->solz[ip] >= solznight && sstq[csstbox][ip] > SSTmaxn)) {
3354 dSST_ref = sstq[csstbox][ip] - l2rec->l1rec->sstref[ip];
3356 if ((evalmask &
SSTMODS) == 0) {
3359 if (dSST_ref < -SSTdiff || l2rec->
l1rec->sstref[ip] < sstbad + 1.0)
3361 if (dSST_ref < -input->sstrefdif &&
3362 l2rec->l1rec->lat[ip] >= equatorialSouth && l2rec->l1rec->lat[ip] <= equatorialNorth &&
3363 l2rec->l1rec->lon[ip] >= equatorialWest && l2rec->l1rec->lon[ip] <= equatorialEast) {
3369 if (l2rec->l1rec->solz[ip] >= solznight) {
3370 if (
fabs(dSST_ref) > SSTdiff)
3374 if (dSST_ref < -SSTvdiff || l2rec->
l1rec->sstref[ip] < sstbad + 1.0)
3377 if (l2rec->l1rec->solz[ip] >= solznight) {
3378 if (
fabs(dSST_ref) > SSTvdiff)
3382 if (l2rec->l1rec->solz[ip] >=
SOLZNIGHT) {
3383 if (
fabs(dSST_ref) > SSTdiff)
3386 if (dSST_ref < -SSTdiff || dSST_ref > (SSTdiff + 1))
3389 if (
fabs(dSST_ref) > SSTvdiff)
3396 dSST_SST4 = sstq[csstbox][ip] - sst4q[csstbox][ip];
3397 if (sst4q[csstbox][ip] > sstbad + 1.0 && l2rec->l1rec->solz[ip] >=
SOLZNIGHT) {
3398 if (
fabs(dSST_SST4) < SST4diff1)
3400 if (
fabs(dSST_SST4) < SST4diff2)
3407 if (l2rec->l1rec->l1file->sensorID ==
VIIRSN) {
3408 dSST_SST3 = sstq[csstbox][ip]-sst3q[csstbox][ip];
3409 if (sst3q[csstbox][ip] > sstbad+1.0 && l2rec->l1rec->solz[ip] >=
SOLZNIGHT) {
3410 if (
fabs(dSST_SST3) > SST3diff1)
3412 if (
fabs(dSST_SST3) > SST3diff2)
3418 if (l2rec->l1rec->senz[ip] > hisenz)
3420 if (l2rec->l1rec->l1file->sensorID ==
VIIRSN) {
3421 if (l2rec->l1rec->senz[ip] > vhisenzv2) {
3427 if (l2rec->l1rec->senz[ip] > vhisenz)
3432 if (l2rec->l1rec->pixnum[ip] < 2 || l2rec->l1rec->pixnum[ip] > (fullscanpix - 3))
3436 if ((l2rec->l1rec->l1file->sensorID ==
MODIST) && (l2rec->l1rec->pixnum[ip] > 1349))
3443 if (sstq[csstbox][ip] > sstbad + 1.0 && l2rec->l1rec->sstref[ip] > sstbad + 1.0
3444 && sstq[csstbox][ip] - l2rec->l1rec->sstref[ip] <= -1.0)
3445 if (
sstcloud(ip, cldbox, cldbox, cldthresh) == 1)
3449 if (Bt11_maxmin[ip] > Bt11unif1)
3451 if (Bt11_maxmin[ip] > Bt11unif2)
3454 if (Bt12_maxmin[ip] > Bt12unif1)
3456 if (Bt12_maxmin[ip] > Bt12unif2)
3461 dBt_37_11 = Bt37 - Bt11;
3462 dBt_37_12 = Bt37 - Bt12;
3463 dBt_11_37 = Bt11 - Bt37;
3464 dBt_67_11 = Bt67 - Bt11;
3465 dBt_40_11 = Bt40 - Bt11;
3466 dBt_85_11 = Bt85 - Bt11;
3472 Tdeflong = (Bt11 - Bt12) / Bt11;
3474 Tdeflong = (Bt11 - Bt12) / (Bt11 + 0.00001);
3476 double pasutime = l2rec->l1rec->scantime;
3481 yyyyddd = year * 1000 +
day;
3490 switch (l2rec->l1rec->l1file->subsensorID) {
3495 if (yyyyddd < 1994001) {
3497 if ((l2rec->l1rec->solz[ip] >= solznight
3498 || (l2rec->l1rec->solz[ip] < solznight
3499 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3500 && dBt_37_12 < -0.4805) {
3501 if (dBt_37_12 < -1.249) {
3503 }
else if (dBt_11_12 >= 0.239) {
3505 }
else if (Bt37_maxmin[ip] >= 0.7975
3506 && dBt_11_12 >= -0.1805) {
3510 if (dBt_11_12 < 0.307
3511 && ((l2rec->l1rec->solz[ip] >= solznight
3512 || (l2rec->l1rec->solz[ip] < solznight
3513 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3514 && Bt37_maxmin[ip] >= 1.6215)) {
3520 if ((l2rec->l1rec->solz[ip] >= solznight
3521 || (l2rec->l1rec->solz[ip] < solznight
3522 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3523 && dBt_37_12 < 0.62) {
3525 }
else if (dBt_11_12 < 0.5055
3526 && ((l2rec->l1rec->solz[ip] >= solznight
3527 || (l2rec->l1rec->solz[ip] < solznight
3528 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3529 && Bt37_maxmin[ip] >= 1.033)
3530 && Bt11_maxmin[ip] >= 0.2435) {
3538 if ((l2rec->l1rec->solz[ip] >= solznight
3539 || (l2rec->l1rec->solz[ip] < solznight && l2rec->l1rec->glint_coef[ip] <= glintmax))
3540 && dBt_37_12 < -0.581) {
3543 if (dBt_11_12 < 0.315) {
3544 if ((l2rec->l1rec->solz[ip] >= solznight
3545 || (l2rec->l1rec->solz[ip] < solznight
3546 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3547 && dBt_11_37 < -0.1855) {
3549 }
else if ((l2rec->l1rec->solz[ip] >= solznight
3550 || (l2rec->l1rec->solz[ip] < solznight
3551 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3552 && Bt37_maxmin[ip] >= 0.9555) {
3555 }
else if ((l2rec->l1rec->solz[ip] >= solznight
3556 || (l2rec->l1rec->solz[ip] < solznight
3557 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3558 && dBt_11_37 >= 0.86 && Bt37_maxmin[ip] >= 0.5035) {
3566 if (yyyyddd >= 1995001 && yyyyddd < 1996001) {
3567 if ((l2rec->l1rec->solz[ip] >= solznight
3568 || (l2rec->l1rec->solz[ip] < solznight
3569 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3570 && dBt_11_37 >= 0.8015) {
3572 }
else if ((l2rec->l1rec->solz[ip] >= solznight
3573 || (l2rec->l1rec->solz[ip] < solznight
3574 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3575 && Bt37_maxmin[ip] >= 1.216) {
3576 if (dBt_11_12 < 1.342) {
3579 }
else if (dBt_11_12 < 1.3225
3580 && ((l2rec->l1rec->solz[ip] >= solznight
3581 || (l2rec->l1rec->solz[ip] < solznight
3582 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3583 && dBt_11_37 < 0.994)) {
3586 }
else if (yyyyddd >= 1996001) {
3587 if (dBt_11_12 >= 0.755) {
3588 if ((l2rec->l1rec->solz[ip] >= solznight
3589 || (l2rec->l1rec->solz[ip] < solznight
3590 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3591 && (dBt_11_37 >= 0.7995 || LtNIR8 >= 0.7225)) {
3595 if ((l2rec->l1rec->solz[ip] >= solznight
3596 || (l2rec->l1rec->solz[ip] < solznight
3597 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3598 && (dBt_11_37 >= 1.1475 || LtNIR8 >= 1.2645
3599 || Bt37_maxmin[ip] >= 0.966)) {
3602 if (((l2rec->l1rec->solz[ip] >= solznight
3603 || (l2rec->l1rec->solz[ip] < solznight
3604 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3605 && dBt_11_37 >= 0.869)
3606 || (dBt_11_12 < 0.462
3607 && ((l2rec->l1rec->solz[ip] >= solznight
3608 || (l2rec->l1rec->solz[ip] < solznight
3609 && l2rec->l1rec->glint_coef[ip] <= glintmax))
3610 && LtNIR8 >= 0.4865))) {
3622 if (l2rec->l1rec->solz[ip] < solznight) {
3624 if ((l2rec->l1rec->glint_coef[ip] <= glintmax && LtRED >= 0.7315)
3625 || dBt_11_12 < 0.5375) {
3630 if (dBt_37_11 < -0.1025 || Bt37_maxmin[ip] >= 1.035
3631 || dBt_11_12 < 0.7385) {
3633 }
else if (Bt37_maxmin[ip] < 0.7145) {
3634 if (dBt_11_12 < 1.454) {
3637 }
else if (dBt_11_12 < 1.271) {
3638 if (dBt_37_11 >= 0.9195) {
3641 }
else if (dBt_37_11 >= 2.408 && dBt_11_12 < 2.272) {
3649 if (l2rec->l1rec->solz[ip] < solznight) {
3651 if (l2rec->l1rec->glint_coef[ip] <= glintmax && LtRED >= 0.7045) {
3653 }
else if (l2rec->l1rec->lat[ip] >= -20.0 && dBt_11_12 < 0.4355) {
3658 if (dBt_37_12 < 0.0355 || Bt37_maxmin[ip] >= 0.9035
3659 || dBt_11_12 < 0.4565 || dBt_37_11 < -0.5515) {
3661 }
else if (dBt_37_11 >= 1.635 && dBt_11_12 < 1.693) {
3668 if (l2rec->l1rec->solz[ip] < solznight) {
3671 if (l2rec->l1rec->glint_coef[ip] <= glintmax && LtRED >= 0.7045) {
3673 }
else if (dBt_11_12 < 0.4995) {
3679 if (dBt_37_12 < 0.3185) {
3681 }
else if (Bt37_maxmin[ip] >= 0.8455) {
3682 if (dBt_11_12 < 1.477) {
3685 }
else if (dBt_11_12 < 0.6605) {
3687 }
else if (dBt_37_11 < -0.5745) {
3689 }
else if (dBt_37_11 >= 2.1015 && dBt_11_12 < 2.206) {
3695 if (l2rec->l1rec->solz[ip] < solznight) {
3697 if ((l2rec->l1rec->glint_coef[ip] <= glintmax && LtRED >= 0.84648)
3698 || dBt_11_12 < 0.168655
3699 || fabsf(sstq[csstbox][ip] - l2rec->l1rec->sstref[ip]) >= 1.237905) {
3704 if (dBt_11_12 < 0.99571) {
3705 if (dBt_37_12 < -0.26932 || dBt_11_12 < 0.126555
3706 || Bt37_maxmin[ip] >= 1.02994
3707 || fabsf(sstq[csstbox][ip] - l2rec->l1rec->sstref[ip]) >= 0.758065) {
3710 }
else if (dBt_37_11 < -0.387815
3711 || fabsf(sstq[csstbox][ip] - l2rec->l1rec->sstref[ip]) >= 0.857825) {
3722 if (l2rec->l1rec->l1file->sensorID ==
MODIST) {
3723 if (l2rec->l1rec->solz[ip] < solznight
3724 && l2rec->l1rec->glint_coef[ip] <= glintmax) {
3731 if (rhotRED[ip] < 0.206 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
3732 treesum[ip] += 0.894;
3733 if (rhotRED[ip] < 0.051 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
3734 treesum[ip] += 0.540;
3735 if (l2rec->l1rec->senz[ip] < 64.915) {
3736 treesum[ip] += -0.057;
3737 if (rhoCirrus_max[ip] < 0.003 && rhoCirrus_max[ip] > (
BAD_FLT + 0.1)) {
3738 treesum[ip] += 0.087;
3739 if (l2rec->l1rec->senz[ip] < 54.529) {
3740 treesum[ip] += 0.030;
3742 treesum[ip] += -0.573;
3745 treesum[ip] += -0.828;
3748 treesum[ip] += -2.700;
3751 treesum[ip] += -0.490;
3754 if (rhoCirrus_min[ip] < 0.004 && rhoCirrus_min[ip] > (
BAD_FLT + 0.1)) {
3755 treesum[ip] += 0.210;
3756 if (rhotRED[ip] < 0.073 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
3757 treesum[ip] += 0.074;
3759 treesum[ip] += -0.467;
3762 treesum[ip] += -1.008;
3765 treesum[ip] += -1.402;
3770 if (rhotRED_min[ip] < 0.239 && rhotRED_min[ip] > (
BAD_FLT + 0.1)) {
3771 treesum[ip] += 0.821;
3773 treesum[ip] += -0.033;
3774 if (dBt_67_11 < -42.423) {
3775 treesum[ip] += 0.283;
3777 treesum[ip] += -0.184;
3781 if (dBt_37_11 < 3.493) {
3782 treesum[ip] += 0.530;
3783 if (dBt_11_12 < 0.178) {
3784 treesum[ip] += -0.589;
3786 treesum[ip] += 0.174;
3789 treesum[ip] += -0.169;
3791 if (rhoCirrus_min[ip] < 0.008 && rhoCirrus_min[ip] > (
BAD_FLT + 0.1)) {
3792 treesum[ip] += 0.097;
3794 treesum[ip] += -0.761;
3797 if (sst_stdev[ip] < 0.273 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
3798 treesum[ip] += 0.258;
3800 treesum[ip] += -0.194;
3802 if (sst_stdev[ip] < 0.119 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
3803 treesum[ip] += 0.459;
3805 treesum[ip] += -0.037;
3806 if (sstq[csstbox][ip] < 27.293) {
3807 treesum[ip] += -0.054;
3809 treesum[ip] += 0.411;
3812 }
else if (l2rec->l1rec->solz[ip] < solznight) {
3814 if (LtRED < (1000.0 - 0.1)) {
3824 if (rhotRED[ip] < 0.098 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
3825 treesum[ip] += 1.026;
3826 if (rhotRED[ip] < 0.069 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
3827 treesum[ip] += 0.290;
3829 treesum[ip] += -0.312;
3832 if (rhoCirrus < 0.002 && rhoCirrus > (
BAD_FLT + 0.1)) {
3833 treesum[ip] += 0.154;
3835 treesum[ip] += -0.574;
3838 if (Bt73_max[ip] < -10.303) {
3839 treesum[ip] += -0.150;
3841 treesum[ip] += 0.393;
3844 treesum[ip] += -0.761;
3845 if (Bt11 < 16.122) {
3846 treesum[ip] += -0.538;
3848 treesum[ip] += 0.707;
3852 if (rhoCirrus_max[ip] < 0.005 && rhoCirrus_max[ip] > (
BAD_FLT + 0.1)) {
3853 treesum[ip] += 0.357;
3854 if (Tdeflong < 0.037) {
3855 treesum[ip] += -0.450;
3856 if (l2rec->l1rec->lat[ip] < 28.270) {
3857 treesum[ip] += -0.383;
3859 treesum[ip] += 0.560;
3862 treesum[ip] += 0.134;
3864 if (l2rec->l1rec->senz[ip] < 34.756) {
3865 treesum[ip] += 0.098;
3867 treesum[ip] += -0.424;
3870 treesum[ip] += -1.399;
3872 if (rhoCirrus_min[ip] < 0.01 && rhoCirrus_min[ip] > (
BAD_FLT + 0.1)) {
3873 treesum[ip] += 0.326;
3875 treesum[ip] += -1.404;
3879 if (sst_stdev[ip] < 0.382 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
3880 treesum[ip] += 0.130;
3881 if (l2rec->l1rec->lat[ip] < -5.005) {
3882 treesum[ip] += 0.400;
3884 treesum[ip] += -0.107;
3887 if (sst_stdev[ip] < 0.224 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
3888 treesum[ip] += 0.182;
3890 treesum[ip] += -0.216;
3893 treesum[ip] += -0.632;
3895 if (dBt_85_11 < -1.641) {
3896 treesum[ip] += 0.268;
3898 treesum[ip] += -0.201;
3899 if (sstq[csstbox][ip] < 27.723) {
3900 treesum[ip] += -0.069;
3902 treesum[ip] += 0.903;
3910 if (Bt12_min[ip] < 15.376) {
3911 treesum[ip] += -0.908;
3912 if (dBt_11_12 < 0.27) {
3913 treesum[ip] += -0.446;
3915 treesum[ip] += 0.568;
3918 if (rhoCirrus_min[ip] < -0.001) {
3919 treesum[ip] += -0.981;
3921 treesum[ip] += 0.137;
3924 treesum[ip] += 0.819;
3925 if (Tdeflong < 0.031) {
3926 treesum[ip] += -0.969;
3928 treesum[ip] += 0.025;
3931 if (Bt73_max[ip] < -9.485) {
3932 treesum[ip] += -0.208;
3934 treesum[ip] += 0.428;
3937 if (rhoCirrus_max[ip] < 0.005 && rhoCirrus_max[ip] > (
BAD_FLT + 0.1)) {
3938 treesum[ip] += 0.235;
3939 if (rhoCirrus < 0.002 && rhoCirrus > (
BAD_FLT + 0.1)) {
3940 treesum[ip] += 0.100;
3942 treesum[ip] += -0.506;
3945 treesum[ip] += -1.176;
3947 if (sst_stdev[ip] < 0.36 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
3948 treesum[ip] += 0.222;
3950 treesum[ip] += -0.657;
3952 if (sstq[csstbox][ip] < 27.443) {
3953 treesum[ip] += -0.077;
3954 if (sst_stdev[ip] < 0.36 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
3955 treesum[ip] += 0.355;
3957 treesum[ip] += -0.179;
3960 if (rhoCirrus_min[ip] < 0.01 && rhoCirrus_min[ip] > (
BAD_FLT + 0.1)) {
3961 treesum[ip] += 0.022;
3962 if (l2rec->l1rec->lat[ip] < 29.775) {
3963 treesum[ip] += -0.128;
3964 if (l2rec->l1rec->lat[ip] < -15.305) {
3965 treesum[ip] += 0.431;
3967 treesum[ip] += -0.202;
3969 if (Bt11_max[ip] < 14.722) {
3970 treesum[ip] += -1.906;
3972 treesum[ip] += 0.087;
3975 if (Tdeflong < 0.04) {
3976 treesum[ip] += -0.336;
3978 treesum[ip] += 0.156;
3981 treesum[ip] += 0.379;
3984 treesum[ip] += -1.948;
3987 treesum[ip] += 0.688;
3993 if (dBt_37_12 < -0.053) {
3994 treesum[ip] += -1.257;
3995 if (l2rec->l1rec->lat[ip] < 33.195) {
3996 treesum[ip] += -0.278;
3997 if (l2rec->l1rec->lat[ip] < -40.185) {
3998 treesum[ip] += 0.619;
4000 treesum[ip] += -0.711;
4002 treesum[ip] += -3.733;
4004 treesum[ip] += -0.111;
4008 treesum[ip] += 0.333;
4011 treesum[ip] += -0.292;
4013 treesum[ip] += 0.764;
4016 treesum[ip] += 0.430;
4017 if (Bt11_maxmin[ip] < 0.486 && Bt11_maxmin[ip] > (
BAD_FLT + 0.1)) {
4018 treesum[ip] += 0.628;
4019 if (Bt40_stdev[ip] < 0.146 && Bt40_stdev[ip] > (
BAD_FLT + 0.1)) {
4020 treesum[ip] += 0.177;
4022 treesum[ip] += -0.723;
4025 treesum[ip] += -0.450;
4027 if (dSST_SST4 < -0.878) {
4028 treesum[ip] += -1.353;
4029 if (dSST_SST4 < -1.533) {
4030 treesum[ip] += -1.439;
4032 treesum[ip] += 0.346;
4035 treesum[ip] += 0.219;
4036 if (Bt37_stdev[ip] < 0.448 && Bt37_stdev[ip] > (
BAD_FLT + 0.1)) {
4037 treesum[ip] += 0.290;
4038 if (dSST_SST4 < -0.422) {
4039 treesum[ip] += -0.504;
4041 treesum[ip] += 0.268;
4044 treesum[ip] += -0.484;
4046 if (Bt12 < 16.736) {
4047 treesum[ip] += -0.285;
4048 if (dBt_40_11 < -2.199) {
4049 treesum[ip] += 0.518;
4051 treesum[ip] += -0.316;
4052 if (Bt12 < 11.896) {
4053 treesum[ip] += -0.527;
4055 treesum[ip] += 0.400;
4059 treesum[ip] += 0.500;
4061 if (dSST_SST4 < 1.183) {
4062 treesum[ip] += 0.051;
4064 treesum[ip] += -0.898;
4069 if (treesum[ip] <= 0.0) {
4073 else if (l2rec->l1rec->l1file->sensorID ==
MODISA) {
4074 if (l2rec->l1rec->solz[ip] < solznight && l2rec->l1rec->glint_coef[ip] <= glintmax) {
4081 if (rhotRED[ip] < 0.204 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
4082 treesum[ip] += 0.982;
4083 if (rhotRED[ip] < 0.056 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
4084 treesum[ip] += 0.328;
4086 if (rhoCirrus_max[ip] < 0.006 && rhoCirrus_max[ip] > (
BAD_FLT + 0.1)) {
4087 treesum[ip] += 0.151;
4088 if (l2rec->l1rec->senz[ip] < 59.043) {
4089 treesum[ip] += 0.029;
4091 treesum[ip] += -0.618;
4094 treesum[ip] += -1.071;
4097 treesum[ip] += -0.565;
4100 treesum[ip] += -1.325;
4103 if (rhotRED_min[ip] < 0.251 && rhotRED_min[ip] > (
BAD_FLT + 0.1)) {
4104 treesum[ip] += 0.81;
4106 treesum[ip] += -0.021;
4107 if (l2rec->l1rec->lat[ip] < 48.685) {
4108 treesum[ip] += 0.605;
4110 treesum[ip] += -0.088;
4111 if (l2rec->l1rec->lat[ip] < 37.755) {
4112 treesum[ip] += -0.311;
4114 treesum[ip] += 0.189;
4116 if (dBt_11_12 < 0.752) {
4117 treesum[ip] += -0.091;
4119 treesum[ip] += 0.581;
4124 if (dBt_67_11 < -38.023) {
4125 treesum[ip] += 0.221;
4127 treesum[ip] += -0.201;
4131 if (rhoCirrus_min[ip] < 0.003 && rhoCirrus_min[ip] > (
BAD_FLT + 0.1)) {
4132 treesum[ip] += 0.22;
4133 if (rhoCirrus_max[ip] < 0.003 && rhoCirrus_max[ip] > (
BAD_FLT + 0.1)) {
4134 treesum[ip] += 0.069;
4136 treesum[ip] += -0.422;
4139 treesum[ip] += -0.891;
4141 if (dBt_37_11 < 3.577) {
4142 treesum[ip] += 0.719;
4144 treesum[ip] += -0.227;
4145 if (sstq[csstbox][ip] < 27.668) {
4146 treesum[ip] += -0.017;
4148 treesum[ip] += 0.472;
4150 if (sst_stdev[ip] < 0.481 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
4151 treesum[ip] += 0.094;
4153 treesum[ip] += -0.322;
4156 if (sst_stdev[ip] < 0.263 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
4157 treesum[ip] += 0.193;
4159 treesum[ip] += -0.276;
4161 }
else if (l2rec->l1rec->solz[ip] < solznight) {
4163 if (LtRED < (1000.0 - 0.1)) {
4170 if (rhotRED_min[ip] < 0.087 && rhotRED_min[ip] > (
BAD_FLT + 0.1)) {
4171 treesum[ip] += 1.017;
4173 treesum[ip] += -0.644;
4175 if (Bt11_min[ip] < 15.22) {
4176 treesum[ip] += -0.837;
4177 if (dBt_67_11 < -40.834) {
4178 treesum[ip] += 0.510;
4180 treesum[ip] += -0.181;
4183 treesum[ip] += 0.870;
4184 if (Tdeflong < 0.036) {
4185 treesum[ip] += -0.859;
4187 treesum[ip] += 0.215;
4190 if (l2rec->l1rec->lat[ip] < 29.675) {
4191 treesum[ip] += -0.099;
4193 treesum[ip] += 0.467;
4195 if (dBt_37_11 < 10.053) {
4196 treesum[ip] += -0.743;
4198 treesum[ip] += 0.137;
4201 if (rhoCirrus_max[ip] < 0.004 && rhoCirrus_max[ip] > (
BAD_FLT + 0.1)) {
4202 treesum[ip] += 0.227;
4203 if (rhotRED[ip] < 0.068 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
4204 treesum[ip] += 0.824;
4206 treesum[ip] += -0.113;
4208 if (rhoCirrus_maxmin[ip] < 0.001 && rhoCirrus_max[ip] > (
BAD_FLT + 0.1)) {
4209 treesum[ip] += 0.102;
4211 treesum[ip] += -0.454;
4214 treesum[ip] += -1.096;
4215 if (rhoCirrus < 0.006 && rhoCirrus > (
BAD_FLT + 0.1)) {
4216 treesum[ip] += 0.282;
4218 treesum[ip] += -0.810;
4221 if (sst_stdev[ip] < 0.397 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
4222 treesum[ip] += 0.235;
4223 if (l2rec->l1rec->lat[ip] < -0.365) {
4224 treesum[ip] += 0.240;
4226 treesum[ip] += -0.194;
4227 if (l2rec->l1rec->lon[ip] < -67.480) {
4228 treesum[ip] += 0.241;
4230 treesum[ip] += -0.229;
4233 if (sst_stdev[ip] < 0.188 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
4234 treesum[ip] += 0.187;
4236 treesum[ip] += -0.258;
4239 treesum[ip] += -0.848;
4241 if (sstq[csstbox][ip] < 27.278) {
4242 treesum[ip] += -0.066;
4244 treesum[ip] += 0.509;
4305 if (Bt12_min[ip] < 15.119) {
4306 treesum[ip] += -0.759;
4307 if (dBt_37_11 < 12.733) {
4308 treesum[ip] += 0.652;
4311 if (rhoCirrus_min[ip] < 0.001) {
4312 treesum[ip] += -1.096;
4314 treesum[ip] += 0.130;
4317 treesum[ip] += -0.288;
4319 if (Bt37_maxmin[ip] < 0.529 && Bt37_maxmin[ip] > (
BAD_FLT + 0.1)) {
4320 treesum[ip] += 0.926;
4322 treesum[ip] += 0.026;
4325 treesum[ip] += 0.794;
4326 if (dBt_37_11 < 8.37) {
4327 treesum[ip] += 0.522;
4329 treesum[ip] += -0.268;
4332 if (rhoCirrus_maxmin[ip] < 0.001 && rhoCirrus_max[ip] > (
BAD_FLT + 0.1)) {
4333 treesum[ip] += 0.381;
4334 if (rhoCirrus_max[ip] < 0.002 && rhoCirrus_max[ip] > (
BAD_FLT + 0.1)) {
4335 treesum[ip] += 0.006;
4337 treesum[ip] += -0.584;
4340 treesum[ip] += -0.619;
4342 if (sst_stdev[ip] < 0.397 && sst_stdev[ip] > (
BAD_FLT + 0.1)) {
4343 treesum[ip] += 0.101;
4345 treesum[ip] += -0.684;
4347 if (Tdeflong < 0.036) {
4348 treesum[ip] += -0.471;
4349 if (l2rec->l1rec->lat[ip] < 32.335) {
4350 treesum[ip] += -0.481;
4352 treesum[ip] += 0.684;
4355 treesum[ip] += 0.193;
4358 if (rhoCirrus_min[ip] < 0.003 && rhoCirrus_min[ip] > (
BAD_FLT + 0.1)) {
4359 treesum[ip] += 0.108;
4360 if (l2rec->l1rec->lat[ip] < -25.425) {
4361 treesum[ip] += 0.517;
4363 treesum[ip] += -0.082;
4364 if (l2rec->l1rec->lat[ip] < 27.215) {
4365 treesum[ip] += -0.077;
4366 if (Bt11 < 14.734) {
4367 treesum[ip] += -2.012;
4369 treesum[ip] += 0.089;
4372 treesum[ip] += 0.383;
4376 treesum[ip] += -0.913;
4378 if (sstq[csstbox][ip] < 27.583) {
4379 treesum[ip] += -0.074;
4381 treesum[ip] += 0.691;
4388 if (dBt_37_12 < 0.117) {
4389 treesum[ip] += -1.279;
4390 if (l2rec->l1rec->lat[ip] < 33.035) {
4391 treesum[ip] += -0.289;
4392 if (l2rec->l1rec->lat[ip] < -42.235) {
4393 treesum[ip] += 0.747;
4395 treesum[ip] += -0.564;
4396 if (Bt37 < 13.117) {
4397 treesum[ip] += -0.580;
4399 treesum[ip] += 0.638;
4403 treesum[ip] += 0.355;
4406 treesum[ip] += -0.307;
4408 treesum[ip] += 0.747;
4411 treesum[ip] += 0.470;
4412 if (Bt11_stdev[ip] < 0.155 && Bt11_stdev[ip] > (
BAD_FLT + 0.1)) {
4413 treesum[ip] += 0.690;
4414 if (Bt37_maxmin[ip] < 0.524 && Bt37_maxmin[ip] > (
BAD_FLT + 0.1)) {
4415 treesum[ip] += 0.150;
4417 treesum[ip] += -0.794;
4420 treesum[ip] += -0.430;
4422 if (dSST_SST4 < -0.787) {
4423 treesum[ip] += -1.404;
4424 if (dSST_SST4 < -1.253) {
4425 treesum[ip] += -1.086;
4427 treesum[ip] += 0.388;
4430 treesum[ip] += 0.197;
4431 if (Bt37_maxmin[ip] < 1.229 && Bt37_maxmin[ip] > (
BAD_FLT + 0.1)) {
4432 treesum[ip] += 0.287;
4433 if (dSST_SST4 < -0.383) {
4434 treesum[ip] += -0.531;
4436 treesum[ip] += 0.279;
4439 treesum[ip] += -0.497;
4441 if (Bt12 < 16.353) {
4442 treesum[ip] += -0.300;
4443 if (dBt_40_11 < -2.171) {
4444 treesum[ip] += 0.516;
4446 treesum[ip] += -0.395;
4447 if (sst4q[csstbox][ip] < 16.212) {
4448 treesum[ip] += -0.694;
4450 treesum[ip] += 0.392;
4454 treesum[ip] += 0.451;
4458 if (dBt_85_11 < -1.577) {
4459 treesum[ip] += 0.088;
4461 treesum[ip] += -0.408;
4465 if (treesum[ip] <= 0.0) {
4470 else if (l2rec->l1rec->l1file->sensorID ==
VIIRSN) {
4475 if (l2rec->l1rec->solz[ip] < solznight) {
4481 if (dBt_11_12 < 0.23435 ||
4482 Bt12 < (270.78 -
CtoK)) {
4484 }
else if (Bt37_maxmin[ip] >= 0.40919 &&
4485 (Bt37_maxmin[ip] >= 1.0765 ||
4486 Bt12_maxmin[ip] >= 0.8412 ||
4487 Bt12_maxmin[ip] < 0.3193)) {
4493 if (dBt_37_11 < 0.18654) {
4495 }
else if (dSST_SST3 < -1.021674) {
4496 if (dBt_11_12 < 2.187215 || dBt_37_11 >= 5.46243) {
4499 }
else if (Bt37_maxmin[ip] >= 0.48349) {
4500 if (dBt_11_12 < 0.32251 || dSST_SST3 >= 0.4414579) {
4502 }
else if (Bt37_maxmin[ip] >= 1.012265) {
4503 if (dBt_11_12 < 0.951295 || Bt12_maxmin[ip] < 0.69827) {
4507 if (l2rec->l1rec->senz[ip] > 56.3) {
4508 if (dBt_37_11 < 1.101845 || dBt_11_12 >= 1.308475) {
4518 if (l2rec->l1rec->solz[ip] >= solznight) {
4520 treesum[ip] = 0.413;
4521 if (dBt_37_11 < 0.115) {
4522 treesum[ip] += -1.931;
4524 treesum[ip] += 0.496;
4525 if (dSST_SST3 < -0.465) {
4526 treesum[ip] += -0.942;
4527 if (dSST_SST3 < -1.102) {
4528 treesum[ip] += -0.735;
4529 if (dBt_37_11 < 1.686) {
4530 treesum[ip] += 0.651;
4532 treesum[ip] += -0.82;
4535 treesum[ip] += 0.207;
4538 treesum[ip] += 0.309;
4539 if (dSST_SST3 < 0.78) {
4540 treesum[ip] += 0.043;
4541 if (dSST_SST3 < -0.158) {
4542 treesum[ip] += -0.392;
4544 treesum[ip] += 0.194;
4547 treesum[ip] += -1.069;
4549 if (dBt_37_11 < 0.306) {
4550 treesum[ip] += -0.692;
4552 treesum[ip] += 0.077;
4555 if (Bt12 < 287.407) {
4556 treesum[ip] += -0.339;
4558 treesum[ip] += 0.426;
4561 if (sstq[csstbox][ip] < (270.414 -
CtoK)) {
4562 treesum[ip] += -3.879;
4564 treesum[ip] += 0.047;
4565 if (Bt37_stdev[ip] < 0.247 && Bt37_stdev[ip] > (
BAD_FLT + 0.1)) {
4566 treesum[ip] += 0.176;
4568 treesum[ip] += -0.187;
4571 if (treesum[ip] <= 0.0) {
4576 }
else if (l2rec->l1rec->glint_coef[ip] <= glintmax) {
4589 xrad = (360.0 / 365.0) * xdoy /
RADEG;
4590 subsolar = 23.45 * sin(xrad);
4592 if (rhotRED[ip] > 0.3 &&
4593 rhot16[ip] >= 0.006 && rhot16[ip] < 0.1 &&
4594 ((l2rec->l1rec->lat[ip] > (subsolar + 30.0)) || (l2rec->l1rec->lat[ip] < (subsolar - 30.0)))) {
4604 if (rhot16[ip] < 0.16 && Lt16 > (
BAD_FLT + 0.1) && Lt16 < (1000.0 - 0.1)) {
4605 treesum[ip] += 0.805;
4606 if (rhotNIR7[ip] < 0.062 && LtNIR7 > (
BAD_FLT + 0.1) && LtNIR7 < (1000.0 - 0.1)) {
4607 treesum[ip] += 0.393;
4608 if (rhoCirrus < 0.004 && rhoCirrus > (
BAD_FLT + 0.1)) {
4609 treesum[ip] += 0.287;
4610 if (Tdeflong < 0.002) {
4611 treesum[ip] += -0.681;
4613 treesum[ip] += 0.026;
4614 if (rhotNIR7[ip] < 0.039 && LtNIR7 > (
BAD_FLT + 0.1) && LtNIR7 < (1000.0 - 0.1)) {
4615 treesum[ip] += 0.364;
4617 treesum[ip] += -0.21;
4621 treesum[ip] += -1.244;
4624 treesum[ip] += -0.0572;
4626 if (rhot16_min[ip] < 0.032 && rhot16_min[ip] > (
BAD_FLT + 0.1)) {
4627 treesum[ip] += 0.455;
4629 treesum[ip] += -0.395;
4632 if (l2rec->l1rec->senz[ip] < 64.994) {
4633 treesum[ip] += 0.216;
4634 if (rhoCirrus < 0.007 && rhoCirrus > (
BAD_FLT + 0.1)) {
4635 treesum[ip] += 0.065;
4637 treesum[ip] += -1.077;
4640 treesum[ip] += -0.708;
4643 treesum[ip] += -1.755;
4644 if (rhot16[ip] < 0.266 && Lt16 > (
BAD_FLT + 0.1) && Lt16 < (1000.0 - 0.1)) {
4645 treesum[ip] += 0.642;
4647 treesum[ip] += -0.19;
4648 if (rhotRED_maxmin[ip] < 0.103 && rhotRED_maxmin[ip] > (
BAD_FLT + 0.1)) {
4649 treesum[ip] += 0.425;
4651 treesum[ip] += -0.195;
4654 if (dBt_11_12 < 0.235) {
4655 treesum[ip] += -0.189;
4657 treesum[ip] += 0.411;
4659 if (l2rec->l1rec->wv[ip] < 2.946) {
4660 treesum[ip] += 0.038;
4662 treesum[ip] += -1.137;
4665 if (Bt11_maxmin[ip] < 0.762 && Bt11_maxmin[ip] > (
BAD_FLT + 0.1)) {
4666 treesum[ip] += 0.156;
4668 treesum[ip] += -0.188;
4670 if (l2rec->l1rec->wv[ip] < 1.315) {
4671 treesum[ip] += 0.327;
4673 treesum[ip] += -0.054;
4674 if (sstq[csstbox][ip] < (278.171 -
CtoK)) {
4675 treesum[ip] += -0.679;
4677 treesum[ip] += 0.05;
4685 if (rhotRED[ip] > 0.065) {
4689 if (Bt85_min[ip] < (287.451 -
CtoK)) {
4690 treesum[ip] += -0.812;
4691 if (l2rec->l1rec->lat[ip] < 32.315) {
4692 treesum[ip] += -0.296;
4693 if (Tdeflong < 0.001) {
4694 treesum[ip] += -1.109;
4695 if (l2rec->l1rec->lat[ip] < -30.0) {
4696 treesum[ip] += 0.525;
4698 treesum[ip] += -1.827;
4701 treesum[ip] += 0.44;
4703 if (l2rec->l1rec->wv[ip] < 2.065) {
4704 treesum[ip] += 0.49;
4706 treesum[ip] += -1.104;
4707 if (Bt85 < (287.059 -
CtoK)) {
4708 treesum[ip] += -1.071;
4710 treesum[ip] += 0.727;
4714 treesum[ip] += 0.669;
4716 if (dBt_37_11 < 17.594) {
4717 treesum[ip] += 0.452;
4719 treesum[ip] += -0.76;
4722 treesum[ip] += 0.858;
4723 if (l2rec->l1rec->lon[ip] < -69.475) {
4724 treesum[ip] += 0.512;
4726 treesum[ip] += -0.176;
4727 if (l2rec->l1rec->lat[ip] < 1.01) {
4728 treesum[ip] += 0.64;
4730 treesum[ip] += -0.176;
4732 treesum[ip] += 0.69;
4734 treesum[ip] += -0.305;
4738 if (dBt_37_11 < 9.655) {
4739 treesum[ip] += 0.562;
4741 treesum[ip] += -0.173;
4743 if (Bt85 < (290.343 -
CtoK)) {
4744 treesum[ip] += -0.39;
4746 treesum[ip] += 0.243;
4747 if (Tdeflong < 0.003) {
4748 treesum[ip] += -0.817;
4750 treesum[ip] += 0.267;
4753 if (l2rec->l1rec->lat[ip] < 22.465) {
4754 treesum[ip] += -0.206;
4756 treesum[ip] += 0.523;
4759 if (Bt11_maxmin[ip] < 1.189 && Bt11_maxmin[ip] > (
BAD_FLT + 0.1)) {
4760 treesum[ip] += 0.059;
4762 treesum[ip] += -1.22;
4768 if (rhotNIR7_min[ip] < 0.104 && rhotNIR7_min[ip] > (
BAD_FLT + 0.1)) {
4769 treesum[ip] += 0.91;
4770 if (rhotRED[ip] < 0.086 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
4771 treesum[ip] += 0.518;
4773 if (rhotRED_min[ip] < 0.067 && rhotRED_min[ip] > (
BAD_FLT + 0.1)) {
4774 treesum[ip] += 0.558;
4776 treesum[ip] += -0.263;
4778 if (rhot16[ip] < 0.06 || Lt16 > (1000.0 - 0.1)) {
4779 treesum[ip] += -0.231;
4781 treesum[ip] += 1.712;
4784 if (rhot16[ip] < 0.046 || Lt16 > (1000.0 - 0.1)) {
4785 treesum[ip] += -1.353;
4787 treesum[ip] += 0.352;
4791 treesum[ip] += -0.585;
4792 if (dBt_37_12 < 12.951) {
4793 treesum[ip] += -0.905;
4795 treesum[ip] += 0.187;
4796 if (rhotRED[ip] < 0.098 && LtRED > (
BAD_FLT + 0.1) && LtRED < (1000.0 - 0.1)) {
4797 treesum[ip] += 0.549;
4799 treesum[ip] += -0.484;
4804 treesum[ip] += -1.819;
4806 if (rhotRED_min[ip] < 0.206 && rhotRED_min[ip] > (
BAD_FLT + 0.1)) {
4807 treesum[ip] += 0.467;
4809 treesum[ip] += -1.18;
4810 if (rhotRED_maxmin[ip] < 0.037 && rhotRED_maxmin[ip] > (
BAD_FLT + 0.1)) {
4811 treesum[ip] += 1.747;
4813 treesum[ip] += -1.79;
4816 if (l2rec->l1rec->wv[ip] < 1.705) {
4817 treesum[ip] += 0.434;
4819 treesum[ip] += -0.645;
4822 if (rhoCirrus < 0.002 && rhoCirrus > (
BAD_FLT + 0.1)) {
4823 treesum[ip] += 0.23;
4824 if (l2rec->l1rec->lat[ip] < 32.13) {
4825 treesum[ip] += -0.067;
4826 if (sstq[csstbox][ip] < (300.034 -
CtoK)) {
4827 treesum[ip] += -0.146;
4829 treesum[ip] += 0.824;
4832 treesum[ip] += 0.758;
4835 treesum[ip] += -1.153;
4837 if (rhoCirrus_min[ip] < 0.005 && rhoCirrus_min[ip] > (
BAD_FLT + 0.1)) {
4838 treesum[ip] += 0.28;
4840 treesum[ip] += -0.939;
4843 if (l2rec->l1rec->senz[ip] < 33.204) {
4846 treesum[ip] += -0.331;
4850 if (treesum[ip] <= 0.0) {
4860 if (l2rec->l1rec->l1file->sensorID ==
AVHRR) {
4864 if (l2rec->l1rec->lat[ip] < 0.0
4865 && ((ASCEND == 1 && l2rec->l1rec->pixnum[ip] <= cpix)
4866 || (ASCEND == 0 && l2rec->l1rec->pixnum[ip] > cpix))
4867 && l2rec->l1rec->senz[ip] > 45.00) {
4884 extern l1qstr
l1que;
4885 int32_t
npix = l2rec->l1rec->npix;
4887 float Bt37, Bt39, Bt40, Bt85;
4889 float dBt_37_12, dBt_40_11, dBt_85_11;
4896 for (ip = 0; ip <
npix; ip++) {
4898 d3940ref[ip] = sstbad;
4901 if (
sstmasked(l2rec->l1rec->flags, ip)) {
4908 Bt37 = l2rec->l1rec->Bt[ipbir + ib37];
4909 Bt39 = l2rec->l1rec->Bt[ipbir + ib39];
4910 Bt40 = l2rec->l1rec->Bt[ipbir + ib40];
4911 Bt85 = l2rec->l1rec->Bt[ipbir + ib85];
4912 Bt11 = l2rec->l1rec->Bt[ipbir + ib11];
4913 Bt12 = l2rec->l1rec->Bt[ipbir + ib12];
4916 if ((l2rec->l1rec->l1file->sensorID ==
MODISA)
4917 && l2rec->l1rec->detnum == 0) {
4924 dBt_37_12 = Bt37 - Bt12;
4925 dBt_40_11 = Bt40 - Bt11;
4926 dBt_85_11 = Bt85 - Bt11;
4929 if (Bt39 < BT_LO + 0.1 || Bt39 >
BT_HI - 0.1 || Bt40 <
BT_LO + 0.1
4930 || Bt40 >
BT_HI - 0.1) {
4936 if (Bt39 < Btmin || Bt39 > Btmax || Bt40 < Btmin || Bt40 > Btmax40)
4940 dBt_34 = Bt39 - Bt40;
4941 if (dBt_34 < dBt4min || dBt_34 > dBt4max)
4947 d3940ref[ip] =
btrefdiffv6(ip, Bt39, Bt40, l2rec);
4949 if (d3940ref[ip] < dBtrefmin || d3940ref[ip] > dBtrefmax)
4953 if (sst4q[csstbox][ip] < SSTmin || sst4q[csstbox][ip] > SSTmaxn)
4957 if (sst4q[csstbox][ip] < sstbad + 1.0 || l2rec->l1rec->sstref[ip] < sstbad + 1.0) {
4960 dSST4_ref = sst4q[csstbox][ip] - l2rec->l1rec->sstref[ip];
4963 if ((evalmask &
SSTMODS) == 0) {
4966 if (dSST4_ref < -SSTdiff || l2rec->
l1rec->sstref[ip] < sstbad + 1.0)
4968 if (dSST4_ref < -input->sstrefdif &&
4969 l2rec->l1rec->lat[ip] >= equatorialSouth && l2rec->l1rec->lat[ip] <= equatorialNorth &&
4970 l2rec->l1rec->lon[ip] >= equatorialWest && l2rec->l1rec->lon[ip] <= equatorialEast) {
4976 if (l2rec->l1rec->solz[ip] >= solznight) {
4977 if (
fabs(dSST4_ref) > SSTdiff)
4979 if (
fabs(dSST4_ref) > SSTvdiff)
4983 if (dSST4_ref < -SSTvdiff || l2rec->
l1rec->sstref[ip] < sstbad + 1.0)
4986 if (l2rec->l1rec->solz[ip] >=
SOLZNIGHT) {
4987 if (
fabs(dSST4_ref) > SSTdiff)
4990 if (dSST4_ref < -SSTdiff || dSST4_ref > (SSTdiff + 1))
4993 if (
fabs(dSST4_ref) > SSTvdiff)
4997 dSST_SST4 = sstq[csstbox][ip] - sst4q[csstbox][ip];
4998 if (sstq[csstbox][ip] > sstbad + 1.0) {
4999 if (
fabs(dSST_SST4) < SST4diff1)
5001 if (
fabs(dSST_SST4) < SST4diff2)
5006 if (l2rec->l1rec->senz[ip] > hisenz)
5008 if (l2rec->l1rec->senz[ip] > vhisenz)
5011 if (l2rec->l1rec->pixnum[ip] < 2 || l2rec->l1rec->pixnum[ip] > (fullscanpix - 3))
5015 if ((l2rec->l1rec->l1file->sensorID ==
MODIST) && (l2rec->l1rec->pixnum[ip] > 1349))
5027 if (Bt39_maxmin[ip] > Bt39unif1)
5029 if (Bt39_maxmin[ip] > Bt39unif2)
5032 if (Bt40_maxmin[ip] > Bt40unif1)
5034 if (Bt40_maxmin[ip] > Bt40unif2)
5038 if (l2rec->l1rec->solz[ip] >= solznight) {
5039 if (l2rec->l1rec->l1file->sensorID ==
MODIST) {
5042 if (dBt_37_12 < -0.053) {
5043 treesum[ip] += -1.257;
5044 if (l2rec->l1rec->lat[ip] < 33.195) {
5045 treesum[ip] += -0.278;
5046 if (l2rec->l1rec->lat[ip] < -40.185) {
5047 treesum[ip] += 0.619;
5049 treesum[ip] += -0.711;
5051 treesum[ip] += -3.733;
5053 treesum[ip] += -0.111;
5057 treesum[ip] += 0.333;
5060 treesum[ip] += -0.292;
5062 treesum[ip] += 0.764;
5065 treesum[ip] += 0.430;
5066 if (Bt11_maxmin[ip] < 0.486 && Bt11_maxmin[ip] > (
BAD_FLT + 0.1)) {
5067 treesum[ip] += 0.628;
5068 if (Bt40_stdev[ip] < 0.146) {
5069 treesum[ip] += 0.177;
5071 treesum[ip] += -0.723;
5074 treesum[ip] += -0.450;
5076 if (dSST_SST4 < -0.878) {
5077 treesum[ip] += -1.353;
5078 if (dSST_SST4 < -1.533) {
5079 treesum[ip] += -1.439;
5081 treesum[ip] += 0.346;
5084 treesum[ip] += 0.219;
5085 if (Bt37_stdev[ip] < 0.448) {
5086 treesum[ip] += 0.290;
5087 if (dSST_SST4 < -0.422) {
5088 treesum[ip] += -0.504;
5090 treesum[ip] += 0.268;
5093 treesum[ip] += -0.484;
5095 if (Bt12 < 16.736) {
5096 treesum[ip] += -0.285;
5097 if (dBt_40_11 < -2.199) {
5098 treesum[ip] += 0.518;
5100 treesum[ip] += -0.316;
5101 if (Bt12 < 11.896) {
5102 treesum[ip] += -0.527;
5104 treesum[ip] += 0.400;
5108 treesum[ip] += 0.500;
5110 if (dSST_SST4 < 1.183) {
5111 treesum[ip] += 0.051;
5113 treesum[ip] += -0.898;
5118 }
else if (l2rec->l1rec->l1file->sensorID ==
MODISA) {
5123 if (dBt_37_12 < 0.117) {
5124 treesum[ip] += -1.279;
5125 if (l2rec->l1rec->lat[ip] < 33.035) {
5126 treesum[ip] += -0.289;
5127 if (l2rec->l1rec->lat[ip] < -42.235) {
5128 treesum[ip] += 0.747;
5130 treesum[ip] += -0.564;
5131 if (Bt37 < 13.117) {
5132 treesum[ip] += -0.580;
5134 treesum[ip] += 0.638;
5138 treesum[ip] += 0.355;
5141 treesum[ip] += -0.307;
5143 treesum[ip] += 0.747;
5146 treesum[ip] += 0.470;
5147 if (Bt11_stdev[ip] < 0.155) {
5148 treesum[ip] += 0.690;
5149 if (Bt37_maxmin[ip] < 0.524 && Bt37_maxmin[ip] > (
BAD_FLT + 0.1)) {
5150 treesum[ip] += 0.150;
5152 treesum[ip] += -0.794;
5155 treesum[ip] += -0.430;
5157 if (dSST_SST4 < -0.787) {
5158 treesum[ip] += -1.404;
5159 if (dSST_SST4 < -1.253) {
5160 treesum[ip] += -1.086;
5162 treesum[ip] += 0.388;
5165 treesum[ip] += 0.197;
5166 if (Bt37_maxmin[ip] < 1.229 && Bt37_maxmin[ip] > (
BAD_FLT + 0.1)) {
5167 treesum[ip] += 0.287;
5168 if (dSST_SST4 < -0.383) {
5169 treesum[ip] += -0.531;
5171 treesum[ip] += 0.279;
5174 treesum[ip] += -0.497;
5176 if (Bt12 < 16.353) {
5177 treesum[ip] += -0.300;
5178 if (dBt_40_11 < -2.171) {
5179 treesum[ip] += 0.516;
5181 treesum[ip] += -0.395;
5182 if (sst4q[csstbox][ip] < 16.212) {
5183 treesum[ip] += -0.694;
5185 treesum[ip] += 0.392;
5189 treesum[ip] += 0.451;
5193 if (dBt_85_11 < -1.577) {
5194 treesum[ip] += 0.088;
5196 treesum[ip] += -0.408;
5200 if (treesum[ip] <= 0.0) {
5218 for (ip = 0; ip < l2rec->l1rec->npix; ip++) {
5220 if (l2rec->l1rec->l1file->sensorID ==
AVHRR) {
5259 if (l2rec->l1rec->ssttype[ip] == 0 && qual_sst[ip] < 4) {
5267 if (l2rec->l1rec->solz[ip] < solznight) {
5282 || l2rec->l1rec->ssttype[ip] == 0) {
5286 }
else if (((
input->viirsnv7 >= 1)
5293 }
else if (((
input->viirsnv7 <= 0)
5295 || (l2rec->l1rec->glint_coef[ip] > glintmax)
5312 if (haveRed && l2rec->
l1rec->glint_coef[ip] <= glintmax) {
5313 ipb = ip * nbvis + ibred;
5318 rhot =
PI * l2rec->l1rec->Lt[ipb] / l2rec->l1rec->Fo[ibred];
5319 if (qual_sst[ip] < 3 && sstq[csstbox][ip] - l2rec->l1rec->sstref[ip] < -1.0
5322 if ((
input->viirsnv7 >= 1)
5323 && (qual_sst[ip] == 1)) {
5353 || ((
input->viirsnv7 >= 1)
5355 || ((
input->viirsnv7 >= 1)
5357 || ((
input->viirsnv7 >= 1)
5365 }
else if (((
input->viirsnv7 <= 0)
5367 || ((
input->viirsnv7 <= 0)
5369 || ((
input->viirsnv7 <= 0)
5382 if (haveSST4 && sst4q[csstbox][ip] > sstbad + 1.0) {
5383 if (qual_sst[ip] < 3
5386 if ((
input->viirsnv7 >= 1) && (qual_sst[ip] == 1)) {
5408 for (ip = 0; ip < l2rec->l1rec->npix; ip++) {
5410 if (l2rec->l1rec->solz[ip] < solznight) {
5473 float nlsst(
float Bt11,
float Bt12, int32_t
is,
float sstref,
5474 float **bounds,
float **coef,
float sstrefoffday,
5475 float sstrefoffnight, int32_t ip, int32_t xsatid,
5476 size_t nlatbands,
size_t ncoefficients) {
5477 extern l1qstr
l1que;
5478 static float dBtlo = 0.5;
5479 static float dBthi = 0.9;
5487 float dBt = Bt11 - Bt12;
5488 float sstlo, ssthi, lsst;
5495 int ic = nlatbands - 1;
5496 while ((ic > 0) && (
lat <= bounds[ic - 1][1] + latwin)) {
5501 if (
l1que.r[
is].solz[ip] >= solznight)
5502 sstref = sstref + sstrefoffnight;
5504 sstref = sstref + sstrefoffday;
5518 satzdir = (
l1que.r[
is].pixnum[ip] < fullscanpix / 2) ? -1.0 : 1.0;
5522 if (xsatid ==
NO16) {
5527 printf(
"ERROR - need nlatbands >= 2, found %ld\n", nlatbands);
5530 if(ncoefficients < 4) {
5531 printf(
"ERROR - need ncoefficients >= 4, found %ld\n", ncoefficients);
5535 lsst = coef[0][0] + coef[0][1] * Bt11 + coef[0][2] * dBt * sstref + coef[0][3] * dBt * ((1.0 /
mu) - 1.0);
5536 else if (dBt >= dBthi)
5537 lsst = coef[1][0] + coef[1][1] * Bt11 + coef[1][2] * dBt * sstref + coef[1][3] * dBt * ((1.0 /
mu) - 1.0);
5539 sstlo = coef[0][0] + coef[0][1] * Bt11 + coef[0][2] * dBt * sstref + coef[0][3] * dBt * ((1.0 /
mu) - 1.0);
5540 ssthi = coef[1][0] + coef[1][1] * Bt11 + coef[1][2] * dBt * sstref + coef[1][3] * dBt * ((1.0 /
mu) - 1.0);
5541 lsst = sstlo + ((dBt - dBtlo) / (dBthi - dBtlo))*(ssthi - sstlo);
5544 }
else if (
input->viirsnosisaf == 1) {
5545 if (
l1que.r[
is].solz[ip] >= solznight)
5552 if(ncoefficients < 7) {
5553 printf(
"ERROR - need ncoefficients >= 7, found %ld\n", ncoefficients);
5557 + (coef[ic][1] + coef[ic][2] * ((1.0 /
mu) - 1.0)) * Bt11
5558 + (coef[ic][3] + coef[ic][4] * sstref + coef[ic][5] * ((1.0 /
mu) - 1.0)) * dBt
5559 + coef[ic][6] * ((1.0 /
mu) - 1.0);
5561 }
else if (
input->viirsnv7 >= 1) {
5565 if (ncoefficients < 7) {
5566 printf(
"ERROR - need ncoefficients >= 7, found %ld\n", ncoefficients);
5569 if (
lat < bounds[ic][1] - latwin || ic == (nlatbands - 1)) {
5570 lsst = coef[ic][0] + coef[ic][1] * Bt11 + coef[ic][2] * dBt * sstref
5571 + coef[ic][3] * dBt * ((1.0 /
mu) - 1.0)
5572 + coef[ic][4] * ((1.0 /
mu) - 1.0)
5573 + coef[ic][5] * pow(((1.0 /
mu) - 1.0), coef[ic][6]);
5576 dBtlo = bounds[ic][1] - latwin;
5577 dBthi = bounds[ic][1] + latwin;
5578 sstlo = coef[ic][0] + coef[ic][1] * Bt11 + coef[ic][2] * dBt * sstref
5579 + coef[ic][3] * dBt * ((1.0 /
mu) - 1.0)
5580 + coef[ic][4] * ((1.0 /
mu) - 1.0)
5581 + coef[ic][5] * pow(((1.0 /
mu) - 1.0), coef[ic][6]);
5582 ssthi = coef[ic + 1][0] + coef[ic + 1][1] * Bt11
5583 + coef[ic + 1][2] * dBt * sstref
5584 + coef[ic + 1][3] * dBt * ((1.0 /
mu) - 1.0)
5585 + coef[ic + 1][4] * ((1.0 /
mu) - 1.0)
5586 + coef[ic + 1][5] * pow(((1.0 /
mu) - 1.0), coef[ic + 1][6]);
5588 lsst = sstlo + ((
lat - dBtlo) / (dBthi - dBtlo)) * (ssthi - sstlo);
5599 static int last_ic = -1;
5602 C0 = (
float *) calloc(7,
sizeof(
float));
5603 C1 = (
float *) calloc(7,
sizeof(
float));
5605 if (last_ic != ic) {
5606 for (
i = 0;
i < ncoefficients;
i++){
5611 C0[
j] = coef[ic][
i];
5612 if (ic < nlatbands -1)
5613 C1[
j] = coef[ic + 1][
i];
5616 if (
lat < bounds[ic][1] - latwin || ic == (nlatbands - 1)) {
5619 + C0[2] * dBt * sstref
5620 + C0[3] * dBt * ((1.0 /
mu) - 1.0)
5622 + C0[5] * (
l1que.r[
is].senz[ip] * satzdir)
5623 + C0[6] * pow((
l1que.r[
is].senz[ip] * satzdir), 2);
5625 dBtlo = bounds[ic][1] - latwin;
5626 dBthi = bounds[ic][1] + latwin;
5629 + C0[2] * dBt * sstref
5630 + C0[3] * dBt * ((1.0 /
mu) - 1.0)
5632 + C0[5] * (
l1que.r[
is].senz[ip] * satzdir)
5633 + C0[6] * pow((
l1que.r[
is].senz[ip] * satzdir), 2);
5636 +
C1[2] * dBt * sstref
5637 +
C1[3] * dBt * ((1.0 /
mu) - 1.0)
5639 +
C1[5] * (
l1que.r[
is].senz[ip] * satzdir)
5640 +
C1[6] * pow((
l1que.r[
is].senz[ip] * satzdir), 2);
5642 lsst = sstlo + ((
lat - dBtlo) / (dBthi - dBtlo)) * (ssthi - sstlo);