49 navblk_sType navblk[],
50 tilt_states_sType *tiltblk,
52 static FILE *fp =
NULL;
76 static INT16 lastScanTemp[8] = {0, 0, 0, 0, 0, 0, 0, 0};
77 static INT16 lastMirrorSide = 0;
78 static INT16 lastTdi[8] = {0, 0, 0, 0, 0, 0, 0, 0};
96 if (scene->mnftype ==
GACTYPE) {
114 s_inst =
sizeof (
l1rec[0].inst);
122 if ((fp = fopen(scene->l0file,
"r")) ==
NULL) {
124 "-E- %s line %d: unable to open %s for reading\n",
125 __FILE__, __LINE__, scene->l0file);
132 fileFrameNum = scene->indx[sceneFrameNum];
133 fileBytePos =
sizeof (swl0hdr) + fileFrameNum * (
L0LEN);
134 if (fseek(fp, fileBytePos, SEEK_SET) != 0) {
136 "-E- %s line %d: error reading %s\n",
137 __FILE__, __LINE__, scene->l0file);
140 if (fread(mnf,
L0LEN, 1, fp) != 1) {
142 "-E- %s line %d: error reading %s\n",
143 __FILE__, __LINE__, scene->l0file);
148 memcpy(scid, &mnf[
O_SCID],
sizeof (scid));
153 if (mnftype != scene->mnftype) {
155 "-E- %s line %d: frame type mismatch\n",
165 for (irec = 0; irec < nrecs; irec++) {
168 memset(&
l1rec[irec], 0,
sizeof (swl1rec));
170 l1rec[irec].type = scene->mnftype;
181 memcpy(
l1rec[irec].inst, &mnf[o_inst + irec * s_inst], s_inst);
192 o_gtdipix = o_data + irec * s_data + 0;
193 o_startpix = o_data + irec * s_data + 16;
194 o_darkpix = o_data + irec * s_data + 32;
195 o_image = o_data + irec * s_data + 48;
196 o_stoppix = o_data + irec * s_data + s_data - 16;
198 memcpy(
l1rec[irec].startpix, &mnf[o_startpix],
199 sizeof (
l1rec[0].startpix));
200 memcpy(
l1rec[irec].darkpix, &mnf[o_darkpix],
201 sizeof (
l1rec[0].darkpix));
202 memcpy(&
l1rec[irec].
data[0][0], &mnf[o_image],
204 memcpy(
l1rec[irec].stoppix, &mnf[o_stoppix],
205 sizeof (
l1rec[0].stoppix));
218 if (scene->type ==
HRPT && l0ctl->gainSetting >= 0) {
220 l1rec[irec].gain[
i] = l0ctl->gainSetting;
226 memcpy(
l1rec[irec].
tdi, lastTdi,
sizeof (lastTdi));
227 memcpy(lastTdi, &mnf[o_gtdipix],
sizeof (lastTdi));
246 if (
l1rec[irec].startpix[7] == 0)
247 l1rec[irec].side = 0;
248 else if (
l1rec[irec].startpix[7] == 1023)
249 l1rec[irec].side = 1;
257 l1rec[irec].side = lastMirrorSide;
259 l1rec[irec].side = (lastMirrorSide + 1) % 2;
261 lastMirrorSide =
l1rec[irec].side;
269 memcpy(
l1rec[irec].sc_ana, navinp[sceneFrameNum].sc_ana,
270 sizeof (
l1rec[0].sc_ana));
271 memcpy(
l1rec[irec].sc_dis, navinp[sceneFrameNum].sc_dis,
272 sizeof (
l1rec[0].sc_dis));
273 memcpy(
l1rec[irec].inst_ana,
274 &(navinp[sceneFrameNum].inst_ana[irec][0]),
275 sizeof (
l1rec[0].inst_ana));
276 memcpy(
l1rec[irec].inst_dis,
277 &(navinp[sceneFrameNum].inst_dis[irec][0]),
278 sizeof (
l1rec[0].inst_dis));
283 (irec * 4 *
DTLAC * 1000)) % 86400000;
289 sceneScanNum = sceneFrameNum * nrecs + irec;
290 memcpy(
l1rec[irec].orb_vec, navblk[sceneScanNum].orb_vec,
291 sizeof (
l1rec[0].orb_vec));
292 memcpy(
l1rec[irec].l_vert, navblk[sceneScanNum].l_vert,
293 sizeof (
l1rec[0].l_vert));
294 memcpy(
l1rec[irec].sun_ref, navblk[sceneScanNum].sun_ref,
295 sizeof (
l1rec[0].sun_ref));
298 memcpy(
l1rec[irec].sen_mat, navblk[sceneScanNum].sen_mat,
299 sizeof (
l1rec[0].sen_mat));
302 memcpy(
l1rec[irec].nflag, navblk[sceneScanNum].nflag,
303 sizeof (
l1rec[0].nflag));
304 l1rec[irec].tilt = tiltblk->tilt[sceneScanNum];
310 if (navblk[sceneScanNum].nflag[0] == 0) {
311 geonav_(navblk[sceneScanNum].orb_vec,
312 navblk[sceneScanNum].sen_mat,
314 navblk[sceneScanNum].sun_ref,
340 l1rec[irec].scan_temp[0] =
l1rec[irec].inst[ 7] & 255;
341 l1rec[irec].scan_temp[1] =
l1rec[irec].inst[ 7] & 255;
342 l1rec[irec].scan_temp[2] =
l1rec[irec].inst[ 8] & 255;
343 l1rec[irec].scan_temp[3] =
l1rec[irec].inst[ 8] & 255;
344 l1rec[irec].scan_temp[4] =
l1rec[irec].inst[ 9] & 255;
345 l1rec[irec].scan_temp[5] =
l1rec[irec].inst[ 9] & 255;
346 l1rec[irec].scan_temp[6] =
l1rec[irec].inst[10] & 255;
347 l1rec[irec].scan_temp[7] =
l1rec[irec].inst[10] & 255;
349 lastScanTemp[
i] =
l1rec[irec].scan_temp[
i];
356 if ((scene->mnftype ==
GACTYPE) && (irec == 0)) {
363 memcpy(inst, &mnf[o_inst + s_inst], s_inst);
368 l1rec[irec].scan_temp[0] = inst[ 7] & 255;
369 l1rec[irec].scan_temp[1] = inst[ 7] & 255;
370 l1rec[irec].scan_temp[2] = inst[ 8] & 255;
371 l1rec[irec].scan_temp[3] = inst[ 8] & 255;
372 l1rec[irec].scan_temp[4] = inst[ 9] & 255;
373 l1rec[irec].scan_temp[5] = inst[ 9] & 255;
374 l1rec[irec].scan_temp[6] = inst[10] & 255;
375 l1rec[irec].scan_temp[7] = inst[10] & 255;
387 l1rec[irec].scan_temp[
i] = lastScanTemp[
i];
400 nbits += (256 * mnf[0] + mnf[1]);
405 l1rec[irec].s_flags[1] = scene->qual[sceneFrameNum];
408 l1rec[irec].s_flags[2] = (mnfnum - 1) * 5 + irec + 1;
410 l1rec[irec].s_flags[2] = 1;