Go to the documentation of this file.
44 static char slp_flds[] = {
45 "g1d1,g1d2,g1d3,g1d4,g2d1,g2d2,g2d3,g2d4,g3d1,g3d2,g3d3,g3d4,g4d1,g4d2,g4d3,g4d4"
48 static char OFFSET_FLDS[] = {
49 "g1offs1,g1offs2,g1offs3,g1offs4,g2offs1,g2offs2,g2offs3,g2offs4,g3offs1,g3offs2,g3offs3,g3offs4,g4offs1,g4offs2,g4offs3,g4offs4"
52 static char TFACTOR_FLDS[] = {
53 "t_const,t_linear,t_quadratic"
56 static char CORRECTION_FLDS[] = {
57 "cal_offs,mirror1,mirror2"
60 static char *slp_names[] = {
61 "B1Slopes",
"B2Slopes",
"B3Slopes",
"B4Slopes",
"B5Slopes",
"B6Slopes",
62 "B7Slopes",
"B8Slopes"
65 static char *parm_names[] = {
66 "B1Parms",
"B2Parms",
"B3Parms",
"B4Parms",
"B5Parms",
"B6Parms",
98 attrnum = SDfindattr(sdfid,
REFYEAR);
99 if ((SDreadattr(sdfid, attrnum,
ref_year)) < 0)
102 attrnum = SDfindattr(sdfid,
REFDAY);
103 if ((SDreadattr(sdfid, attrnum,
ref_day)) < 0)
106 attrnum = SDfindattr(sdfid,
REFMIN);
107 if ((SDreadattr(sdfid, attrnum, ref_min)) < 0)
150 int16_t *cal_year, int16_t *cal_day) {
152 int16 dyear, dday, *cal_syear, *cal_sday, *cal_eyear, *cal_eday;
154 int32
i, *cal_smsec, *cal_emsec, vsid, elts;
159 if ((elts = VSelts(vsid)) < 0)
162 if ((cal_syear = (
int16 *) malloc(elts *
sizeof (
int16))) ==
NULL)
165 if ((cal_eyear = (
int16 *) malloc(elts *
sizeof (
int16))) ==
NULL)
174 if ((cal_smsec = (int32 *) malloc(elts *
sizeof (int32))) ==
NULL)
177 if ((cal_emsec = (int32 *) malloc(elts *
sizeof (int32))) ==
NULL)
186 rdvdata(vsid,
SYEAR, 0, elts, (
unsigned char *) cal_syear);
187 rdvdata(vsid,
SDAY, 0, elts, (
unsigned char *) cal_sday);
188 rdvdata(vsid,
SMSEC, 0, elts, (
unsigned char *) cal_smsec);
190 rdvdata(vsid,
EYEAR, 0, elts, (
unsigned char *) cal_eyear);
191 rdvdata(vsid,
EDAY, 0, elts, (
unsigned char *) cal_eday);
192 rdvdata(vsid,
EMSEC, 0, elts, (
unsigned char *) cal_emsec);
204 for (
i = elts - 1;
i > 0;
i--) {
205 if (cal_eyear[
i] == 0) {
206 if (dyear > cal_syear[
i])
208 if (dyear == cal_syear[
i] && dday > cal_sday[
i])
210 if (dyear == cal_syear[
i] && dday == cal_sday[
i] &&
211 msec >= cal_smsec[
i])
214 if (dyear > cal_syear[
i]) {
215 if (dyear < cal_eyear[
i])
217 if (dyear == cal_eyear[
i]) {
218 if (dday < cal_eday[
i])
220 if (dday == cal_eday[
i] &&
msec <= cal_emsec[
i])
224 if (dyear == cal_syear[
i]) {
225 if (dyear < cal_eyear[
i])
227 if (dyear == cal_eyear[
i]) {
228 if (dday >= cal_sday[
i] && dday < cal_eday[
i])
230 if (dday >= cal_sday[
i] && dday == cal_eday[
i] &&
231 msec <= cal_emsec[
i])
288 float32 gains[8][16], float32 temps[256][8],
289 float32
scan_mod[2][1285], float64 *tfactor_const,
290 float64 *tfactor_linear, float64 *tfactor_quadratic,
291 float32 *cal_offset, float32 mirror[2][8],
292 int16 tdi_list[256][4]) {
294 int32
i, slpid, parmid;
295 float32 parm_buf[8][3];
296 float64 tfactor_buf[8][3];
301 if ((
rdvdata(slpid, slp_flds,
index, 1, (
unsigned char *) gains[
i])) < 0)
309 (
unsigned char *) idoffs[
i])) < 0)
return RDERR;
312 (
unsigned char *) tfactor_buf[
i])) < 0)
return RDERR;
315 (
unsigned char *) parm_buf[
i])) < 0)
return RDERR;
321 tfactor_const[
i] = tfactor_buf[
i][0];
322 tfactor_linear[
i] = tfactor_buf[
i][1];
323 tfactor_quadratic[
i] = tfactor_buf[
i][2];
324 cal_offset[
i] = parm_buf[
i][0];
325 mirror[0][
i] = parm_buf[
i][1];
326 mirror[1][
i] = parm_buf[
i][2];
373 float32 gains[8][16], float32
counts[8][4][5],
374 float32
rads[8][4][5]) {
380 float32 loc_slopes[4];
381 float32 slopes[
BANDS][4][4];
382 int32 cnts[
BANDS][4][4];
387 for (
j = 0, l = 0;
j < 4;
j++)
388 for (
k = 0;
k < 4;
k++) {
390 slopes[
i][
j][
k] = gains[
i][l];
391 cnts[
i][
j][
k] = idoffs[
i][l++];
395 for (
j = 0;
j < 4;
j++)
396 dets[
j] = tdi_list[
tdi[
i]][
j] - 1;
399 scnts[
k] = 1023 - cnts[
i][
j][dets[
k]];
400 srads[
k] = scnts[
k] * slopes[
i][
j][dets[
k]];
401 loc_slopes[
k] = slopes[
i][
j][dets[
k]];
407 for (
k = 1;
k < 5;
k++)
408 rads[
i][
j][
k] = srads[oindex[
k - 1]];
411 counts[
i][
j][1] = (scnts[oindex[0]] +
412 srads[oindex[0]] / loc_slopes[oindex[1]] +
413 srads[oindex[0]] / loc_slopes[oindex[2]] +
414 srads[oindex[0]] / loc_slopes[oindex[3]]) / 4.0;
416 counts[
i][
j][2] = (scnts[oindex[0]] + scnts[oindex[1]] +
417 srads[oindex[1]] / loc_slopes[oindex[2]] +
418 srads[oindex[1]] / loc_slopes[oindex[3]]) / 4.0;
420 counts[
i][
j][3] = (scnts[oindex[0]] + scnts[oindex[1]] +
422 srads[oindex[2]] / loc_slopes[oindex[3]]) / 4.0;
424 counts[
i][
j][4] = (scnts[oindex[0]] + scnts[oindex[1]] +
425 scnts[oindex[2]] + scnts[oindex[3]]) / 4.0;
462 loc_dtype[
i] = tolower(
dtype[
i]);
465 if ((strcmp(loc_dtype,
GAC)) == 0)
472 printf(
"\n\n--------- GAC scan_mod values --------------\n");
502 int32
i, done = 0, exchange = 0, loc_index[
DETS], temp_index;
503 float32 loc_srads[
DETS], temp;
507 loc_srads[
i] = srads[
i];
511 for (exchange = 0,
i = 0;
i <
DETS - 1;
i++)
512 if (loc_srads[
i] > loc_srads[
i + 1]) {
515 temp_index = loc_index[
i];
516 loc_srads[
i] = loc_srads[
i + 1];
517 loc_index[
i] = loc_index[
i + 1];
518 loc_srads[
i + 1] = temp;
519 loc_index[
i + 1] = temp_index;
526 oindex[
i] = loc_index[
i];
529 for (
i = 0;
i < 4;
i++)
530 printf(
"\n %d\t%8.5f ", oindex[
i], loc_srads[
i]);
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
float rads[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
void sort_srads(float32 *srads, int32 *oindex)
int32 get_ref_time(int32 sdfid, int16 *ref_year, int16 *ref_day, int16 *ref_min)
int32_t get_index(int32_t fid, int16_t syear, int16_t sday, int16_t eday, int32_t msec, int16_t *cal_year, int16_t *cal_day)
int attach_vdata(int32_t fid, const char *sname)
int32 read_parm_data(int32 fid, int32 sdfid, int32 index, int32 idoffs[8][16], float32 gains[8][16], float32 temps[256][8], float32 scan_mod[2][1285], float64 *tfactor_const, float64 *tfactor_linear, float64 *tfactor_quadratic, float32 *cal_offset, float32 mirror[2][8], int16 tdi_list[256][4])
int16_t tdi[BANDS_DIMS_1A]
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that and then aggregated up to Resolved feature request Bug by adding three new int8 SDSs for each high resolution pixel
int rdvdata(int32_t vskey, const char *fields, int32_t start, int32_t nelt, unsigned char *databuf)
int32_t read_SDS(int32_t sdfid, const char *sds_name, void *buffer)
void setup_scanmod(char *dtype, float32 scan_mod[2][1285])
void calc_knees(int16 *tdi, int16 tdi_list[256][4], int32 idoffs[8][16], float32 gains[8][16], float32 counts[8][4][5], float32 rads[8][4][5])