13 #ifndef DtLutNetcdf_H_
14 #define DtLutNetcdf_H_
20 using namespace netCDF;
21 using namespace netCDF::exceptions;
23 static const int LON_BINS = 360;
24 static const int LAT_BINS = 181;
25 static const int DATA_BINS = 55;
26 static const int GRIB_ARRAY_SIZE = LON_BINS*LAT_BINS*DATA_BINS*4;
27 static const int GRIB_ROW_SIZE = LON_BINS*LAT_BINS*4;
28 static const int NUM_CASES_SMALL = 4;
29 static const int NUM_CASES_BIG = 5;
30 static const int NUM_MOMENTS = 4;
31 static const int NUM_LUTS = 4;
32 static const int NUM_LATS = 180;
33 static const int NUM_LONS = 360;
34 static const int NUMCASES = 4;
35 static const int NUMCASEB = 5;
36 static const int NWAV = 7;
37 static const int NAOT = 6;
38 static const int NTH0 = 11;
39 static const int NTHET = 16;
40 static const int NPHI = 16;
41 static const int NUM_SOLUTIONS = 2;
42 static const int NLUTWAV = 4;
43 static const int NLTHET0 = 11;
44 static const int NLTHE = 15;
45 static const int NLPHI = 16;
46 static const int NLTAU = 7;
47 static const int NLTABLE = 5;
48 static const int NLETA = 13;
49 static const int NLSIZE = 2;
50 static const int DTABLE = 5;
51 static const int O3_COEFS = 2;
52 static const int H2O_COEFS = 3;
53 static const int IW550 = 1;
58 float data[DATA_BINS][LAT_BINS][LON_BINS];
63 float ugrd[LAT_BINS][LON_BINS];
64 float vgrd[LAT_BINS][LON_BINS];
65 float pwat[LAT_BINS][LON_BINS];
66 float ozone[LAT_BINS][LON_BINS];
91 float THET0_NL[NLTHET0];
92 float MU0_NL[NLTHET0];
93 float WAV_NL[NLUTWAV];
94 float OPTH_NL0[NLTABLE][NLUTWAV][NLTAU];
95 float MASSCOEF_NL0[NLTABLE][NLUTWAV][NLTAU];
96 float EXTNORM_NL0[NLTABLE][NLUTWAV][NLTAU];
97 float SSA_NL0[NLTABLE][NLUTWAV][NLTAU];
98 float QEXT_NL0[NLTABLE][NLUTWAV][NLTAU];
99 float BEXT_NL0[NLTABLE][NLUTWAV][NLTAU];
100 float VEXT_NL0[NLTABLE][NLUTWAV][NLTAU];
101 float MEXT_NL0[NLTABLE][NLUTWAV][NLTAU];
102 float SBAR_NL0[NLTABLE][NLUTWAV][NLTAU][NLTHET0];
103 float INT_NL0[NLTABLE][NLUTWAV][NLTAU][NLTHET0][NLTHE][NLPHI];
104 float Fd_NL0[NLTABLE][NLUTWAV][NLTAU][NLTHET0];
105 float T_NL0[NLTABLE][NLUTWAV][NLTAU][NLTHET0][NLTHE];
106 float OMEGA0[NLTABLE][NLUTWAV][NLTAU];
109 float OPTH_NL1[NLSIZE][NLUTWAV][NLTAU];
110 float MASSCOEF_NL1[NLSIZE][NLUTWAV][NLTAU];
111 float EXTNORM_NL1[NLSIZE][NLUTWAV][NLTAU];
112 float SSA_NL1[NLSIZE][NLUTWAV][NLTAU];
113 float QEXT_NL1[NLSIZE][NLUTWAV][NLTAU];
114 float BEXT_NL1[NLSIZE][NLUTWAV][NLTAU];
115 float VEXT_NL1[NLSIZE][NLUTWAV][NLTAU];
116 float MEXT_NL1[NLSIZE][NLUTWAV][NLTAU];
117 float SBAR_NL1[NLSIZE][NLUTWAV][NLTAU][NLTHET0];
118 float INT_NL1[NLSIZE][NLUTWAV][NLTAU][NLTHET0][NLTHE][NLPHI];
119 float Fd_NL1[NLSIZE][NLUTWAV][NLTAU][NLTHET0];
120 float T_NL1[NLSIZE][NLUTWAV][NLTAU][NLTHET0][NLTHE];
131 float REF_RAYALL[NWAV][NUM_LUTS][NTH0][NTHET][NPHI];
132 float EXTSMALL[NWAV][NUM_CASES_SMALL][NUM_LUTS];
133 float RGSS[NUM_CASES_SMALL];
134 float SIGMAS[NUM_CASES_SMALL];
135 float MOMENTSSMALL[NUM_CASES_SMALL][NUM_MOMENTS][NUM_LUTS];
136 float CCNSMALL[NUM_CASES_SMALL][NUM_LUTS];
137 float BACKSCTTSMALL[NWAV][NUM_CASES_SMALL][NUM_LUTS];
138 float ASSYMSMALL[NWAV][NUM_CASES_SMALL][NUM_LUTS];
139 float ALBEDOSMALL[NWAV][NUM_CASES_SMALL][NUM_LUTS];
140 float ALBEDO_R_SMALL[NWAV][NUM_CASES_SMALL][NAOT][NUM_LUTS][NTH0];
141 float ALBEDO_T_SMALL[NWAV][NUM_CASES_SMALL][NAOT][NUM_LUTS][NTH0];
142 float ALBEDO_R_RAY[NWAV][NTH0];
143 float ALBEDO_T_RAY[NWAV][NTH0];
144 float AINTS[NWAV][NUM_CASES_SMALL][NAOT][NUM_LUTS][NTH0][NTHET][NPHI];
145 float TAUAS[NWAV][NUM_CASES_SMALL][NAOT];
146 float EFFRADSMALL[NUM_CASES_SMALL];
147 float EXTBIG[NWAV][NUM_CASES_BIG][NUM_LUTS];
148 float RGSB[NUM_CASES_BIG];
149 float SIGMAB[NUM_CASES_BIG];
150 float MOMENTSBIG[NUM_CASES_BIG][NUM_MOMENTS][NUM_LUTS];
151 float BACKSCTTBIG[NWAV][NUM_CASES_BIG][NUM_LUTS];
152 float ASSYMBIG[NWAV][NUM_CASES_BIG][NUM_LUTS];
153 float ALBEDOBIG[NWAV][NUM_CASES_BIG][NUM_LUTS];
154 float ALBEDO_R_BIG[NWAV][NUM_CASES_BIG][NAOT][NUM_LUTS][NTH0];
155 float ALBEDO_T_BIG[NWAV][NUM_CASES_BIG][NAOT][NUM_LUTS][NTH0];
156 float AINTB[NWAV][NUM_CASES_BIG][NAOT][NUM_LUTS][NTH0][NTHET][NPHI];
157 float TAUAB[NWAV][NUM_CASES_BIG][NAOT];
158 float EFFRADBIG[NUM_CASES_BIG];
162 static const int TRANSM_H2O_TABLES = 6;
163 static const int TRANSM_H2O_ROWS = 220;
164 static const int TRANSM_H2O_VALS = 6;
165 static const int REFL_CH2_ROWS = 158080;
166 static const int REFL_CH2_VALS = 7;
167 static const int WEIGHT_VALS = 3;
171 float TRANSM_H20[TRANSM_H2O_TABLES][TRANSM_H2O_ROWS][TRANSM_H2O_VALS];
172 float WEIGHTS[TRANSM_H2O_ROWS][WEIGHT_VALS];
173 float REFL_CH2[REFL_CH2_ROWS][REFL_CH2_VALS];
174 float RATIO_CH19_TO_CH2[REFL_CH2_ROWS][REFL_CH2_VALS];
236 int create_dt_nc4_lut();
242 int read_grib_lut(
dtGribLUT &grib_lut );
281 int read_land_aerosol_file(
const string groupname,
int wnum,
288 int read_land_aerosol_map(
const string groupname,
295 int read_ocean_big_aerosol_file(
const string groupname,
int wnum,
302 int read_ocean_small_aerosol_file(
const string groupname,
int wnum,
309 int read_transm_h2o_file(
const string groupname,
int num,
316 int read_ch2_reflectance_file(
const string groupname,
323 int read_ch19_to_ch2_ratio_file(
const string groupname,
330 int read_weight_table_file(
const string groupname,
337 int write_global_attributes( NcFile* nc_output );
343 bool isPlatformLittleEndian();
349 int write_grib_lut( NcFile* nc_output,
dtGribLUT* grib_lut );
373 int write_water_vapor_lut( NcFile* nc_output,
dtWaterVaporLUT* oa_lut );
418 static void byteSwap(T& aValue);
429 T tempValue = aValue;
432 unsigned char* aValuePtr =
reinterpret_cast<unsigned char*
>(&aValue);
433 unsigned char* tempValuePtr =
reinterpret_cast<unsigned char*
>(&tempValue);
436 for (
unsigned int byte = 0;
byte <
sizeof(aValue); ++
byte)
438 aValuePtr[
byte] = tempValuePtr[(
sizeof(aValue) - 1) -
byte];