8 #ifndef INCLUDE_DTALGORITHM_H_
9 #define INCLUDE_DTALGORITHM_H_
56 static constexpr
int LINE = 1;
57 static constexpr
int GRIDX = LINE;
58 static constexpr
int GRIDY = LINE;
59 static constexpr
int NUM_CASES_SMALL = 4;
60 static constexpr
int NUM_CASES_BIG = 5;
61 static constexpr
int NUM_LUTS = 4;
62 static constexpr
int NUM_LATS = 180;
63 static constexpr
int NUM_LONS = 360;
66 static constexpr
float MINMTHET0=0.0;
67 static constexpr
float MAXMTHET0=80.0;
68 static constexpr
float MINMTHET=0.0;
69 static constexpr
float MAXMTHET=72.0;
70 static constexpr
float MINMPHI=0.0;
71 static constexpr
float MAXMPHI=180.0;
73 static constexpr
float MAXTAU=5.0;
74 static constexpr
float MINTAU=-0.01;
76 static constexpr
int NUM_RFL_BANDS = 10;
77 static constexpr
int DT_OWAVES = 7;
78 static constexpr
int DT_LWAVES = 3;
79 static constexpr
int MODIS_WAVES = 7;
80 static constexpr
int VIIRS_WAVES = 3;
81 static const float wind_[WIND_LUT_ENTRIES];
82 static const float pressure_[P_LEVELS];
97 float rfld_[NUM_RFL_BANDS];
112 virtual int initialize( map<string, ddata*> imap );
122 virtual map<string, ddata*> process(vector<size_t>
start, vector<size_t>
count,
123 map<string, ddata*> imap);
129 int compute_gas_correction();
135 int fit_line(
float x[],
float y[],
float sig[],
int ndata,
136 float& A,
float& B );
159 int interp_extrap(
int num,
float xin,
160 float x[],
float y[],
float& yout );
164 int mean_std(
int n,
float*
data,
float&
mean,
float& sdev );
170 int mean_std_weighted(
int n,
float*
data,
float&
mean,
171 float& sdev,
float* weight );
176 int sort_index(
int numPts,
float array[],
int index[] );
182 int sort_inplace(
int numPts,
float array1[],
float array2[] );
187 int set_byte(
short val,
short bitPos,
short& target);
192 int compute_glint_angle();
197 int compute_scatter_angle(
float& scat_angle);
208 static constexpr
float THRHLD550 = 0.0025;
209 static constexpr
float THRHLD470 = 0.4;
210 static constexpr
float THRHLD138_1 = 0.03;
211 static constexpr
float THRHLD138_2 = 0.005;
212 static constexpr
float THRHLD_DUST = 0.75;
213 static constexpr
float THRHLD_CIRRUS = 0.03;
214 static constexpr
float Threshold_LSQ_Error = 3.7;
216 static constexpr
float GLINT_ANGLE_THRESHOLD = 40.0;
218 static constexpr
float LOW_THRESHOLD = -0.05;
219 static constexpr
float HIGH_THRESHOLD = 5.0;
220 static constexpr
float GLINT_REFL_THRESHOLD = 0.01570796326;
222 static constexpr
int NUMCASES = 4;
223 static constexpr
int NUMCASEB = 5;
224 static constexpr
int NWAV = 7;
225 static constexpr
int NAOT = 6;
226 static constexpr
int NTH0 = 11;
227 static constexpr
int NTHET = 16;
228 static constexpr
int NPHI = 16;
229 static constexpr
int NUM_ARRAY_ELEMENTS = 77;
230 static constexpr
int NUM_SIZES = 2;
231 static constexpr
int NUM_STATS = 2;
241 float refl_rayl_[NWAV];
244 float refl_big_[NWAV][NUM_CASES_BIG][NAOT];
245 float refl_small_[NWAV][NUM_CASES_SMALL][NAOT];
248 float albedo_R_small_tau_[NWAV][NUM_CASES_SMALL][NAOT];
249 float albedo_R_big_tau_[NWAV][NUM_CASES_BIG][NAOT];
250 float albedo_T_small_tau_[NWAV][NUM_CASES_SMALL][NAOT];
251 float albedo_T_big_tau_[NWAV][NUM_CASES_BIG][NAOT];
257 int good_pixels_[NWAV];
260 float tau_[NWAV][NUMCASES*NUMCASEB];
261 float tau_small_[NWAV][NUMCASES*NUMCASEB];
262 float tau_big_[NWAV][NUMCASES*NUMCASEB];
263 float backscatter_[NWAV][NUMCASES*NUMCASEB];
264 float assym_[NWAV][NUMCASES*NUMCASEB];
265 float refl_flux_[NWAV][NUMCASES*NUMCASEB];
266 float trans_flux_[NWAV][NUMCASES*NUMCASEB];
267 float angstrom_exp_[NUM_STATS][NUMCASES*NUMCASEB];
268 float solution_index_[NUM_SIZES][NUMCASES*NUMCASEB];
269 float ccn_[NUMCASES*NUMCASEB];
270 float eff_radius_[NUMCASES*NUMCASEB];
271 float eff_variance_[NUMCASES*NUMCASEB];
272 float mass_con_ocean_[NUMCASES*NUMCASEB];
273 float xmin_[2][NUMCASES*NUMCASEB];
274 float funmin_[2][NUMCASES*NUMCASEB];
275 float tau_X55_[2][NUMCASES*NUMCASEB];
276 float error_[2][NWAV][NUMCASES*NUMCASEB];
279 float refl_avg_[NWAV];
280 float sdev_avg_[NWAV];
281 float tau_avg_[NUM_STATS][NWAV];
282 float tau_small_avg_[NUM_STATS][NWAV];
283 float tau_big_avg_[NUM_STATS][NWAV];
284 float backscatter_avg_[NUM_STATS][NWAV];
285 float assym_avg_[NUM_STATS][NWAV];
286 float refl_flux_avg_[NUM_STATS][NWAV];
287 float trans_flux_avg_[NUM_STATS][NWAV];
288 float angstrom_exp_avg_[NUM_STATS][NUM_SIZES];
289 float solution_index_avg_[NUM_STATS][NUM_SIZES];
290 float ccn_avg_[NUM_STATS];
291 float eff_radius_avg_[NUM_STATS];
292 float eff_variance_avg_[NUM_STATS];
293 float mass_con_ocean_avg_[NUM_STATS];
294 float xmin_avg_[NUM_STATS];
295 float funmin_avg_[NUM_STATS];
296 float tau_X55_avg_[NUM_STATS];
305 short quality_to_pass_[2];
306 short quality_flag_[12];
309 float sds_refl_[NWAV];
310 float sds_refl_sdev_[NWAV];
311 short sds_numPixels_[NWAV];
312 float sds_tau_best_[NWAV];
313 float sds_tau_avg_[NWAV];
314 float sds_tau_big_best_[NWAV];
315 float sds_tau_big_avg_[NWAV];
316 float sds_tau_small_best_[NWAV];
317 float sds_tau_small_avg_[NWAV];
318 float sds_assy_best_[NWAV];
319 float sds_assy_avg_[NWAV];
320 float sds_back_best_[NWAV];
321 float sds_back_avg_[NWAV];
322 float sds_reff_best_[NWAV];
323 float sds_reff_avg_[NWAV];
324 float sds_tranf_best_[NWAV];
325 float sds_tranf_avg_[NWAV];
328 float sds_Small_Weighting_[NUM_SIZES];
329 float sds_Least_Error_[NUM_SIZES];
330 float sds_tau_X55_[NUM_SIZES];
331 float sds_EffRad_[NUM_SIZES];
332 float sds_EffVar_[NUM_SIZES];
333 short sds_Sol_Index_Small_[NUM_SIZES];
334 short sds_Sol_Index_Large_[NUM_SIZES];
335 float sds_Angs_Coeff1_[NUM_SIZES];
336 float sds_Angs_Coeff2_[NUM_SIZES];
337 float sds_Mass_Conc_[NUM_SIZES];
338 float sds_CCN_[NUM_SIZES];
339 float sds_AOT_model_[NUMCASES+NUMCASEB];
360 vector<string>
get_products() {
return {
"cloud_mask",
"quality_flag",
"aerosol_type",
361 "l2_flags",
"scattering_angle",
"fmf_550",
"angstrom",
"aot_380",
362 "aot_490",
"aot_550",
"aot_670",
"aot_865",
"aot_1240",
"aot_1610",
"aot_2250"};};
367 map<string, ddata*> process(vector<size_t>
start, vector<size_t>
count,
368 map<string, ddata*> imap);
375 int index_geometry(
float sza,
float azim,
float phi);
381 int interpolate_rayleigh();
387 int interpolate_angles();
394 int compute_tau_flux(
int iBig,
int iSmall,
int iSol );
403 int compute_avg_refl();
409 int compute_average_to_500m();
414 int store_reflectance();
424 int assign_quality();
434 int average_output();
439 int compute_minimum(
int iBig,
int iSmall,
int iSol);
444 int compute_minimum_baseline(
int iBig,
int iSmall,
int iSol);
449 float fun_tau(
float xmin,
int iBig,
int iSmall,
int iSol );
459 static constexpr
int NLTHET0 = 11;
460 static constexpr
int NLTHE = 15;
461 static constexpr
int NLPHI = 16;
462 static constexpr
int NLWAV = 4;
463 static constexpr
int NLTAU = 7;
464 static constexpr
int NLTABLE = 5;
465 static constexpr
int NLETA = 13;
466 static constexpr
int NLSIZE = 2;
467 static constexpr
int DTABLE = 5;
469 static constexpr
float THR213MIN_1 = 0.01;
470 static constexpr
float THR213MAX_1 = 0.25;
471 static constexpr
float THR213MIN_2 = 0.25;
472 static constexpr
float THR213MAX_2 = 0.25;
474 static constexpr
float DLAT = 0.5;
475 static constexpr
float DLON = 0.5;
477 static constexpr
int QA_LAND = 5;
488 float refl_ray_nl_[NLWAV];
489 float opth_nl_[NLSIZE][NLWAV][NLTAU];
490 float int_nl_[NLSIZE][NLWAV][NLTAU];
491 float fd_nl_[NLSIZE][NLWAV][NLTAU];
492 float t_nl_[NLSIZE][NLWAV][NLTAU];
493 float fdt_nl_[NLSIZE][NLWAV][NLTAU];
494 float sbar_nl_[NLSIZE][NLWAV][NLTAU];
496 float refl_inter_[NLWAV][GRIDX*GRIDY];
501 float rho_star_[NLSIZE][NLWAV][NLTAU];
502 float rho_star_tot_[NLWAV][NLTAU];
503 float rho_S212_[NLSIZE][NLTAU];
504 float rho_S212_tot_[NLTAU];
505 float errwave_[NLWAV];
517 float rho_sfc_[NLWAV];
524 int good_pixels_[NLWAV];
535 short quality_flag_for_joint_[2];
540 short sds_qcontrol_[QA_LAND];
549 float sds_numpixels_[NLWAV];
550 float sds_tau_corrected_[NLWAV];
551 float sds_refl_[NLWAV];
552 float sds_refl_std_[NLWAV];
553 float sds_tau_small_[NLWAV];
554 float sds_tau_big_[NLWAV];
555 float sds_surface_reflectance_[NLWAV];
575 vector<string>
get_products() {
return {
"cloud_mask",
"quality_flag",
"aerosol_type",
576 "l2_flags",
"scattering_angle",
"fmf_550",
"angstrom",
"aot_380",
577 "aot_490",
"aot_550",
"aot_670",
"aot_2250"};};
595 map<string, ddata*> process(vector<size_t>
start, vector<size_t>
count,
596 map<string, ddata*> imap);
603 int index_geometry(
float sza,
float azim,
float phi);
615 int interpolate_rayleigh();
621 int interpolate_angle();
628 int interpolate_elevation();
637 int compute_average(
size_t iy,
size_t ix);
646 int compute_cloudmask_ndvi(
size_t iy,
size_t ix,
647 int& iCldRed,
int& iCldBlue);
659 int retrieve_first();
667 int retrieve_second();
672 int assign_quality();