28 static unsigned short *bnd_short;
29 static float *bnd_float;
42 for (ibnd = 0; ibnd < out_rec->nbnd; ibnd++) {
47 min_sq1[ibnd] = 99999;
48 max_sq1[ibnd] = -99999;
49 min_sq2[ibnd] = 99999;
50 max_sq2[ibnd] = -99999;
57 nlin = out_rec->ndet_scan;
60 if ((bnd_short = (
unsigned short *)
61 malloc(
nlin * out_rec->npix * sizeof (
unsigned short))) ==
NULL) {
62 printf(
"%s, %d: Unable to allocate bnd_short storage\n",
66 if ((bnd_float = (
float *)
67 malloc(
nlin * out_rec->npix * sizeof (
float))) ==
NULL) {
68 printf(
"%s, %d: Unable to allocate bnd_float storage\n",
74 ilin = out_rec->ndet_scan * iscn;
77 count[0] = out_rec->ndet_scan;
78 count[1] = out_rec->npix;
82 for (ibnd = 0; ibnd < out_rec->nbnd; ibnd++) {
83 lam_um = (
float) out_rec->lam_band[ibnd] / 1000.;
88 lcl_id = out_rec->bnd_dat_id[1][ibnd];
89 scale = out_rec->refl_scale[ibnd];
90 offset = out_rec->refl_offset[ibnd];
92 if (out_rec->meas_typ[ibnd] == 0) {
93 lcl_id = out_rec->bnd_dat_id[0][ibnd];
94 scale = out_rec->scale[ibnd];
95 offset = out_rec->offset[ibnd];
97 if (out_rec->out_bnd_typ[ibnd] == 0) {
98 for (ilin = 0; ilin <
nlin; ilin++) {
99 for (ipix = 0; ipix < out_rec->npix; ipix++) {
100 loc = ilin * out_rec->npix + ipix;
101 if (*(out_rec->bnd_q[ibnd] +
loc) == 1)
103 else if (*(out_rec->bnd_q[ibnd] +
loc) == 2)
106 tmpval2 = *(out_rec->bnd_lt[ibnd] +
loc);
111 *(bnd_short +
loc) = (
unsigned short) tmpval;
112 if (tmpval < min_sq1[ibnd]) min_sq1[ibnd] = (
int) tmpval;
113 if (tmpval > max_sq1[ibnd]) max_sq1[ibnd] = (
int) tmpval;
115 if (tmpval2 < min_q1[ibnd]) min_q1[ibnd] = tmpval2;
116 if (tmpval2 > max_q1[ibnd]) max_q1[ibnd] = tmpval2;
123 "%s, %d: radiance (short) scan write failure, scan %d, band %d\n",
124 __FILE__, __LINE__, iscn, ibnd);
130 for (ilin = 0,
loc = 0; ilin <
nlin; ilin++)
131 for (ipix = 0; ipix < out_rec->npix; ipix++,
loc++)
132 if (*(out_rec->bnd_q[ibnd] +
loc) == 1)
134 else if (*(out_rec->bnd_q[ibnd] +
loc) == 2)
137 tmpval = *(out_rec->bnd_lt[ibnd] +
loc);
138 *(bnd_float +
loc) = tmpval;
139 if (tmpval < min_q1[ibnd]) min_q1[ibnd] = tmpval;
140 if (tmpval > max_q1[ibnd]) max_q1[ibnd] = tmpval;
145 "%s, %d: radiance (float) scan write failure, scan %d, band %d\n",
146 __FILE__, __LINE__, iscn, ibnd);
154 if (out_rec->meas_typ[ibnd] == 0) {
159 lcl_id = out_rec->bnd_dat_id[1][ibnd];
160 for (ilin = 0; ilin <
nlin; ilin++) {
161 for (ipix = 0; ipix < out_rec->npix; ipix++) {
162 loc = ilin * out_rec->npix + ipix;
163 if (*(out_rec->bnd_q[ibnd] +
loc) == 1)
165 else if (*(out_rec->bnd_q[ibnd] +
loc) == 2)
169 tmpval2 = *(out_rec->bnd_lt[ibnd] +
loc) *
PI /
170 (out_rec->f0[ibnd] *
mu0);
171 tmpval = (tmpval2 - out_rec->refl_offset[ibnd])
172 / out_rec->refl_scale[ibnd];
176 *(bnd_short +
loc) = (
unsigned short) tmpval;
177 if (tmpval < min_sq2[ibnd]) min_sq2[ibnd] = (
int) tmpval;
178 if (tmpval > max_sq2[ibnd]) max_sq2[ibnd] = (
int) tmpval;
180 if (tmpval2 < min_q2[ibnd]) min_q2[ibnd] = tmpval2;
181 if (tmpval2 > max_q2[ibnd]) max_q2[ibnd] = tmpval2;
187 printf(
"%s, %d: reflectance scan write failure, scan %d, band %d\n",
188 __FILE__, __LINE__, iscn, ibnd);
196 lcl_id = out_rec->bnd_dat_id[0][ibnd];
197 for (ilin = 0; ilin <
nlin; ilin++) {
198 for (ipix = 0; ipix < out_rec->npix; ipix++) {
199 loc = ilin * out_rec->npix + ipix;
203 if (*(out_rec->bnd_q[ibnd] +
loc) == 1)
205 else if (*(out_rec->bnd_q[ibnd] +
loc) == 2)
208 tmpval =
bbt_2_rad(*(out_rec->bnd_lt[ibnd] +
loc), lam_um);
209 *(bnd_float +
loc) = tmpval;
210 if (tmpval < min_q2[ibnd]) min_q2[ibnd] = tmpval;
211 if (tmpval > max_q2[ibnd]) max_q2[ibnd] = tmpval;
216 if (out_rec->out_bnd_typ[ibnd] == 0) {
217 if (*(out_rec->bnd_q[ibnd] +
loc) == 1)
219 else if (*(out_rec->bnd_q[ibnd] +
loc) == 2)
222 tmpval = (*(bnd_float +
loc) - out_rec->offset[ibnd])
223 / out_rec->scale[ibnd];
224 *(bnd_short +
loc) = (
unsigned short) tmpval;
225 if (tmpval < min_sq2[ibnd]) min_sq2[ibnd] = (
int) tmpval;
226 if (tmpval > max_sq2[ibnd]) max_sq2[ibnd] = (
int) tmpval;
234 if (out_rec->out_bnd_typ[ibnd] == 0) {
237 "%s, %d: emissive radiance scan write failure, scan %d, band %d\n",
238 __FILE__, __LINE__, iscn, ibnd);
243 "%s, %d: emissive radiance scan write failure, scan %d, band %d\n",
244 __FILE__, __LINE__, iscn, ibnd);
252 out_rec->qual1_m[ibnd]) != 0) {
254 "%s, %d: scan write to QF1_VIIRSMBNDSDR failed. scan %d, band %d\n",
255 __FILE__, __LINE__, iscn, ibnd);
261 if (iscn == out_rec->nscan - 1) {
265 printf(
"%s, %d: info - Data minimum, maximum\n\n", __FILE__, __LINE__);
266 printf(
" Radiance (W / m^2 sr um) BBT (deg K for 12-16)\n");
267 printf(
" unscaled scaled\n");
268 printf(
"Band Minimum Maximum Minimum Maximum\n");
269 for (ibnd = 0; ibnd < out_rec->nbnd; ibnd++)
270 printf(
"%4d %8.4f %8.4f %6d %6d\n", ibnd + 1, min_q1[ibnd],
271 max_q1[ibnd], min_sq1[ibnd], max_sq1[ibnd]);
274 "\n Reflectance (no units) Rad (W / m^2 sr um for 12-16)\n\n");
275 printf(
" unscaled scaled\n");
276 printf(
"Band Minimum Maximum Minimum Maximum\n");
277 for (ibnd = 0; ibnd < out_rec->nbnd; ibnd++)
278 printf(
"%4d %8.6f %8.6f %6d %6d\n", ibnd + 1, min_q2[ibnd],
279 max_q2[ibnd], min_sq2[ibnd], max_sq2[ibnd]);