15 #include <boost/math/interpolators/barycentric_rational.hpp>
223 memset(mtable_, 0, NLSIZE*
sizeof(
int));
224 memset(refl_ray_nl_, 0, NLWAV*
sizeof(
float));
225 memset(opth_nl_, 0, NLSIZE*NLWAV*NLTAU*
sizeof(
float));
226 memset(int_nl_, 0, NLSIZE*NLWAV*NLTAU*
sizeof(
float));
227 memset(fd_nl_, 0, NLSIZE*NLWAV*NLTAU*
sizeof(
float));
228 memset(t_nl_, 0, NLSIZE*NLWAV*NLTAU*
sizeof(
float));
229 memset(fdt_nl_, 0, NLSIZE*NLWAV*NLTAU*
sizeof(
float));
230 memset(sbar_nl_, 0, NLSIZE*NLWAV*NLTAU*
sizeof(
float));
231 memset(refl_inter_, 0, NLWAV*GRIDX*GRIDY*
sizeof(
float));
232 memset(refl_, 0, NLWAV*
sizeof(
float));
233 memset(sdev_, 0, NLWAV*
sizeof(
float));
235 memset(rho_star_, 0, NLSIZE*NLWAV*NLTAU*
sizeof(
float));
236 memset(rho_star_tot_, 0, NLWAV*NLTAU*
sizeof(
float));
237 memset(rho_S212_, 0, NLSIZE*NLTAU*
sizeof(
float));
238 memset(rho_S212_tot_, 0, NLTAU*
sizeof(
float));
239 memset(errwave_, 0, NLWAV*
sizeof(
float));
247 memset(aot_d_, 0, NLWAV*
sizeof(
float));
248 memset(aot_f_, 0, NLWAV*
sizeof(
float));
249 memset(aot_c_, 0, NLWAV*
sizeof(
float));
250 memset(rho_sfc_, 0, NLWAV*
sizeof(
float));
257 memset(good_pixels_, 0, NLWAV*
sizeof(
int));
263 return_quality_cirrus_= 0;
266 memset(quality_flag_for_joint_, 0, 2*
sizeof(
short));
267 quality_flag_for_retr_= 0;
268 qcontrol_special_= 0;
269 memset(sds_qcontrol_, 0, QA_LAND*
sizeof(
short));
270 sds_aerosol_type_= 0;
272 sds_fitting_error_= 0;
274 sds_cloud_fraction_= 0;
276 sds_dust_weighting_= 0;
278 memset(sds_numpixels_, 0, NLWAV*
sizeof(
float));
279 memset(sds_tau_corrected_, 0, NLWAV*
sizeof(
float));
280 memset(sds_refl_, 0, NLWAV*
sizeof(
float));
281 memset(sds_refl_std_, 0, NLWAV*
sizeof(
float));
282 memset(sds_tau_small_, 0, NLWAV*
sizeof(
float));
283 memset(sds_tau_big_, 0, NLWAV*
sizeof(
float));
284 memset(sds_surface_reflectance_, 0, NLWAV*
sizeof(
float));
312 int status = DTDB_SUCCESS;
333 map<string, ddata*> imap)
353 if((solz_ >= MINMTHET0) && (solz_ <= MAXMTHET0) &&
354 (senz_ >= MINMTHET) && (senz_ <= MAXMTHET) &&
355 (raa_ >= MINMPHI) && (raa_ <= MAXMPHI) && rfld_[D488] > 0.0)
358 compute_gas_correction();
370 cm_->compute(cmask_);
372 cloud_mask_ = (cmask_+1)%2;
375 cmask_ = (cloud_mask_+1)%2;
377 if (!bcloudmask_) cmask_ = 1;
378 if (bcloudmask_ && cloud_mask_) {
383 index_geometry(solz_, senz_, raa_);
384 compute_glint_angle();
385 compute_scatter_angle(scatter_angle_);
386 interpolate_rayleigh();
390 thresh_min_ = THR213MIN_1;
391 thresh_max_ = THR213MAX_1;
397 int ilon = 180 + round(lon_ + DLON);
398 int ilat = 90 - round(lat_ + DLAT);
404 mtable_[
ISMALL] = lut_.AEROSOL_ALL[season_][ilat][ilon] + 1;
405 mtable_[
IBIG] = DTABLE-1;
407 index_geometry( solz_, senz_, raa_);
409 interpolate_elevation();
413 if (aot_d_[
DL670] > 0) {
414 angstrom_ = -1.0 * log(aot_d_[
DL488]/aot_d_[
DL670])/ log(0.466/0.644);
418 iaer_ = mtable_[
ISMALL]+1;
427 qual_flag_ = quality_flag_for_joint_[0];
428 aerosol_type_ = sds_aerosol_type_;
429 error_flag_ = quality_flag_for_joint_[1];
431 scatter_ang_ = 180.0 - glint_angle_;
432 glint_ang_ = glint_angle_;
433 sse_ = sds_fitting_error_;
434 fmf_ = sds_dust_weighting_;
435 aot_550_ = sds_tau_corrected_[
DL550];
436 ae1_ = sds_angs_coeff_;
440 for (
int iWav=0; iWav<NOWL; iWav++ ) {
457 vector<float> tba = {490.0,550.0,670.0,2250.0};
459 using boost::math::barycentric_rational;
460 barycentric_rational<float>
interp(move(tba), move(yba));
477 int status = DTDB_SUCCESS;
479 for (
int iTh0=0; iTh0< NLTHET0-1; iTh0++) {
480 if ((
sza >= lut_.THET0_NL[iTh0]) && (
sza <= lut_.THET0_NL[iTh0+1])) {
485 for (
int iTh=0; iTh < NLTHE-1; iTh++) {
486 if ((azim >= lut_.THE_NL[iTh]) && (azim <= lut_.THE_NL[iTh+1])) {
491 for (
int iPhi=0; iPhi < NLPHI-1; iPhi++) {
492 if ((phi >= lut_.PHI_NL[iPhi]) && (phi <= lut_.PHI_NL[iPhi+1])) {
514 int status = DTDB_SUCCESS;
521 compute_cloudmask_ndvi(iy, ix, numCldRed, numCldBlue);
523 int aindex[GRIDX*GRIDY];
524 memset(aindex, 0, GRIDX*GRIDY*
sizeof(
int));
525 float array_interm[NLWAV][GRIDX*GRIDY];
526 memset(array_interm, 0, NLWAV*GRIDX*GRIDY*
sizeof(
float));
532 sort_index(numCldBlue,refl_inter_[
DL670],aindex);
534 int N20 = (
int) ((
float)numCldBlue/5.0);
535 int N50 = (
int) ((
float)numCldBlue/2.0);
537 if ((N50 == 0) && (numCldBlue > 0)) N50=1;
538 int number_pixels = 1;
541 if((N50-N20) > number_pixels) {
543 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
544 good_pixels_[iWav]=0;
545 for (
int ix=N20; ix<N50; ix++ ) {
546 float ril = refl_inter_[iWav][aindex[ix]];
547 if ((ril > 0.0) && (ril <= 1.0)) {
548 array_interm[iWav][good_pixels_[iWav]] = ril;
549 good_pixels_[iWav] += 1;
554 num_pixels_used_ = good_pixels_[
DL670];
555 for (
int iWav = 0; iWav < NLWAV; iWav++ ) {
556 if(good_pixels_[iWav] > 0) {
560 mean_std(good_pixels_[iWav],
561 array_interm[iWav], refl_val, sd_val);
563 refl_[iWav] = refl_val;
564 sdev_[iWav] = sd_val;
572 if( !((refl_[
DL488] > 0) &&
573 (refl_[
DL670] > 0) &&
577 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
585 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
607 int& numCldRed,
int& numCldBlue)
609 int status = DTDB_SUCCESS;
613 for (
int iWav=0; iWav < NLWAV; iWav++) {
614 for (
int j=0;
j<GRIDX*GRIDY;
j++) {
615 refl_inter_[iWav][
j] = 0;
619 if(cm_->snowmask_ == 0) {
626 if ((rfld_[
D2250] <= thresh_max_) &&
627 (rfld_[
D2250] > thresh_min_) && (cmask_ == 1)) {
629 if ((rfld_[
D865] > 0.0) && (rfld_[
D670] > 0.0)) {
651 int status = DTDB_SUCCESS;
654 float x0[2] = {0.0,0.0};
655 float y0[2] = {0.0,0.0};
656 float x1[2] = {0.0,0.0};
657 float y1[2] = {0.0,0.0};
658 float x2[2] = {0.0,0.0};
659 float y2[2] = {0.0,0.0};
663 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
665 for (
int iTh0=SZA_0_; iTh0<=SZA_1_; iTh0++ ) {
667 for (
int iTh=THE_0_; iTh<=THE_1_; iTh++ ) {
669 for (
int iPhi=PHI_0_; iPhi<=PHI_1_; iPhi++ ) {
670 x0[numThe]=lut_.PHI_NL[iPhi];
671 y0[numThe]=lut_.INT_NL0[iTable][iWav][iTau][iTh0][iTh][iPhi];
674 interp_extrap(numThe,raa_,x0,y0,y1[numSza]);
675 x1[numSza]=lut_.THE_NL[iTh];
678 interp_extrap(numSza,senz_,x1,y1,y2[numWave]);
679 x2[numWave]=lut_.THET0_NL[iTh0];
682 interp_extrap(numWave,solz_,x2,y2,refl_ray_nl_[iWav]);
698 int status = DTDB_SUCCESS;
700 float x0[2] = {0.0,0.0};
701 float y0[2] = {0.0,0.0};
702 float x1[2] = {0.0,0.0};
703 float y1[2] = {0.0,0.0};
704 float w1[2] = {0.0,0.0};
705 float x2[2] = {0.0,0.0};
706 float y2[2] = {0.0,0.0};
707 float w2[2] = {0.0,0.0};
708 float v2[2] = {0.0,0.0};
709 float u2[2] = {0.0,0.0};
710 for (
int iSize=0; iSize<NLSIZE; iSize++ ) {
711 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
712 for (
int iTau=0; iTau<NLTAU; iTau++ ) {
714 for (
int iSza=SZA_0_; iSza<=SZA_1_; iSza++ ) {
716 for (
int iTh=THE_0_; iTh<=THE_1_; iTh++ ) {
718 for (
int iPhi=PHI_0_; iPhi<=PHI_1_; iPhi++ ) {
719 x0[nPhi]=lut_.PHI_NL[iPhi];
720 y0[nPhi]=lut_.INT_NL0[mtable_[iSize]][iWav][iTau][iSza][iTh][iPhi];
723 interp_extrap(nPhi,raa_,x0,y0,y1[nTh]);
724 x1[nTh]=lut_.THE_NL[iTh];
725 w1[nTh]=lut_.T_NL0[mtable_[iSize]][iWav][iTau][iSza][iTh];
728 interp_extrap(nTh,senz_,x1,y1,y2[nTau]);
729 interp_extrap(nTh,senz_,x1,w1,w2[nTau]);
730 x2[nTau]=lut_.THET0_NL[iSza];
731 v2[nTau]=lut_.Fd_NL0[mtable_[iSize]][iWav][iTau][iSza];
732 u2[nTau]=lut_.SBAR_NL0[mtable_[iSize]][iWav][iTau][iSza];
735 interp_extrap(nTau,solz_,x2,y2,int_nl_[iSize][iWav][iTau]);
736 interp_extrap(nTau,solz_,x2,w2,t_nl_[iSize][iWav][iTau]);
737 interp_extrap(nTau,solz_,x2,
v2,fd_nl_[iSize][iWav][iTau]);
738 interp_extrap(nTau,solz_,x2,u2,sbar_nl_[iSize][iWav][iTau]);
739 fdt_nl_[iSize][iWav][iTau] =
740 t_nl_[iSize][iWav][iTau]*fd_nl_[iSize][iWav][iTau];
760 int status = DTDB_SUCCESS;
762 float rod_pres[NLWAV];
763 float eqwav_nl[NLWAV];
764 memset(rod_pres, 0, NLWAV*
sizeof(
float));
765 memset(eqwav_nl, 0, NLWAV*
sizeof(
float));
770 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
771 float expfactor = -4.15 + (0.2 * lut_.WAV_NL[iWav]);
773 pow(lut_.WAV_NL[iWav],expfactor);
779 while (diff0 > 0.00001) {
780 lambda0 = (lambda1 + lambda2) / 2.0;
781 float fexp0 = -4.15 + 0.2*lambda0;
782 float fexp1 = -4.15 + 0.2*lambda1;
783 float fexp2 = -4.15 + 0.2*lambda2;
784 float ftau0 = 0.0088*pow(lambda0,fexp0);
785 float ftau1 = 0.0088*pow(lambda1,fexp1);
786 float ftau2 = 0.0088*pow(lambda2,fexp2);
787 if ((ftau1 > rod_pres[iWav]) && (ftau2 < rod_pres[iWav])) {
788 if (ftau0 > rod_pres[iWav]) {
789 lambda1 = (lambda1 + lambda2)/2.0;
792 lambda2 = (lambda1 + lambda2)/2.0;
795 diff0 =
fabs(ftau0 - rod_pres[iWav]);
797 eqwav_nl[iWav] = log(lambda0);
800 for (
int iTab=0; iTab<DTABLE; iTab++) {
801 for (
int iWav=0; iWav<NLUTWAV; iWav++) {
802 lut_.OPTH_NL0[iTab][iWav][0] =
803 0.75*lut_.OPTH_NL0[iTab][iWav][1];
808 for (
int iSize=0; iSize<NLSIZE; iSize++ ) {
809 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
811 for (
int iTau=0; iTau<NLTAU; iTau++ ) {
813 float x[2] = {0.0,0.0};
814 float y[2] = {0.0,0.0};
815 float w[2] = {0.0,0.0};
816 float v[2] = {0.0,0.0};
817 float u[2] = {0.0,0.0};
818 float t[2] = {0.0,0.0};
819 float z[2] = {0.0,0.0};
820 int iWav1 = (iWav == 3) ? iWav-1 : iWav;
821 int iWav2 = (iWav == 3) ? iWav : iWav+1;
823 for (
int jWav=iWav1; jWav<=iWav2; jWav++ ) {
825 x[numWav]=log(lut_.WAV_NL[jWav]);
826 y[numWav]=log(int_nl_[iSize][jWav][iTau]);
827 w[numWav]=log(fdt_nl_[iSize][jWav][iTau]);
828 u[numWav]=log(fd_nl_[iSize][jWav][iTau]);
829 t[numWav]=log(t_nl_[iSize][jWav][iTau]);
830 z[numWav]=log(sbar_nl_[iSize][jWav][iTau]);
831 v[numWav]=lut_.OPTH_NL0[mtable_[iSize]][jWav][iTau];
832 if (lut_.OPTH_NL0[mtable_[iSize]][jWav][iTau] > 0.) {
833 v[numWav]=log(lut_.OPTH_NL0[mtable_[iSize]][jWav][iTau]);
837 interp_extrap(numWav,eqwav_nl[iWav],
x,
y,yout);
838 int_nl_[iSize][iWav][iTau] = exp(yout);
839 interp_extrap(numWav,eqwav_nl[iWav],
x,w,yout);
840 fdt_nl_[iSize][iWav][iTau] = exp(yout);
841 interp_extrap(numWav,eqwav_nl[iWav],
x,
u,yout);
842 fd_nl_[iSize][iWav][iTau] = exp(yout);
843 interp_extrap(numWav,eqwav_nl[iWav],
x,
t,yout);
844 t_nl_[iSize][iWav][iTau] = exp(yout);
845 interp_extrap(numWav,eqwav_nl[iWav],
x,z,yout);
846 sbar_nl_[iSize][iWav][iTau] = exp(yout);
847 interp_extrap(numWav,eqwav_nl[iWav],
x,
v,yout);
849 opth_nl_[iSize][iWav][iTau] = yout;
851 opth_nl_[iSize][iWav][iTau] = exp(yout);
854 refl_ray_nl_[iWav] = int_nl_[iSize][iWav][0];
889 int status = DTDB_SUCCESS;
893 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
898 float aot553_temp[NLETA];
899 float rhosfc212_temp[NLETA];
900 float err644_temp[NLETA];
901 float rho_star_temp[NLETA][NLWAV];
902 memset(aot553_temp, 0, NLETA*
sizeof(
float));
903 memset(rhosfc212_temp, 0, NLETA*
sizeof(
float));
904 memset(err644_temp, 0, NLETA*
sizeof(
float));
905 memset(rho_star_temp, 0, NLETA*NLWAV*
sizeof(
float));
907 for (
int iEta=0; iEta<NLETA; iEta++ ) {
909 float eta_temp = -0.2 + (iEta+1) * 0.1;
911 for (
int iTau=0; iTau<NLTAU; iTau++ ) {
912 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
913 rho_star_tot_[iWav][iTau] = eta_temp *
914 rho_star_[
ISMALL][iWav][iTau] +
915 ((1-eta_temp) * rho_star_[
IBIG][iWav][iTau]);
918 rho_S212_tot_[iTau] = eta_temp * rho_S212_[
ISMALL][iTau] +
919 ((1-eta_temp) * rho_S212_[
IBIG][iTau]);
923 interp_extrap(NLTAU,rfld_[
D488],rho_star_tot_[
DL488],
925 aot553_temp[iEta] = (aot553_temp[iEta]<0) ? 0.0 : aot553_temp[iEta];
927 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
929 interp_extrap(NLTAU,aot553_temp[iEta],
931 rho_star_tot_[iWav],rho_star_temp[iEta][iWav]);
935 interp_extrap(NLTAU,aot553_temp[iEta],
937 rho_S212_tot_,rhosfc212_temp[iEta]);
947 err644_temp[iEta] = errwave_[
DL670];
950 int nleta_index[NLETA];
952 sort_index(NLETA, err644_temp, nleta_index);
955 eta_ = -0.2 + (nleta_index[0]+1) * 0.1;
956 err644_ = err644_temp[nleta_index[0]];
957 rho_sfc_[
DL2250] = rhosfc212_temp[nleta_index[0]];
958 rho_sfc_[
DL670] = yint_644_ + slope_644_* rho_sfc_[
DL2250];
959 rho_sfc_[
DL488] = yint_466_ + slope_466_*rho_sfc_[
DL670];
970 float aot_F553 = aot553_temp[nleta_index[0]] * eta_;
971 float aot_C553 = aot553_temp[nleta_index[0]] * (1.-eta_);
975 interp_extrap(NLTAU,aot_F553,opth_nl_[
ISMALL][
DL550],
978 float massconf = yout*aot_F553;
981 interp_extrap(NLTAU,aot_C553,opth_nl_[
IBIG][
DL550],
982 lut_.MASSCOEF_NL0[mtable_[
IBIG]][
DL550],yout);
984 float massconc = yout*aot_C553;
985 masscon_ = massconf + massconc;
987 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
988 interp_extrap(NLTAU,aot_F553,opth_nl_[
ISMALL][
DL550],
989 lut_.EXTNORM_NL0[mtable_[
ISMALL]][iWav],yout);
991 aot_f_[iWav] = aot_F553 * yout;
995 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
996 interp_extrap(NLTAU,aot_C553,opth_nl_[
IBIG][
DL550],
997 lut_.EXTNORM_NL0[mtable_[
IBIG]][iWav],yout);
999 aot_c_[iWav] = aot_C553 * yout;
1000 aot_d_[iWav] = aot_f_[iWav] + aot_c_[iWav];
1029 int status = DTDB_SUCCESS;
1032 float rho_star_temp[NLWAV];
1033 memset(rho_star_temp, 0, NLWAV*
sizeof(
float));
1036 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
1043 for (
int iTau=0; iTau<NLTAU; iTau++ ) {
1044 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
1045 rho_star_tot_[iWav][iTau] = rho_star_[
ISMALL][iWav][iTau];
1048 rho_S212_tot_[iTau] = rho_S212_[
ISMALL][iTau];
1052 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
1054 interp_extrap(NLTAU,rfld_[
D488],
1055 rho_star_tot_[
DL488],
1056 opth_nl_[
ISMALL][iWav], aot_d_[iWav]);
1059 for (
int iWav=0; iWav<NLWAV; iWav++ ) {
1061 interp_extrap(NLTAU,aot_d_[
DL550],
1063 rho_star_tot_[iWav], rho_star_temp[iWav]);
1067 interp_extrap(NLTAU,aot_d_[
DL550],
1069 rho_S212_tot_, rho_sfc_[
DL2250]);
1078 err644_ = errwave_[
DL670];
1081 rho_sfc_[
DL670] = yint_644_ + slope_644_*rho_sfc_[
DL2250];
1082 rho_sfc_[
DL488] = yint_466_ + slope_466_*rho_sfc_[
DL670];
1085 interp_extrap(NLTAU,aot_d_[
DL550],
1088 masscon_ = yout*aot_d_[
DL550];
1102 int status = DTDB_SUCCESS;
1106 for (
int iSize=0; iSize<NLSIZE; iSize++ ) {
1107 for (
int iTau=0; iTau<NLTAU; iTau++ ) {
1108 rho_S212_[iSize][iTau] =
1110 (sbar_nl_[iSize][
DL2250][iTau] *
1112 fdt_nl_[iSize][
DL2250][iTau]);
1113 if (rho_S212_[iSize][iTau] > 1.0) {
1121 const float slpc = 1.0;
1122 slope_644_ = 0.559*slpc;
1124 slope_466_ = 0.645/slpc;
1126 rho_S644_ = slope_644_*rho_S212_[iSize][iTau] + yint_644_;
1127 rho_S466_ = slope_466_*rho_S644_ + yint_466_;
1129 rho_star_[iSize][
DL488][iTau] =
1130 int_nl_[iSize][
DL488][iTau] +
1131 fdt_nl_[iSize][
DL488][iTau] * rho_S466_ /
1132 (1 - sbar_nl_[iSize][
DL488][iTau] * rho_S466_);
1134 rho_star_[iSize][
DL550][iTau] = 0.0;
1135 rho_star_[iSize][
DL670][iTau] =
1136 int_nl_[iSize][
DL670][iTau] +
1137 fdt_nl_[iSize][
DL670][iTau] * rho_S644_ /
1138 (1 - sbar_nl_[iSize][
DL670][iTau] * rho_S644_);
1140 rho_star_[iSize][
DL2250][iTau] =
1141 int_nl_[iSize][
DL2250][iTau] +
1142 fdt_nl_[iSize][
DL2250][iTau] *
1143 rho_S212_[iSize][iTau] /
1144 (1 - sbar_nl_[iSize][
DL2250][iTau] * rho_S212_[iSize][iTau]);
1161 int status = DTDB_SUCCESS;
1163 short quality_land = 0;
1165 memset( qa_flag, 0,
sizeof(qa_flag));
1167 quality_flag_for_joint_[0] = 0;
1168 quality_flag_for_joint_[1] = 0;
1169 if (aot_d_[
DL550] < -0.10) {
1172 if (aot_d_[
DL550] > 5.00) {
1179 quality_flag_for_retr_ = 11;
1186 qa_flag[10] = quality_flag_for_retr_;
1187 qa_flag[11] = error_;
1189 qcontrol_special_ = 0;
1190 quality_flag_for_joint_[0] = qa_flag[7];
1192 quality_flag_for_joint_[1] = error_+20;
1196 else if (error_== 0) {
1198 quality_flag_for_retr_ = 0;
1204 if (quality_land == 0){
1206 quality_flag_for_retr_ = 2;
1209 if (err644_> 0.25) {
1211 quality_flag_for_retr_ = 4;
1214 if (aot_d_[
DL550] < 0.0) {
1215 qcontrol_special_ = 2;
1216 quality_flag_for_retr_ = 5;
1220 if (!((angstrom_> -1.00) && (angstrom_<= 5.0))) {
1222 quality_flag_for_retr_ = 9;
1225 float number_pixels = 1;
1226 int num_Q_pixel1 = (
int)(number_pixels *.03);
1227 int num_Q_pixel2 = (
int)(number_pixels *.05);
1228 int num_Q_pixel3 = (
int)(number_pixels *.08);
1229 int num_Q_pixel4 = (
int)(number_pixels *.12);
1233 if((num_pixels_used_ > num_Q_pixel1) && (num_pixels_used_ <= num_Q_pixel2)) {
1235 quality_flag_for_retr_=6;
1239 if((num_pixels_used_ > num_Q_pixel2) && (num_pixels_used_ <= num_Q_pixel3)) {
1241 quality_flag_for_retr_=7;
1245 if((num_pixels_used_ > num_Q_pixel3) &&
1246 (num_pixels_used_ <= num_Q_pixel4)) {
1248 quality_flag_for_retr_=8;
1252 if( num_pixels_used_ > num_Q_pixel4) {
1255 if (return_quality_cirrus_ == 0){
1256 quality_flag_for_retr_=3;
1262 qcontrol_special_ = 1;
1263 quality_flag_for_retr_ = 1;
1268 qa_flag[8] = qa_flag[6];
1269 qa_flag[9] = qa_flag[7];
1271 if (aot_d_[
DL550] < 0.2) {
1272 quality_flag_for_retr_ = 10;
1275 qa_flag[10] = quality_flag_for_retr_;
1276 qa_flag[9] = error_;
1277 quality_flag_for_joint_[0] = qa_flag[7];
1278 quality_flag_for_joint_[1] = quality_flag_for_retr_;
1283 set_byte(qa_flag[6], 0, qa_temp);
1284 set_byte(qa_flag[7], 1, qa_temp);
1285 set_byte(qa_flag[8], 4, qa_temp);
1286 set_byte(qa_flag[9], 5, qa_temp);
1287 sds_qcontrol_[0] = qa_temp;
1291 set_byte(qa_flag[10], 0, qa_temp);
1292 set_byte(qa_flag[11], 4, qa_temp);
1293 sds_qcontrol_[1] = qa_temp;
1297 set_byte(qa_flag[14], 0, qa_temp);
1298 set_byte(qa_flag[15], 2, qa_temp);
1299 set_byte(qa_flag[16], 4, qa_temp);
1300 set_byte(qa_flag[17], 6, qa_temp);
1301 sds_qcontrol_[2] = qa_temp;
1304 set_byte(qa_flag[18], 0, qa_temp);
1305 sds_qcontrol_[3] = qa_temp;
1306 sds_qcontrol_[4] = 0;
1308 for (
int i=0;
i<19;
i++) {
1327 int status = DTDB_SUCCESS;
1330 if (aot_d_[
DL550] < 0.0) {
1332 for (
int iWav=0; iWav<NLWAV; iWav++) {
1333 aot_f_[iWav] = 0.00;
1334 aot_c_[iWav] = 0.00;
1338 if ((aot_d_[
DL550] >= -0.10) && (aot_d_[
DL550] <= -0.05)) {
1340 aot_d_[
DL550] = -0.05;
1341 aot_d_[
DL488] = -0.05;
1345 for (
int iWav=0; iWav<NLWAV; iWav++) {
1346 aot_d_[iWav] = -0.05;
1352 if(qcontrol_special_ == 2){
1356 if ((angstrom_> -1.00) && (angstrom_<= 5.0)) {
1357 sds_angs_coeff_ = angstrom_;
1364 sds_aerosol_type_ = iaer_;
1366 if ((scatter_angle_ >= -180) && (scatter_angle_ <= 180)) {
1367 sds_scat_angle_ = scatter_angle_;
1370 if ((aot_d_[
DL488] >= -0.1) && (aot_d_[
DL488] <= aotmax)) {
1373 if ((aot_d_[
DL550] >= -0.1) && (aot_d_[
DL550] <= aotmax)) {
1376 if ((aot_d_[
DL670] >= -0.1) && (aot_d_[
DL670] <= aotmax)) {
1379 if ((aot_d_[
DL2250] >= -0.1) && (aot_d_[
DL2250] <= aotmax)) {
1390 sds_fitting_error_ = err644_;
1391 if (cloud_fraction_ >= 0) {
1392 sds_cloud_fraction_ = cloud_fraction_;
1395 sds_dust_weighting_ = eta_;
1397 for (
int iWav=0; iWav<NLWAV; iWav++) {
1398 if (good_pixels_[iWav] >= 0) {
1399 sds_numpixels_[iWav] = good_pixels_[iWav];
1402 if (masscon_ >= 0) {
1403 sds_mass_conc_ = masscon_;
1405 if (ndvi_ >= -1.0 && ndvi_ <= 1.0) {
1408 if ((rfld_[
D488] >= 0.0) && (rfld_[
D488] <= 1.2)) {
1411 sds_surface_reflectance_[
DL488] = rho_sfc_[
DL488];
1413 if ((rfld_[
D550] >= 0.0) && (rfld_[
D550] <= 1.2)) {
1417 if ((rfld_[
D670] >= 0.0) && (rfld_[
D670] <= 1.2)) {
1420 sds_surface_reflectance_[
DL670] = rho_sfc_[
DL670];
1422 if ((rfld_[
D865] >= 0.0) && (rfld_[
D865] <= 1.2)) {
1426 if ((rfld_[
D1240] >= 0.0) && (rfld_[
D1240] <= 1.2)) {
1430 if ((rfld_[
D1610] >= 0.0) && (rfld_[
D1610] <= 1.2)) {
1434 if ((rfld_[
D2250] >= 0.0) && (rfld_[
D2250] <= 1.2)) {
1448 for (
int iWav=0; iWav<NLWAV; iWav++) {
1454 for (
int iWav=0; iWav<NLWAV; iWav++) {
1470 int status = DTDB_SUCCESS;
1472 sds_aerosol_type_=8;
1474 sds_cloud_fraction_= cloud_fraction_;
1479 for (
int iWav=0; iWav<NLWAV; iWav++) {