11 #ifndef DbLutNetcdf_H_
12 #define DbLutNetcdf_H_
14 #include <boost/multi_array.hpp>
19 using namespace netCDF;
20 using namespace netCDF::exceptions;
22 static const int NDET = 10;
23 static const int NAOI = 6;
24 static const int NSIDE = 2;
25 static const int NBANDLUT = 3;
27 static const int NBANDS = 3;
29 static const int NTIMER = 138;
30 static const int NTIMER_AQ = 121;
31 static const int NBANDLUTR = 3;
32 static const int NCOEFF = 6;
34 extern const int chindx[8];
35 extern const int bindx[3];
41 short xxyear_aq[NTIMER_AQ];
42 short xxday_aq[NTIMER_AQ];
43 float angle_of_incident[NAOI];
45 float am13[NSIDE][NAOI][
NDET][NBANDLUT];
46 float xxwave[NBANDLUTR];
47 float xxwave_aq[NBANDLUTR];
48 double sectab[NTIMER];
49 double xxrvs[NCOEFF][
NDET][NSIDE][NBANDLUTR][NTIMER];
50 double xxam12[NCOEFF][
NDET][NSIDE][NBANDLUTR][NTIMER];
51 double xxam13[NCOEFF][
NDET][NSIDE][NBANDLUTR][NTIMER];
52 double xxrvs_aq[NCOEFF][
NDET][NSIDE][NBANDLUTR][NTIMER_AQ];
53 double sectab_aq[NTIMER_AQ];
56 static const int ENTRIES_412 = 121;
57 static const int ENTRIES_470 = 104;
58 static const int XCAL_COEF = 6;
59 static const int MODIS_DETECTORS = 10;
60 static const int MIRROR_SIDES = 2;
61 static const int NLATS = 180;
62 static const int NLONS = 360;
63 static const int NSEASONS = 4;
64 static const int NMONTHS = 12;
65 static const int NNDVI = 3;
66 static const int NTERMS = 4;
69 short YEAR_412[ENTRIES_412];
70 short DAY_412[ENTRIES_412];
71 short YEAR_470[ENTRIES_470];
72 short DAY_470[ENTRIES_470];
73 float GAIN_412[ENTRIES_412];
74 float GAIN_470[ENTRIES_470];
75 double XCAL_412_M11[XCAL_COEF][MODIS_DETECTORS][MIRROR_SIDES][ENTRIES_412-1];
76 double XCAL_412_M12[XCAL_COEF][MODIS_DETECTORS][MIRROR_SIDES][ENTRIES_412-1];
77 double XCAL_412_M13[XCAL_COEF][MODIS_DETECTORS][MIRROR_SIDES][ENTRIES_412-1];
78 double XCAL_470_M11[XCAL_COEF][MODIS_DETECTORS][MIRROR_SIDES][ENTRIES_470-1];
79 double XCAL_470_M12[XCAL_COEF][MODIS_DETECTORS][MIRROR_SIDES][ENTRIES_470-1];
80 double XCAL_470_M13[XCAL_COEF][MODIS_DETECTORS][MIRROR_SIDES][ENTRIES_470-1];
84 float SR412_ALL[NSEASONS][NLATS*10][NLONS*10];
85 float SR412_FWD[NSEASONS][NLATS*10][NLONS*10];
86 float SR470_ALL[NSEASONS][NLATS*10][NLONS*10];
87 float SR470_FWD[NSEASONS][NLATS*10][NLONS*10];
88 float SR650_ALL[NSEASONS][NLATS*10][NLONS*10];
89 float SR650_FWD[NSEASONS][NLATS*10][NLONS*10];
90 float SR865_ALL[NSEASONS][NLATS*10][NLONS*10];
106 float coeffs_2130_to_412[NLATS*10][NLONS*10];
107 float coeffs_2130_to_470[NLATS*10][NLONS*10];
108 float min_2130_for_412[NLATS*10][NLONS*10];
109 float max_2130_for_412[NLATS*10][NLONS*10];
110 float min_2130_for_470[NLATS*10][NLONS*10];
111 float max_2130_for_470[NLATS*10][NLONS*10];
112 float data_num_total[NLATS*10][NLONS*10];
113 float data_num_fitting[NLATS*10][NLONS*10];
114 float stderr_412[NLATS*10][NLONS*10];
115 float stderr_470[NLATS*10][NLONS*10];
118 static const int SP_720 = 720;
119 static const int SP_360 = 360;
120 static const int SP_SETS = 6;
123 float PS[SP_720][SP_360];
124 float SURFACE_PRESSURE[SP_SETS * SP_720][SP_SETS * SP_360];
125 float SURFACE_ELEVATION[SP_SETS * SP_720][SP_SETS * SP_360];
129 static const int NSZAV = 10;
130 static const int NSZA = 12;
131 static const int NVZA = 46;
132 static const int NRAA = 30;
133 static const int NTAU = 10;
134 static const int SSA412 = 8;
135 static const int SSA470 = 4;
136 static const int SSA650 = 1;
137 static const int SR412 = 20;
138 static const int SR470 = 24;
139 static const int SR650 = 24;
144 float NVALX_412[SR412][SSA412][NTAU][NRAA][NVZA][NSZA];
145 float NVALX_470[SR470][SSA470][NTAU][NRAA][NVZA][NSZA];
146 float NVALX_650[SR650][NTAU][NRAA][NVZA][NSZA];
149 static const int NSTOKES = 3;
150 static const int NRRAA = 31;
153 float RAYL_412[NRRAA][NVZA][NSZA][NSTOKES];
154 float RAYL_470[NRRAA][NVZA][NSZA][NSTOKES];
155 float RAYL_650[NRRAA][NVZA][NSZA][NSTOKES];
161 static const int MTABLE_20800 = 20800;
162 static const int MTABLE_260 = 260;
163 static const int MTABLE_160 = 160;
164 static const int MTABLE_2 = 2;
167 float LOGI0[MTABLE_20800];
168 float Z1I0[MTABLE_20800];
169 float Z2I0[MTABLE_20800];
170 float TI0[MTABLE_20800];
171 float SB[MTABLE_260];
172 float LOGI0R[MTABLE_160];
173 float Z1I0R[MTABLE_160];
174 float Z2I0R[MTABLE_160];
175 float TI0R[MTABLE_160];
180 float NVALX21_SFC[NSEASONS][NRAA][NVZA][NSZAV];
181 float R0X21_SFC[NSEASONS][NRAA][NVZA][NSZAV];
182 float SX21_SFC[NSEASONS][NRAA][NVZA][NSZAV];
183 float TX21_SFC[NSEASONS][NRAA][NVZA][NSZAV];
184 float NVALX672_SFC[NSEASONS][NRAA][NVZA][NSZAV];
185 float R0X672_SFC[NSEASONS][NRAA][NVZA][NSZAV];
186 float SX672_SFC[NSEASONS][NRAA][NVZA][NSZAV];
187 float TX672_SFC[NSEASONS][NRAA][NVZA][NSZAV];
188 float NVALX865_SFC[NSEASONS][NRAA][NVZA][NSZAV];
189 float R0X865_SFC[NSEASONS][NRAA][NVZA][NSZAV];
190 float SX865_SFC[NSEASONS][NRAA][NVZA][NSZAV];
191 float TX865_SFC[NSEASONS][NRAA][NVZA][NSZAV];
195 float SR412_ALL[NSEASONS][NLATS*10][NLONS*10];
196 float SR488_ALL[NSEASONS][NLATS*10][NLONS*10];
197 float SR670_ALL[NSEASONS][NLATS*10][NLONS*10];
198 float BRDF_650[NLATS*10][NLONS*10];
209 float SC412_ALL[NSEASONS][NNDVI][NTERMS][NLATS*10][NLONS*10];
210 float SC412_FWD[NSEASONS][NNDVI][NTERMS][NLATS*10][NLONS*10];
211 float SC470_ALL[NSEASONS][NNDVI][NTERMS][NLATS*10][NLONS*10];
212 float SC470_FWD[NSEASONS][NNDVI][NTERMS][NLATS*10][NLONS*10];
213 float SC650_ALL[NSEASONS][NNDVI][NTERMS][NLATS*10][NLONS*10];
214 float SC650_FWD[NSEASONS][NNDVI][NTERMS][NLATS*10][NLONS*10];
227 int VEGETATION[4*NLATS*10][NLONS*10];
228 short IGBP[NLATS*10][NLONS*10];
229 short REGION_INDEX[NLATS*10][NLONS*10];
230 float DESERTS_FLAG[NLATS*10][NLONS*10];
234 float GEOZONE_FLAG[NLATS*10][NLONS*10];
235 float ELEVATION_STDV[NLATS*10][NLONS*10];
236 float BACKGROUND_AOD[4][NLATS][NLONS];
239 static const int NSCOEF = 3;
240 static const int NSLATS = 3000;
241 static const int NSLONS = 6000;
245 float coeffs_2250_to_412[NSEASONS][NSCOEF][NSLATS][NSLONS];
246 float coeffs_2250_to_488[NSEASONS][NSCOEF][NSLATS][NSLONS];
247 float coeffs_2250_to_670[NSEASONS][NSCOEF][NSLATS][NSLONS];
248 float min_2250_for_412[NSEASONS][NSLATS][NSLONS];
249 float max_2250_for_412[NSEASONS][NSLATS][NSLONS];
250 float min_2250_for_488[NSEASONS][NSLATS][NSLONS];
251 float max_2250_for_488[NSEASONS][NSLATS][NSLONS];
252 float min_2250_for_670[NSEASONS][NSLATS][NSLONS];
253 float max_2250_for_670[NSEASONS][NSLATS][NSLONS];
254 float data_num_total[NSEASONS][NSLATS][NSLONS];
255 float data_num_fitting[NSEASONS][NSLATS][NSLONS];
256 float stderr_412[NSEASONS][NSLATS][NSLONS];
257 float stderr_488[NSEASONS][NSLATS][NSLONS];
258 float stderr_670[NSEASONS][NSLATS][NSLONS];
261 static const int NVSZA = 22;
262 static const int NVVZA = 20;
263 static const int NVRAA = 21;
264 static const int NAOT1 = 14;
265 static const int NAOT2 = 7;
266 static const int NFMF1 = 7;
267 static const int NFMF2 = 5;
268 static const int NFMF3 = 8;
269 static const int NFMF4 = 4;
270 static const int NWS = 6;
271 static const int NCHL = 4;
272 static const int NDBOWL = 7;
273 static const int NDBMDL = 4;
274 static const int NDBLWL = 3;
277 const static size_t nsza = NVSZA;
278 const static size_t nvza = NVVZA;
279 const static size_t nraa = NVRAA;
282 const static size_t nwspd = NWS;
283 const static size_t nchl = NCHL;
284 const static size_t nwave = NDBOWL;
285 boost::multi_array<float,7>
m03;
286 boost::multi_array<float,7>
m04;
287 boost::multi_array<float,7>
m05;
288 boost::multi_array<float,7>
m07;
289 boost::multi_array<float,6>
m08;
290 boost::multi_array<float,6>
m10;
291 boost::multi_array<float,6>
m11;
292 boost::multi_array<float,1>
sza;
293 boost::multi_array<float,1>
vza;
294 boost::multi_array<float,1>
raa;
296 boost::multi_array<float,1>
fmf;
297 boost::multi_array<float,1>
wspd;
298 boost::multi_array<float,1>
chl;
299 boost::multi_array<float,1>
wave;
300 boost::multi_array<float,2>
ae;
301 boost::multi_array<float,3>
aot;
304 boost::multi_array<float,3>
ssa;
307 boost::multi_array<float,3>
asy;
313 const static size_t nsza = NVSZA;
314 const static size_t nvza = NVVZA;
315 const static size_t nraa = NVRAA;
318 const static size_t nwspd = NWS;
319 const static size_t nchl = NCHL;
320 const static size_t nwave = NDBOWL;
321 float m03[NCHL][NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA];
322 float m04[NCHL][NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA];
323 float m05[NCHL][NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA];
324 float m07[NCHL][NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA];
325 float m08[NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA];
326 float m10[NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA];
327 float m11[NWS][NFMF3][NAOT1][NVRAA][NVVZA][NVSZA];
336 float ae[NFMF3][NAOT1];
337 float aot[NDBOWL][NFMF3][NAOT1];
338 float fine_aot[NDBOWL][NFMF3][NAOT1];
339 float coarse_aot[NDBOWL][NFMF3][NAOT1];
340 float ssa[NDBOWL][NFMF3][NAOT1];
341 float fine_ssa[NDBOWL][NFMF3][NAOT1];
342 float coarse_ssa[NDBOWL][NFMF3][NAOT1];
343 float asy[NDBOWL][NFMF3][NAOT1];
344 float fine_asy[NDBOWL][NFMF3][NAOT1];
345 float coarse_asy[NDBOWL][NFMF3][NAOT1];
350 float SZA412_Nodes[NSZA];
351 float VZA412_Nodes[NVZA];
352 float RAA412_Nodes[NRAA];
353 float AOT412_Nodes[NTAU];
354 float SSA412_Nodes[SSA412];
355 float SR412_Nodes[SR412];
356 float nvalx412[SR412][SSA412][NTAU][NRAA][NVZA][NSZA];
357 float SZA488_Nodes[NSZA];
358 float VZA488_Nodes[NVZA];
359 float RAA488_Nodes[NRAA];
360 float AOT488_Nodes[NTAU];
361 float SSA488_Nodes[SSA470];
362 float SR488_Nodes[SR470];
363 float nvalx488[SR470][SSA470][NTAU][NRAA][NVZA][NSZA];
364 float SZA672_Nodes[NSZA];
365 float VZA672_Nodes[NVZA];
366 float RAA672_Nodes[NRAA];
367 float AOT672_Nodes[NTAU];
368 float SSA672_Nodes[SSA650];
369 float SR672_Nodes[SR650];
370 float nvalx672[SR650][SSA650][NTAU][NRAA][NVZA][NSZA];
373 static const int NUMX = 21601;
374 static const int NUMY = 10801;
386 float log_chl[NLATS*10][NLONS*10][NMONTHS];
390 static const int NDAYS = 95;
453 int create_db_nc4_lut();
465 int* edge,
int& season,
int &dateline);
467 int* edge,
int& season,
int &dateline);
469 int* edge,
int& season,
int &dateline);
507 int read_chl_files(
dbChlLUT* lut );
515 int write_tables_lut(NcFile* nc_output,
dbTablesLUT* lut);
516 int write_surface_pressure_lut(NcFile* nc_output,
518 int write_nvalx_lut(NcFile* nc_output,
dbNvalxLUT* lut);
526 const string strType);
528 const string strType);
530 int write_chl_lut(NcFile* nc_output,
dbChlLUT* lut);
531 int write_geozone_lut(NcFile* nc_output,
dbGeozoneLUT* lut);
532 int write_rayleigh_lut(NcFile* nc_output,
dbRayleighLUT* lut);
538 int write_global_attributes(NcFile* nc_output);
544 bool isPlatformLittleEndian();
605 static void byteSwap(T& aValue);
615 T tempValue = aValue;
618 unsigned char* aValuePtr =
reinterpret_cast<unsigned char*
>(&aValue);
619 unsigned char* tempValuePtr =
reinterpret_cast<unsigned char*
>(&tempValue);
622 for (
unsigned int byte = 0;
byte <
sizeof(aValue); ++
byte) {
623 aValuePtr[
byte] = tempValuePtr[(
sizeof(aValue) - 1) -
byte];