Go to the documentation of this file.
43 int32 dims [H4_MAX_VAR_DIMS];
45 int32 end [
NBTDIMS] = {1, 1, 1};
46 char name [H4_MAX_NC_NAME] =
"";
47 char sdsname[H4_MAX_NC_NAME] =
"";
53 printf(
"\nNo brightness temperature conversion provided for this sensor.\n");
58 printf(
"Loading radiance to brightness temperature from %s\n",
filename);
62 sd_id = SDstart(
filename, DFACC_RDONLY);
64 fprintf(
stderr,
"-E- %s line %d: SDstart(%s, %d) failed.\n",
65 __FILE__, __LINE__,
filename, DFACC_RDONLY);
71 status = SDreadattr(sd_id, SDfindattr(sd_id,
"Number of Bands"), &
nbnd);
73 status = SDreadattr(sd_id, SDfindattr(sd_id,
"number_of_bands"), &
nbnd);
75 printf(
"-E- %s Line %d: Error reading global attribute %s from %s.\n",
76 __FILE__, __LINE__,
"Number of Bands",
filename);
80 status = SDreadattr(sd_id, SDfindattr(sd_id,
"Number of Detectors"), &ndet);
82 status = SDreadattr(sd_id, SDfindattr(sd_id,
"number_of_detectors"), &ndet);
85 printf(
"-E- %s Line %d: Error reading global attribute %s from %s.\n",
86 __FILE__, __LINE__,
"Number of Detectors",
filename);
90 status = SDreadattr(sd_id, SDfindattr(sd_id,
"Number of Radiance Levels"), &ntab);
92 status = SDreadattr(sd_id, SDfindattr(sd_id,
"number_of_radiance_levels"), &ntab);
95 printf(
"-E- %s Line %d: Error reading global attribute %s from %s.\n",
96 __FILE__, __LINE__,
"Number of Radiance Levels",
filename);
101 printf(
"-E- %s Line %d: BT table dimensions exceed max allowable (%d %d %d).\n",
102 __FILE__, __LINE__, ntab,
nbnd, ndet);
106 printf(
"-E- %s Line %d: BT table dimensions does not match sensor attributes (%d %d).\n",
107 __FILE__, __LINE__,
nbnd, ndet);
113 strcpy(sdsname,
"Uselog");
114 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
118 printf(
"-E- %s: Error reading SDS %s from %s.\n", __FILE__, sdsname,
filename);
121 status = SDendaccess(sds_id);
125 strcpy(sdsname,
"Radiances");
126 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
128 for (ibnd = 0; ibnd <
nbnd; ibnd++)
for (idet = 0; idet < ndet; idet++)
for (
itab = 0;
itab < ntab;
itab++) {
134 printf(
"-E- %s: Error reading %s from %s.\n", __FILE__, sdsname,
filename);
138 status = SDendaccess(sds_id);
142 strcpy(sdsname,
"Temperatures");
143 sds_id = SDselect(sd_id, SDnametoindex(sd_id, sdsname));
145 for (ibnd = 0; ibnd <
nbnd; ibnd++)
for (idet = 0; idet < ndet; idet++)
for (
itab = 0;
itab < ntab;
itab++) {
151 printf(
"-E- %s: Error reading %s from %s.\n", __FILE__, sdsname,
filename);
155 status = SDendaccess(sds_id);
171 static int firstCall = 1;
174 int32_t ndets =
l1rec->l1file->ndets;
175 int32_t
id, ip, ib, ipb;
185 printf(
"Error loading brightness temperature table.\n");
189 printf(
"Brightness temperature file not specified.");
193 for (ib = 0; ib <
nbands; ib++)
194 for (
id = 0;
id < ndets;
id++)
195 radinc[ib][
id] = radtab[ib][
id][1] - radtab[ib][
id][0];
200 case 250:
id =
l1rec->detnum / 4;
202 case 500:
id =
l1rec->detnum / 2;
204 default:
id =
l1rec->detnum / 1;
208 for (ip = 0; ip <
l1rec->npix; ip++)
209 for (ib = 0; ib <
nbands; ib++) {
213 if (!isfinite(
l1rec->Ltir[ipb]) ||
l1rec->Ltir[ipb] <= 0.0) {
218 rad =
l1rec->Ltir[ipb]*10.0;
223 if (rad <= radtab[ib][
id][0])
225 else if (rad >= radtab[ib][
id][ntab - 1])
228 i = (int32_t) ((rad - radtab[ib][
id][0]) / radinc[ib][
id]);
229 a = (rad - radtab[ib][
id][
i]) / (radtab[ib][
id][
i + 1] - radtab[ib][
id][
i]);
230 l1rec->Bt[ipb] = temptab[ib][
id][
i] +
a * (temptab[ib][
id][
i + 1] - temptab[ib][
id][
i]);
231 l1rec->Bt[ipb] -= 273.15;
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that resolution
int read_bt_table(char *filename, int nbands, int ndets)
char filename[FILENAME_MAX]
void radiance2bt(l1str *l1rec, int resolution)
Extra metadata that will be written to the HDF4 file l2prod rank
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a