ocssw  1.0
/disk01/web/ocssw/build/src/l2gen/turbid.c (r8096/r2592)
Go to the documentation of this file.
00001 #include "l12_proto.h"
00002 #define TI_BAD -999.
00003 
00004 
00005 void tindx_shi(l2str *l2rec, int32_t ipix, float *tindx)
00006 {
00007     static int32_t mask = LAND | CLOUD;
00008 
00009     static int32_t ib748  =   -1;
00010     static int32_t ib1240 =   -1;
00011     static int32_t ib2130 =   -1;
00012 
00013     float dr748;
00014     float dr1240;
00015     float dr2130;
00016 
00017     int32_t  ip,ip1,ip2,ipb;
00018 
00019     if (ipix < 0) {
00020         ip1 = 0;
00021         ip2 = l2rec->npix-1;
00022     } else {
00023         ip1 = ipix;
00024         ip2 = ipix;
00025     }
00026 
00027     if (ib748 == -1) {
00028         if ((ib748 = windex(748.0,l2rec->fwave,l2rec->nbands)) < 0) {
00029         printf("tindx_shi: incompatible sensor wavelengths (no 748).\n");
00030             exit(1);
00031     }
00032         if ((ib1240 = windex(1240.0,l2rec->fwave,l2rec->nbands)) < 0) {
00033         printf("tindx_shi: incompatible sensor wavelengths (no 1240).\n");
00034             exit(1);
00035     }
00036         if ((ib2130 = windex(2130.0,l2rec->fwave,l2rec->nbands)) < 0) {
00037         printf("tindx_shi: incompatible sensor wavelengths (no 2130).\n");
00038             exit(1);
00039     }
00040     }
00041 
00042     for (ip=ip1; ip<=ip2; ip++) {
00043 
00044         ipb = ip*NBANDS+ib748; 
00045         dr748  = (l2rec->Lt[ipb]/l2rec->tg_sol[ipb]/l2rec->tg_sen[ipb] - l2rec->Lr[ipb])/l2rec->Fobar[ib748 ];
00046 
00047         ipb = ip*NBANDS+ib1240; 
00048         dr1240 = (l2rec->Lt[ipb]/l2rec->tg_sol[ipb]/l2rec->tg_sen[ipb] - l2rec->Lr[ipb])/l2rec->Fobar[ib1240];
00049 
00050         ipb = ip*NBANDS+ib2130;
00051     dr2130 = (l2rec->Lt[ipb]/l2rec->tg_sol[ipb]/l2rec->tg_sen[ipb] - l2rec->Lr[ipb])/l2rec->Fobar[ib2130];
00052 
00053         if (((l2rec->flags[ip] & mask) != 0) || dr1240 <= 0.0 || dr2130 <= 0.0)
00054         *tindx++ = TI_BAD;
00055     else
00056       /*  *tindx++ = (dr748/dr1240)*exp(-(492./890.)*log(dr1240/dr2130)); */
00057         *tindx++ = (dr748/dr1240)*pow((dr1240/dr2130),-(492./890.));
00058     }
00059 
00060     return;
00061 }
00062 
00063 
00064 
00065 void tindx_morel(l2str *l2rec, int32_t ipix, float *tindx)
00066 {
00067     static int32_t ib560 = -1;
00068 
00069     float chl;
00070     float Rrs;
00071     float Rrs_lim;
00072     float X;
00073     int32_t  ip,ip1,ip2;
00074 
00075     if (ipix < 0) {
00076         ip1 = 0;
00077         ip2 = l2rec->npix-1;
00078     } else {
00079         ip1 = ipix;
00080         ip2 = ipix;
00081     }
00082 
00083     if (ib560 == -1) {
00084         if ((ib560 = windex(560.0,l2rec->fwave,l2rec->nbands)) < 0) {
00085         printf("turbid_morel: incompatible sensor wavelengths (no 560).\n");
00086             exit(1);
00087     }
00088     printf("turbid_morel: using %f nm for 560.\n",l2rec->fwave[ib560]);
00089     }
00090 
00091     for (ip=ip1; ip<=ip2; ip++) {
00092 
00093         chl = l2rec->chl[ip];
00094         Rrs = l2rec->Rrs[ip*NBANDS+ib560];
00095 
00096         if (l2rec->mask[ip] || chl <= 0.0 || Rrs <= 0.0) {
00097         *tindx++ = TI_BAD;
00098             l2rec->flags[ip] |= PRODFAIL;
00099         } else if (chl <= 0.2) {
00100         *tindx++ = -100;
00101     } else {
00102         X = log10(MIN(chl,10));
00103         Rrs_lim = 0.00331 + X*(0.002122 + X*(0.00031587 - X*0.00023145)); 
00104             *tindx++ = 100.0 * (Rrs - Rrs_lim)/Rrs;
00105     }
00106     }
00107 
00108     return;
00109 }
00110