Go to the documentation of this file.
76 attrnum = SDfindattr(sdfid,
REFYEAR);
77 if ((SDreadattr(sdfid, attrnum,
ref_year)) < 0)
80 attrnum = SDfindattr(sdfid,
REFDAY);
81 if ((SDreadattr(sdfid, attrnum,
ref_day)) < 0)
84 attrnum = SDfindattr(sdfid,
REFMIN);
85 if ((SDreadattr(sdfid, attrnum, ref_min)) < 0)
131 int16_t *cal_year, int16_t *cal_day) {
133 int16 dyear, dday, *cal_syear, *cal_sday, *cal_eyear, *cal_eday;
135 int32_t
i, *cal_smsec, *cal_emsec, vsid, elts;
140 if ((elts = VSelts(vsid)) < 0)
143 if ((cal_syear = (
int16 *) malloc(elts *
sizeof (
int16))) ==
NULL)
146 if ((cal_eyear = (
int16 *) malloc(elts *
sizeof (
int16))) ==
NULL)
155 if ((cal_smsec = (int32_t *) malloc(elts *
sizeof (int32_t))) ==
NULL)
158 if ((cal_emsec = (int32_t *) malloc(elts *
sizeof (int32_t))) ==
NULL)
167 rdvdata(vsid,
SYEAR, 0, elts, (
unsigned char *) cal_syear);
168 rdvdata(vsid,
SDAY, 0, elts, (
unsigned char *) cal_sday);
169 rdvdata(vsid,
SMSEC, 0, elts, (
unsigned char *) cal_smsec);
171 rdvdata(vsid,
EYEAR, 0, elts, (
unsigned char *) cal_eyear);
172 rdvdata(vsid,
EDAY, 0, elts, (
unsigned char *) cal_eday);
173 rdvdata(vsid,
EMSEC, 0, elts, (
unsigned char *) cal_emsec);
185 for (
i = elts - 1;
i > 0;
i--) {
186 if (cal_eyear[
i] == 0) {
187 if (dyear > cal_syear[
i])
189 if (dyear == cal_syear[
i] && dday > cal_sday[
i])
191 if (dyear == cal_syear[
i] && dday == cal_sday[
i] &&
192 msec >= cal_smsec[
i])
196 if (dyear > cal_syear[
i])
198 else if ((dyear == cal_syear[
i]) && (dday > cal_sday[
i]))
200 else if ((dyear == cal_syear[
i]) && (dday == cal_sday[
i]) &&
201 (
msec >= cal_smsec[
i]))
205 if (dyear < cal_eyear[
i])
207 else if ((dyear == cal_eyear[
i]) && (dday < cal_eday[
i]))
209 else if ((dyear == cal_eyear[
i]) && (dday == cal_eday[
i]) &&
210 (
msec <= cal_emsec[
i]))
286 float gains[8][16],
float fp_temps[256][8],
287 float scan_mod[2][1285],
double *tfactor_const,
288 double *tfactor_linear_1,
double *tfactor_exponential_1,
289 double *tfactor_linear_2,
double *tfactor_exponential_2,
292 double *mside1_linear_1,
double *mside1_exponential_1,
293 double *mside1_linear_2,
double *mside1_exponential_2,
294 double *mside2_const,
double *mside2_linear_1,
295 double *mside2_exponential_1,
double *mside2_linear_2,
296 double *mside2_exponential_2, int16_t tdi_list[256][4]) {
298 int32_t
i, slpid, parmid;
299 float64 mirror_buf[8][10], tfactor_buf[8][10];
304 if ((
rdvdata(slpid, slp_flds,
index, 1, (
unsigned char *) gains[
i])) < 0)
312 (
unsigned char *) idoffs[
i])) < 0)
return RDERR;
315 (
unsigned char *) tfactor_buf[
i])) < 0)
return RDERR;
318 (
unsigned char *) mirror_buf[
i])) < 0)
return RDERR;
324 tfactor_const[
i] = tfactor_buf[
i][0];
325 tfactor_linear_1[
i] = tfactor_buf[
i][1];
326 tfactor_exponential_1[
i] = tfactor_buf[
i][2];
327 tfactor_linear_2[
i] = tfactor_buf[
i][3];
328 tfactor_exponential_2[
i] = tfactor_buf[
i][4];
329 cal_offset[
i] = tfactor_buf[
i][5];
334 mside1_const[
i] = mirror_buf[
i][0];
335 mside1_linear_1[
i] = mirror_buf[
i][1];
336 mside1_exponential_1[
i] = mirror_buf[
i][2];
337 mside1_linear_2[
i] = mirror_buf[
i][3];
338 mside1_exponential_2[
i] = mirror_buf[
i][4];
339 mside2_const[
i] = mirror_buf[
i][5];
340 mside2_linear_1[
i] = mirror_buf[
i][6];
341 mside2_exponential_1[
i] = mirror_buf[
i][7];
342 mside2_linear_2[
i] = mirror_buf[
i][8];
343 mside2_exponential_2[
i] = mirror_buf[
i][9];
389 void calc_knees(int16_t *
tdi, int16_t tdi_list[256][4], int32_t idoffs[8][16],
390 float gains[8][16],
float counts[8][4][5],
391 float rads[8][4][5]) {
397 float32 loc_slopes[4];
398 float32 slopes[
BANDS][4][4];
399 int32_t cnts[
BANDS][4][4];
400 int32_t oindex[
DETS];
404 for (
j = 0, l = 0;
j < 4;
j++)
405 for (
k = 0;
k < 4;
k++) {
407 slopes[
i][
j][
k] = gains[
i][l];
408 cnts[
i][
j][
k] = idoffs[
i][l++];
412 for (
j = 0;
j < 4;
j++)
413 dets[
j] = tdi_list[
tdi[
i]][
j] - 1;
416 scnts[
k] = 1023 - cnts[
i][
j][dets[
k]];
417 srads[
k] = scnts[
k] * slopes[
i][
j][dets[
k]];
418 loc_slopes[
k] = slopes[
i][
j][dets[
k]];
424 for (
k = 1;
k < 5;
k++)
425 rads[
i][
j][
k] = srads[oindex[
k - 1]];
428 counts[
i][
j][1] = (scnts[oindex[0]] +
429 srads[oindex[0]] / loc_slopes[oindex[1]] +
430 srads[oindex[0]] / loc_slopes[oindex[2]] +
431 srads[oindex[0]] / loc_slopes[oindex[3]]) / 4.0;
433 counts[
i][
j][2] = (scnts[oindex[0]] + scnts[oindex[1]] +
434 srads[oindex[1]] / loc_slopes[oindex[2]] +
435 srads[oindex[1]] / loc_slopes[oindex[3]]) / 4.0;
437 counts[
i][
j][3] = (scnts[oindex[0]] + scnts[oindex[1]] +
439 srads[oindex[2]] / loc_slopes[oindex[3]]) / 4.0;
441 counts[
i][
j][4] = (scnts[oindex[0]] + scnts[oindex[1]] +
442 scnts[oindex[2]] + scnts[oindex[3]]) / 4.0;
488 printf(
"\n\n--------- GAC scan_mod values --------------\n");
518 int32_t
i, done = 0, exchange = 0, loc_index[
DETS], temp_index;
519 float32 loc_srads[
DETS], temp;
523 loc_srads[
i] = srads[
i];
527 for (exchange = 0,
i = 0;
i <
DETS - 1;
i++)
528 if (loc_srads[
i] > loc_srads[
i + 1]) {
531 temp_index = loc_index[
i];
532 loc_srads[
i] = loc_srads[
i + 1];
533 loc_index[
i] = loc_index[
i + 1];
534 loc_srads[
i + 1] = temp;
535 loc_index[
i + 1] = temp_index;
542 oindex[
i] = loc_index[
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]
double fp_tcorr[BANDS_DIMS_1A]
int attach_vdata(int32_t fid, const char *sname)
double fp_tref[BANDS_DIMS_1A]
int32_t read_parm_data(int32_t fid, int32_t sdfid, int32_t index, int32_t idoffs[8][16], float gains[8][16], float fp_temps[256][8], float scan_mod[2][1285], double *tfactor_const, double *tfactor_linear_1, double *tfactor_exponential_1, double *tfactor_linear_2, double *tfactor_exponential_2, double *cal_offset, double *inst_tcorr, double *inst_tref, double *fp_tcorr, double *fp_tref, double *mside1_const, double *mside1_linear_1, double *mside1_exponential_1, double *mside1_linear_2, double *mside1_exponential_2, double *mside2_const, double *mside2_linear_1, double *mside2_exponential_1, double *mside2_linear_2, double *mside2_exponential_2, int16_t tdi_list[256][4])
void sort_srads(float *srads, int32_t *oindex)
void setup_scanmod(int32_t npix, int32_t nsta, int32_t ninc, float scan_mod[2][1285])
int32_t get_tindex(int32_t fid, int16_t syear, int16_t sday, int16_t eday, int32_t msec, int16_t *cal_year, int16_t *cal_day)
double inst_tcorr[BANDS_DIMS_1A]
int16_t tdi[BANDS_DIMS_1A]
int32_t get_ref_time(int32_t sdfid, int16_t *ref_year, int16_t *ref_day, int16_t *ref_min)
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
float fp_temps[256][BANDS_DIMS_1A]
double inst_tref[BANDS_DIMS_1A]
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 calc_knees(int16_t *tdi, int16_t tdi_list[256][4], int32_t idoffs[8][16], float gains[8][16], float counts[8][4][5], float rads[8][4][5])