Go to the documentation of this file.
17 using namespace netCDF;
18 using namespace netCDF::exceptions;
39 if (lut_ !=
nullptr) {
62 if (filepath_1.empty() || filepath_2.empty()) {
63 cerr <<
"DDAncillary:: Ancillary files missing: "
69 memset(lut_1, 0,
sizeof(
met_lut));
70 status = read_merra2_file( filepath_1, lut_1);
71 if (
status != DTDB_SUCCESS) {
72 cerr <<
"DDAncillary:: failure reading file 1: "
77 memset(lut_2, 0,
sizeof(
met_lut));
78 status = read_merra2_file( filepath_2, lut_2);
79 if (
status != DTDB_SUCCESS) {
80 cerr <<
"DDAncillary:: failure reading file 2: "
86 memset(lut_, 0,
sizeof(
met_lut));
88 for (
int iy=0; iy<
NMLATS; iy++) {
89 for (
int ix=0; ix<
NMLONS; ix++) {
90 lut_->ps[iy][ix] = lut_1->
ps[iy][ix] +
91 (lut_2->
ps[iy][ix]-lut_1->
ps[iy][ix])*
min/60.0;
92 lut_->oz[iy][ix] = lut_1->
oz[iy][ix] +
93 (lut_2->
oz[iy][ix]-lut_1->
oz[iy][ix])*
min/60.0;
94 lut_->pw[iy][ix] = lut_1->
pw[iy][ix] +
95 (lut_2->
pw[iy][ix]-lut_1->
pw[iy][ix])*
min/60.0;
96 lut_->u_ws[iy][ix] = lut_1->
u_ws[iy][ix] +
98 lut_->v_ws[iy][ix] = lut_1->
v_ws[iy][ix] +
119 int status = DTDB_SUCCESS;
123 NcVar var =
fio->getVar(
"PS");
124 var.getVar(&in->
ps[0][0]);
125 var =
fio->getVar(
"TO3");
126 var.getVar(&in->
oz[0][0]);
127 var =
fio->getVar(
"TQV");
128 var.getVar(&in->
pw[0][0]);
129 var =
fio->getVar(
"U10M");
130 var.getVar(&in->
u_ws[0][0]);
131 var =
fio->getVar(
"V10M");
132 var.getVar(&in->
v_ws[0][0]);
134 }
catch (NcException& e) {
136 cerr <<
"DDAncillary:: Failure opening ancillary file: "
154 map<string, ddata*> omap;
155 int status = DTDB_SUCCESS;
157 omap.insert({
"status", pstat});
163 omap.insert({
"wind_speed", pws});
165 omap.insert({
"wind_direction", pwd});
167 omap.insert({
"water_vapor", ppw});
169 omap.insert({
"ozone", poz});
171 omap.insert({
"surface_pressure", pps});
173 omap.insert({
"cloud_mask", puc});
178 NcVar var =
fio->getVar(
"PS");
180 var =
fio->getVar(
"TO3");
182 var =
fio->getVar(
"TQV");
187 var =
fio->getVar(
"U10M");
189 var =
fio->getVar(
"V10M");
192 for (
size_t iy=0; iy<plon->
count[0]; iy++) {
193 for (
size_t ix=0; ix<plon->
count[1]; ix++) {
195 pws->
pts[iy][ix] = sqrt(pu_ws->
pts[iy][ix]*pu_ws->
pts[iy][ix] +
196 pv_ws->
pts[iy][ix]*pv_ws->
pts[iy][ix]);
198 float wd = atan2(-1.0*pu_ws->
pts[iy][ix],-1.0*pv_ws->
pts[iy][ix]) *
200 pwd->
pts[iy][ix] = (wd < 0) ? wd + 360.0 : wd;
208 for (
size_t iy=0; iy<plon->
count[0]; iy++) {
209 for (
size_t ix=0; ix<plon->
count[1]; ix++) {
210 get_met(plat->
pts[iy][ix], plon->
pts[iy][ix], &io);
211 pws->
pts[iy][ix] = io.
ws;
212 pwd->
pts[iy][ix] = io.
wd;
213 ppw->
pts[iy][ix] = io.
pw;
214 poz->
pts[iy][ix] = io.
oz;
215 pps->
pts[iy][ix] = io.
ps;
222 NcVar var =
fio->getVar(
"ADJ_MASK");
223 var.getVar(plon->
start, plon->
count, (
unsigned char*)puc->
ptr);
226 for (
size_t iy=0; iy<plon->
count[0]; iy++) {
227 for (
size_t ix=0; ix<plon->
count[1]; ix++) {
237 int status = DTDB_SUCCESS;
239 if(
lat > 90.0 ||
lat < -90.0) {
240 cerr <<
"DDAncillary:: lat out of range, must be 90 to -90:" <<
lat << endl;
243 if (lon < -180.0 || lon > 180.0) {
244 cerr <<
"DDAncillary:: lon out of range, must be [-180,180):" <<
lon << endl;
254 if (
status != DTDB_SUCCESS) {
255 cerr <<
"DDAncillary:: Failed to get indexes for interpolation: " <<
status << endl;
259 float f[4] = {0,0,0,0};
260 float x1 = index2lon(i1);
261 float x2 = index2lon(i2);
262 float y1 = index2lat(j1);
263 float y2 = index2lat(j2);
268 f[0] = lut_->u_ws[j1][i1];
269 f[1] = lut_->u_ws[j1][i2];
270 f[2] = lut_->u_ws[j2][i2];
271 f[3] = lut_->u_ws[j2][i1];
275 u /= ((x2-x1)*(y2-y1));
279 f[0] = lut_->v_ws[j1][i1];
280 f[1] = lut_->v_ws[j1][i2];
281 f[2] = lut_->v_ws[j2][i2];
282 f[3] = lut_->v_ws[j2][i1];
286 v /= ((x2-x1)*(y2-y1));
292 float wd = atan2(-1.0*
u,-1.0*
v) * 180.0/
M_PI;
293 io->
wd = (wd < 0) ? wd + 360.0 : wd;
296 f[0] = lut_->pw[j1][i1];
297 f[1] = lut_->pw[j1][i2];
298 f[2] = lut_->pw[j2][i2];
299 f[3] = lut_->pw[j2][i1];
304 io->
pw = pwat / ((x2-x1)*(y2-y1));
310 f[0] = lut_->oz[j1][i1];
311 f[1] = lut_->oz[j1][i2];
312 f[2] = lut_->oz[j2][i2];
313 f[3] = lut_->oz[j2][i1];
318 io->
oz = oz / ((x2-x1)*(y2-y1));
321 f[0] = lut_->ps[j1][i1];
322 f[1] = lut_->ps[j1][i2];
323 f[2] = lut_->ps[j2][i2];
324 f[3] = lut_->ps[j2][i1];
329 io->
ps = ps / ((x2-x1)*(y2-y1));
346 if (lat < -90.0 || lat > 90.0) {
347 cerr <<
"DDAncillary:: Invalid latitude: " <<
lat << endl;
350 int index = floor((
lat + 90.0) / 0.5);
364 if (index < 0 || index >
NMLATS) {
365 cerr <<
"DDAncillary:: Index is out of bounds: " <<
index << endl;
384 if (lon < -180.0 || lon >= 180.0) {
385 cerr <<
"DDAncillary:: Invalid longitude: " <<
lon << endl;
388 int index = floor((
lon + 180.0)/0.625);
402 if (index < 0 || index >
NMLONS) {
403 cerr <<
"DDAncillary:: Index is out of bounds of windspeed array: " <<
index << endl;
424 int& i1,
int& i2,
int& j1,
int& j2)
429 if(
lat >= 90.0 ||
lat < -90.0) {
430 cerr <<
"DDAncillary:: lat out of range, must be [-90,90]:" <<
lat << endl;
433 if (lon < -180.0 || lon >= 180.0) {
434 cerr <<
"DDAncillary:: lon out of range, must be [-180,180]:" <<
lon << endl;
441 cerr <<
"DDAncillary:: Failed to convert longitude to index: " << i1 << endl;
447 cerr <<
"DDAncillary:: Failed to convert latitude to index: " << j1 << endl;
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT the first two or last two tables respectively will be used for the interpolation If there is only one LUT in the set of it will be treated as a constant LUT The manner in which Earth View data is checked for saturation was changed Previously the raw Earth View DNs and Space View DNs were checked against the lookup table values contained in the table dn_sat The change made is to check the raw Earth and Space View DNs to be sure they are less than the maximum saturation value and to check the Space View subtracted Earth View dns against a set of values contained in the new lookup table dn_sat_ev The metadata configuration and ASSOCIATEDINSTRUMENTSHORTNAME from the MOD02HKM product The same metatdata with extensions and were removed from the MOD021KM and MOD02OBC products ASSOCIATEDSENSORSHORTNAME was set to MODIS in all products These changes are reflected in new File Specification which users may consult for exact the pow functions were eliminated in Emissive_Cal and Emissive bands replaced by more efficient code Other calculations throughout the code were also made more efficient Aside from a few round off there was no difference to the product The CPU time decreased by about for a day case and for a night case A minor bug in calculating the uncertainty index for emissive bands was corrected The frame index(0-based) was previously being used the frame number(1-based) should have been used. There were only a few minor changes to the uncertainty index(maximum of 1 digit). 3. Some inefficient arrays(Sigma_RVS_norm_sq) were eliminated and some code lines in Preprocess_L1A_Data were moved into Process_OBCEng_Emiss. There were no changes to the product. Required RAM was reduced by 20 MB. Now
map< string, ddata * > read(map< string, ddata * > imap)
constexpr unsigned char DFILL_UBYTE
int lon2index(const float lon)
@ UBYTE
unsigned 1 byte int
These are used to scale the SD before writing it to the HDF4 file The default is and which means the product is not scaled at all Since the product is usually stored as a float inside of this is a way to write the float out as a integer l2prod min
boost::multi_array< T, ndim > pts
float index2lat(const int index)
@ FLOAT
single precision floating point number
string get_option(const string &name)
float v_ws[NMLATS][NMLONS]
int read_merra2_file(const string filename, met_lut *lut)
integer function lat2index(lat, status)
double precision function f(R1)
int lat2index(const float lat)
int initialize(int hr, int min)
int get_interp_indexes(const float lat, const float lon, int &i1, int &i2, int &j1, int &j2)
const string INPUT_CLDMASK
@ INT
signed 4 byte integer
float u_ws[NMLATS][NMLONS]
int get_met(const float lat, const float lon, metio *io)
float index2lon(const int index)