OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
l1a_seawifs.c
Go to the documentation of this file.
1 #include <hdf4utils.h>
2 #include "l1a.h"
3 #include "navigation.h"
4 #include "l1a_proto.h"
5 #include "eng_qual.h"
6 #include "l1.h"
7 #include "l1a_seawifs.h"
8 #include "call1a_proto.h"
9 #include "getcal_proto.h"
10 #include "st_proto.h"
11 
12 #include <hdf.h>
13 #include <mfhdf.h>
14 
15 #define LAC_PIXEL_NUM 1285
16 #define GAC_PIXEL_NUM 248
17 #define NREC_IN_BUF 10
18 #define STBUFSIZ 5
19 #define NOTDONE 0
20 #define FIRST_KNEE 1
21 #define MASK_HIGHLT1 16
22 #define GENBUFSIZ NREC_IN_BUF*sizeof(float)*40 /* size of inst_ana */
23 
24 //static int evalmask;
25 
26 int16_t syear, sday; /* data start date */
27 int32_t smsec; /* data start time */
28 int16_t eyear, eday; /* data end date */
29 int32_t emsec; /* data end time */
30 int32_t nscan; /* number of scans */
31 int32_t npix; /* number pixels per scan */
32 int32_t spix; /* start pixel number (from 0) */
33 int32_t dpix; /* LAC pixel increment */
34 float dark_mean[8]; /* Mean of dark restore counts */
35 float dark_std[8]; /* Std dev of dark restore counts */
36 
37 int16_t tdi[BANDS_DIMS_1A] = {0, 0, 0, 0, 0, 0, 0, 0};
38 
39 int16_t entry_year;
40 int16_t entry_day;
41 int16_t ref_year;
42 int16_t ref_day;
43 int16_t ref_minute;
44 float fp_temps[256][BANDS_DIMS_1A];
45 float scan_mod[2][1285];
48 
69 
70 char cal_path_tab[128];
71 char dtype[8];
72 
75 
76 
80 
81 int32_t nsta;
82 int32_t ninc;
83 
84 int16_t *l1a_data = NULL; /* raw radiances band-int-by-pix */
85 int16_t *l1a_back = NULL; /* raw radiances band-int-by-pix */
86 float *l1b_buffer = NULL; /* l1b radiances band-int-by-pix */
87 int32_t *msec;
88 int16_t *side;
89 int16_t *dark_rest;
90 float *tilt;
91 
98 
99 
100 int16_t stray_light = -1; /* num pixels to apply sl correct. */
101 float Ltyp_frac = 0.25; /* fraction of B8 for sl threshold */
102 int16_t out_band = 0; /* if <= 0, no out of band correct. */
103 
104 typedef struct {
105  int16_t gain[8];
106  int16_t tdi[8];
107  int16_t scan_temp[8];
108  float inst_temp[40];
109  float orb_vec[3];
110  float sun_ref[3];
111  float sen_mat[3 * 3];
112  float scan_ell[6];
113 } inputBuffer;
114 
115 
116 int32_t do_st = 1;
117 
118 int32_t get_l1a_rec(int32_t sd_id, int32_t recno, cal_mod_struc *cal_mod,
119  int16_t *l1a_dum, float **l1b_data, int16_t **l2_flags) {
120  /* */
121  /* local vars */
122  /* */
123  int32_t ipix; /* pixel number */
124  int32_t idet; /* detector number */
125  int32_t irec;
126  int32_t start[3] = {0, 0, 0};
127  int32_t edges[3];
128 
129  int16_t band_buf[LAC_PIXEL_NUM * 8];
130  int32_t scan_no;
131  int16_t gain8;
132  int32_t AS_pixels;
133  float Styp_frac = 0.9;
134  int32_t sl_scan;
135  int16_t *l1a_ptr;
136  int16_t *gain_ptr;
137 
138  static inputBuffer rdBuf[NREC_IN_BUF];
139  static inputBuffer bkBuf[STBUFSIZ - 2];
140  byte genBuf[GENBUFSIZ];
141 
142  static int32_t crec = -1;
143  static int16_t recursive_flag = 0;
144  static int16_t n_read = 0;
145  static int32_t max_rec_in_rdbuf;
146  static int32_t offset;
147  static int32_t i, j;
148  static int32_t stray_light_scan_no;
149 
150  static float *st_l1b_data;
151  static int16_t *st_l2_flags;
152 
153  static int32_t initial = 1;
154  static byte first = 1;
155 
156 
157  static int16_t hi_Lt[LAC_PIXEL_NUM]; /* whether radiance > knee */
158  int pixvalue; /* l1a pixel value */
159  int pixdark; /* dark_restore value for each pixel */
160  float kneevalue; /* radiance at first knee */
161 
162  /* */
163  /* Read L1A data scan by scan, build L1B record, and write. */
164 
165  /* If reading out-of-sequence, force restart from beginning to get stlight */
166  /* baf, 05-oct-2001. */
167  if (first || recno < crec) {
168  max_rec_in_rdbuf = recno - 1;
169  stray_light_scan_no = recno;
170  }
171 
172  crec = recno;
173 
174  if (crec > nscan) return 0;
175 
176 
177  if (crec > max_rec_in_rdbuf) {
178 
179  memcpy(&bkBuf, &rdBuf[NREC_IN_BUF - STBUFSIZ + 2],
180  sizeof (inputBuffer) * (STBUFSIZ - 2));
181  memcpy(l1a_back, &l1a_data[(NREC_IN_BUF - STBUFSIZ + 2) * npix * 8],
182  npix * 8 * (STBUFSIZ - 2) * sizeof (int16_t));
183 
184  n_read = (nscan - max_rec_in_rdbuf >= NREC_IN_BUF) ?
185  NREC_IN_BUF : nscan - max_rec_in_rdbuf;
186 
187 
188  edges[0] = 1;
189  start[1] = 0;
190  edges[1] = npix;
191  edges[2] = 8;
192  for (irec = 0; irec < n_read; irec++) {
193  start[0] = recno - 1 + irec;
194  SDreaddata(SDselect(sd_id, SDnametoindex(sd_id, "l1a_data")),
195  start, NULL, edges, (VOIDP) band_buf);
196  for (ipix = 0; ipix < npix; ipix++)
197  for (idet = 0; idet < 8; idet++)
198  l1a_data[irec * (8 * npix) + idet * npix + ipix] =
199  band_buf[ipix * 8 + idet];
200  }
201 
202 
203  rdSDS(sd_id, "gain", recno - 1, 0, n_read, 8, (VOIDP) genBuf);
204  for (i = 0; i < n_read; i++)
205  memcpy(&rdBuf[i].gain, &genBuf[i * 8 * 2], 8 * 2);
206 
207  rdSDS(sd_id, "tdi", recno - 1, 0, n_read, 8, (VOIDP) genBuf);
208  for (i = 0; i < n_read; i++)
209  memcpy(&rdBuf[i].tdi, &genBuf[i * 8 * 2], 8 * 2);
210 
211  rdSDS(sd_id, "scan_temp", recno - 1, 0, n_read, 8, (VOIDP) genBuf);
212  for (i = 0; i < n_read; i++)
213  memcpy(&rdBuf[i].scan_temp, &genBuf[i * 8 * 2], 8 * 2);
214 
215  rdSDS(sd_id, "inst_ana", recno - 1, 0, n_read, 40, (VOIDP) genBuf);
216  for (i = 0; i < n_read; i++)
217  memcpy(&rdBuf[i].inst_temp, &genBuf[i * 40 * 4], 40 * 4);
218 
219  rdSDS(sd_id, "orb_vec", recno - 1, 0, n_read, 3, (VOIDP) genBuf);
220  for (i = 0; i < n_read; i++)
221  memcpy(&rdBuf[i].orb_vec, &genBuf[i * 3 * 4], 3 * 4);
222 
223  rdSDS(sd_id, "sun_ref", recno - 1, 0, n_read, 3, (VOIDP) genBuf);
224  for (i = 0; i < n_read; i++)
225  memcpy(&rdBuf[i].sun_ref, &genBuf[i * 3 * 4], 3 * 4);
226 
227  rdSDS(sd_id, "scan_ell", recno - 1, 0, n_read, 6, (VOIDP) genBuf);
228  for (i = 0; i < n_read; i++)
229  memcpy(&rdBuf[i].scan_ell, &genBuf[i * 6 * 4], 6 * 4);
230 
231 
232  start[0] = recno - 1;
233  edges[0] = n_read;
234  start[1] = 0;
235  edges[1] = 3;
236  edges[2] = 3;
237  SDreaddata(SDselect(sd_id, SDnametoindex(sd_id, "sen_mat")),
238  start, NULL, edges, (VOIDP) genBuf);
239  for (i = 0; i < n_read; i++)
240  memcpy(&rdBuf[i].sen_mat, &genBuf[i * 9 * 4], 9 * 4);
241 
242 
243  offset = max_rec_in_rdbuf + 1;
244  max_rec_in_rdbuf += n_read;
245  }
246 
247  if ((crec - offset) >= 0) {
248  j = crec - offset;
249  gain8 = rdBuf[j].gain[7];
250  gain_ptr = rdBuf[j].gain;
251  l1a_ptr = &l1a_data[j * 8 * npix];
252 
253  l1b_rad(syear, sday, smsec, msec[recno - 1],
254  dtype, nsta, ninc, npix,
255  dark_mean, rdBuf[j].gain, rdBuf[j].tdi,
256  rdBuf[j].scan_temp, rdBuf[j].inst_temp, side[recno - 1],
257  &l1a_data[j * 8 * npix], l1b_buffer, cal_mod);
258  /*
259  calibrate_l1a(cal_path_tab,syear,sday,smsec,eday,msec[recno-1],
260  dtype, nsta, ninc, npix,
261  dark_mean, rdBuf[j].gain, rdBuf[j].tdi,
262  rdBuf[j].scan_temp, rdBuf[j].inst_temp, side[recno-1],
263  &l1a_data[j*8*npix], l1b_buffer, cal_mod);
264  */
265 
266  if (!recursive_flag) {
267  geonav_(rdBuf[j].orb_vec, rdBuf[j].sen_mat, rdBuf[j].scan_ell,
268  rdBuf[j].sun_ref, &nsta, &ninc, &npix,
269  ylat, xlon, solz, sola, senz, sena);
270 
271  }
272  } else {
273  j = (STBUFSIZ - 2) + (crec - offset);
274  gain8 = bkBuf[j].gain[7];
275  gain_ptr = bkBuf[j].gain;
276  l1a_ptr = &l1a_back[j * 8 * npix];
277 
278  if (!recursive_flag) {
279  geonav_(bkBuf[j].orb_vec, bkBuf[j].sen_mat, bkBuf[j].scan_ell,
280  bkBuf[j].sun_ref, &nsta, &ninc, &npix,
281  ylat, xlon, solz, sola, senz, sena);
282 
283  }
284  }
285 
286  if (first) {
287  memcpy(pcal_counts, cal_counts, sizeof (cal_counts));
288  memcpy(pcal_rads, cal_rads, sizeof (cal_rads));
289  first = 0;
290  }
291 
292  if (!recursive_flag) {
293  for (ipix = 0; ipix < npix; ipix++) {
294  hi_Lt[ipix] = FALSE;
295  /* HILT check limited to bands 7 & 8, BAF, 23 Jan 2002 */
296  /* Use dark_mean rather than dark_rest, BAF, 7 July 2003 */
297  for (idet = 6; (idet < 8)&&(hi_Lt[ipix] == FALSE); idet++) {
298  pixvalue = l1a_ptr[ipix + npix * idet];
299  /*
300  pixdark = dark_rest[8*(recno-1)+idet];
301  */
302  pixdark = dark_mean[idet];
303  kneevalue = pcal_counts[idet][gain_ptr[idet]][FIRST_KNEE];
304  hi_Lt[ipix] = ((pixvalue - pixdark) >= kneevalue);
305  }
306  }
307  }
308 
309 
310  scan_no = crec;
311  AS_pixels = stray_light;
312 
313  if (do_st == 0) {
314 
315  for (ipix = 0; ipix < npix; ipix++)
316  l2_flags_buffer[ipix] = 0;
317 
318  } else if (!recursive_flag) {
319 
320  do {
321  if (stray_light_scan_no != scan_no) {
322 
323  recursive_flag = 1;
324 
325  get_l1a_rec(sd_id, stray_light_scan_no, cal_mod,
326  l1a_dum, &st_l1b_data, &st_l2_flags);
327  }
328  } while (stray_light_corr(&initial, Ltyp_frac, Styp_frac,
329  nscan, npix, stray_light_scan_no++, dtype,
330  gain8, &pcal_rads[0][0][0], l1b_buffer, &sl_scan,
331  l2_flags_buffer, &AS_pixels) == NOTDONE);
332  recursive_flag = 0;
333  crec = scan_no;
334 
335  }
336 
337 
338 
339  for (ipix = 0; ipix < npix; ipix++) {
340  if (hi_Lt[ipix])
341  l2_flags_buffer[ipix] |= MASK_HIGHLT1;
342  }
343 
344  *l1b_data = l1b_buffer;
345  *l2_flags = l2_flags_buffer;
346 
347  return (0);
348 }
349 
350 int openl1a_seawifs(filehandle *file) {
351 
352  /* */
353  /* input files */
354  /* */
355  char *cal_path = l1_input->calfile;
356 
357  /* */
358  /* get_l1a_open interface */
359  /* */
360  int32_t fileID;
361  int32_t status;
362  char buf[32];
363 
364 
365  /* */
366  /* set static global evaluation switch */
367  /* */
368  // evalmask = input->evalmask;
369 
370  /* open the file and get the file ID */
371  fileID = SDstart(file->name, DFACC_RDONLY);
372 
373  if (fileID < 0) {
374  fprintf(stderr,
375  "-E %s Line %d: Error opening %s for reading.\n",
376  __FILE__, __LINE__, file->name);
377  return (1);
378  }
379 
380  status = getHDFattr(fileID, "Start Year", "", (VOIDP) & syear);
381  status = getHDFattr(fileID, "Start Day", "", (VOIDP) & sday);
382  status = getHDFattr(fileID, "Start Millisec", "", (VOIDP) & smsec);
383  status = getHDFattr(fileID, "End Year", "", (VOIDP) & eyear);
384  status = getHDFattr(fileID, "End Day", "", (VOIDP) & eday);
385  status = getHDFattr(fileID, "End Millisec", "", (VOIDP) & emsec);
386  status = getHDFattr(fileID, "Number of Scan Lines", "", (VOIDP) & nscan);
387  status = getHDFattr(fileID, "Data Type", "", (VOIDP) & dtype);
388 
389  status = getHDFattr(fileID, "Pixels per Scan Line", "", (VOIDP) & npix);
390  status = getHDFattr(fileID, "LAC Pixel Start Number", "", (VOIDP) & nsta);
391  status = getHDFattr(fileID, "LAC Pixel Subsampling", "", (VOIDP) & ninc);
392 
393  status = getHDFattr(fileID, "Orbit Node Longitude", "", (VOIDP) & file->orbit_node_lon);
394  status = getHDFattr(fileID, "Orbit Number", "", (VOIDP) & file->orbit_number);
395  status = getHDFattr(fileID, "Node Crossing Time", "", (VOIDP) & buf);
396  file->node_crossing_time = zulu2unix(buf);
397 
398 
399  Ltyp_frac = l1_input->sl_frac;
400  stray_light = l1_input->sl_pixl;
401 
402 
403  if (stray_light == 0)
404  do_st = 0;
405  else {
406  do_st = 1;
407  if (stray_light < 0) {
408  if (strcmp(dtype, "GAC") == 0)
409  stray_light = 4;
410  else
411  stray_light = 3;
412  }
413  }
414 
415 
416  /* get the current calibration model solution */
417  if (cal_path == NULL) {
418  fprintf(stderr,
419  "-E %s Line %d: No calibration file specified.\n",
420  __FILE__, __LINE__);
421  exit(1);
422  }
423 
424  read_caltable(cal_path);
425 
426  /*
427  status = get_cal(cal_path, syear, sday, eday, smsec, npix, nsta, ninc,
428  dtype, tdi, &entry_year, &entry_day, &ref_year,
429  &ref_day, &ref_minute, fp_temps, scan_mod, t_const,
430  t_linear_1, t_exponential_1, t_linear_2, t_exponential_2,
431  cal_offs, inst_tcorr, inst_tref, fp_tcorr, fp_tref,
432  ms1_const, ms1_linear_1, ms1_exponential_1, ms1_linear_2,
433  ms1_exponential_2, ms2_const, ms2_linear_1,
434  ms2_exponential_1, ms2_linear_2, ms2_exponential_2,
435  counts, rads);
436  */
437 
438  if (status < 0) {
439  fprintf(stderr,
440  "-E- %s line %d: Error applying calibration table \"%s\".\n",
441  __FILE__, __LINE__, cal_path);
442  exit(status);
443  }
444 
445 
446  /* call cdata.f to initialize global FORTRAN common block data */
447  cdata_();
448 
449 
450  file->npix = npix;
451  file->nscan = nscan;
452  file->sensorID = SEAWIFS;
453  file->sd_id = fileID;
454  if (strcmp(dtype, "GAC") == 0)
455  strcpy(file->spatialResolution, "4.5 km");
456  else
457  strcpy(file->spatialResolution, "1.1 km");
458 
459  strcpy(cal_path_tab, cal_path);
460 
461  l1a_data = (int16_t *) calloc(npix * 8 * NREC_IN_BUF, sizeof (int16_t));
462  l1a_back = (int16_t *) calloc(npix * 8 * (STBUFSIZ - 2), sizeof (int16_t));
463  l1b_buffer = (float *) calloc(npix * 8, sizeof (float));
464 
465  msec = (int32_t *) calloc(nscan, sizeof (int32_t));
466  status = rdSDS(file->sd_id, "msec", 0, 0, 0, 0, (VOIDP) msec);
467  side = (int16_t *) calloc(nscan, sizeof (int16_t));
468  status = rdSDS(file->sd_id, "side", 0, 0, 0, 0, (VOIDP) side);
469 
470  dark_rest = (int16_t *) calloc(nscan * 8, sizeof (int16_t));
471  status = rdSDS(file->sd_id, "dark_rest", 0, 0, 0, 0, (VOIDP) dark_rest);
473  free(dark_rest);
474 
475  tilt = (float *) calloc(nscan, sizeof (float));
476  status = rdSDS(file->sd_id, "tilt", 0, 0, 0, 0, (VOIDP) tilt);
477 
478  spix = nsta - 1;
479  dpix = ninc;
480 
481  return (status);
482 }
483 
484 int readl1a_seawifs(filehandle *file, int32_t recnum, l1str *l1rec) {
485 
486  /* */
487  /* get_l1a_rec interface */
488  /* */
489  static cal_mod_struc cal_mod; /* cal modification structure */
490  static int16_t *l2_flags; /* radiance quality flags for L2 */
491  static float *l1b_data;
492 
493  int32_t i;
494  int32_t status = 0;
495 
496  int32_t nwave = l1rec->l1file->nbands;
497  int32_t *bindx = (int32_t*) l1rec->l1file->bindx;
498 
499  /* */
500  /* local vars */
501  /* */
502  int32_t ipix; /* pixel number */
503  int32_t iw, ib;
504 
505  int16_t *l1a_dum = NULL;
506 
507  static int32_t prev_recnum = -1;
508 
509  static int16_t first = 1;
510  static int32_t ntilts;
511  static int16_t tilt_flags[20];
512  static int16_t tilt_ranges[2 * 20];
513 
514  int32_t nflag[8];
515 
516 
517  /* If reading out-of-sequence, force restart from beginning to get stlight */
518  /* baf, 05-oct-2001. */
519  if (recnum < prev_recnum) {
520  printf("Reading out-of-sequence %d %d\n", recnum, prev_recnum);
521  prev_recnum = -1;
522  }
523 
524 
525  /* Get tilt info */
526  /* ------------- */
527  if (first) {
528  status = rdSDS(file->sd_id, "ntilts", 0, 0, 0, 0, (VOIDP) & ntilts);
529  status = rdSDS(file->sd_id, "tilt_flags", 0, 0, 0, 0, (VOIDP) tilt_flags);
530  status = rdSDS(file->sd_id, "tilt_ranges", 0, 0, 0, 0, (VOIDP) tilt_ranges);
531  first = 0;
532  }
533 
534 
535  /* Check for bad or changing tilt */
536  /* ------------------------------ */
537  for (i = 0; i < ntilts; i++) {
538  if (tilt_ranges[2 * i] <= recnum + 1 && tilt_ranges[2 * i + 1] >= recnum)
539  break;
540  // if (tilt_flags[i] == 0 || /* nadir */
541  // tilt_flags[i] == 1 || /* fwd */
542  // tilt_flags[i] == 2 ) /* aft */
543  // bad_tilt = 0; /* tilt result is ok */
544  // else if (tilt_flags[i] == 3) /* tilt is changing */
545  // bad_tilt = 1;
546  // else /* tilt is unknown */
547  // bad_tilt = 2;
548  }
549 
550 
551  /* Get nav flag */
552  /* ------------ */
553  status = rdSDS(file->sd_id, "nflag", recnum, 0, 1, 8, (VOIDP) & nflag);
554 
555 
556  /* Get l1a data */
557  /* ------------ */
558  for (i = prev_recnum + 1; i <= recnum; i++)
559  status = get_l1a_rec(file->sd_id, i + 1, &cal_mod, l1a_dum,
560  &l1b_data, &l2_flags);
561 
562  /* */
563  /* Copy scan geolocation and view geometry */
564  /* */
565  memcpy(l1rec->lat, ylat, npix * sizeof (float));
566  memcpy(l1rec->lon, xlon, npix * sizeof (float));
567  memcpy(l1rec->solz, solz, npix * sizeof (float));
568  memcpy(l1rec->sola, sola, npix * sizeof (float));
569  memcpy(l1rec->senz, senz, npix * sizeof (float));
570  memcpy(l1rec->sena, sena, npix * sizeof (float));
571 
572  /* */
573  /* Copy L1B radiances, pixel interlaced by band. Add per-band */
574  /* view angles. */
575  /* */
576  for (ipix = 0; ipix < file->npix; ipix++) {
577  if (l1rec->sena[ipix] > 180) {
578  l1rec->sena[ipix] -= 360.0;
579  }
580  if (l1rec->sola[ipix] > 180) {
581  l1rec->sola[ipix] -= 360.0;
582  }
583  l1rec->pixnum[ipix] = spix + ipix*dpix;
584  for (iw = 0; iw < nwave; iw++) {
585  ib = bindx[iw];
586  l1rec->Lt [ipix * nwave + ib] = l1b_data[iw * npix + ipix];
587  }
588  l1rec->stlight[ipix] = ((l2_flags[ipix] & STRAYLIGHT) > 0);
589  l1rec->hilt [ipix] = ((l2_flags[ipix] & HILT) > 0);
590  l1rec->navwarn[ipix] = (nflag[7] & 1) | (nflag[0] & 1);
591  }
592 
593 
594  /* */
595  /* Set scan time in L1B output record */
596  /* */
597  double secs = (double) (msec[recnum] / 1.e3);
598  int16_t year = syear;
599  int16_t day = sday;
600 
601  if (msec[recnum] < smsec) { /* adjust for day rollover */
602  day += 1;
603  if (day > (365 + (year % 4 == 0))) {
604  year += 1;
605  day = 1;
606  }
607  }
608  l1rec->scantime = yds2unix(year, day, secs);
609 
610  l1rec->tilt = tilt[recnum];
611  l1rec->mside = side[recnum];
612 
613  prev_recnum = recnum;
614 
615  return (status);
616 }
617 
618 int readl1a_lonlat_seawifs(filehandle *file, int32_t recnum, l1str *l1rec) {
619  int32_t start[3];
620  int32_t edges[3];
621 
622  inputBuffer rdBuf;
623 
624  if (recnum > nscan) return 0;
625 
626  rdSDS(file->sd_id, "orb_vec", recnum, 0, 1, 3, (VOIDP) rdBuf.orb_vec);
627  rdSDS(file->sd_id, "sun_ref", recnum, 0, 1, 3, (VOIDP) rdBuf.sun_ref);
628  rdSDS(file->sd_id, "scan_ell", recnum, 0, 1, 6, (VOIDP) rdBuf.scan_ell);
629 
630  start[0] = recnum;
631  edges[0] = 1;
632  start[1] = 0;
633  edges[1] = 3;
634  start[2] = 0;
635  edges[2] = 3;
636  SDreaddata(SDselect(file->sd_id, SDnametoindex(file->sd_id, "sen_mat")),
637  start, NULL, edges, (VOIDP) rdBuf.sen_mat);
638 
639  geonav_lonlat_(rdBuf.orb_vec, rdBuf.sen_mat, rdBuf.scan_ell,
640  rdBuf.sun_ref, &nsta, &ninc, &npix,
641  l1rec->lat, l1rec->lon);
642 
643  return (0);
644 }
645 
646 int closel1a_seawifs(filehandle *file) {
647  free(l1a_data);
648  free(l1a_back);
649  free(l1b_buffer);
650  free(msec);
651  free(side);
652  free(tilt);
653 
654  SDend(file->sd_id);
655 
656  return (0);
657 }
658 
659 
660 
float rads[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
Definition: l1a_seawifs.c:47
const int bindx[3]
Definition: DbLutNetcdf.cpp:28
double fp_tcorr[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:57
float sola[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:95
float cal_rads[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
int j
Definition: decode_rs.h:73
float dark_mean[8]
Definition: l1a_seawifs.c:34
int rdSDS(int32_t fileID, const char sdsname[], int32_t start1, int32_t start2, int32_t edges1, int32_t edges2, void *array_data)
int32_t day
double t_const[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:49
int status
Definition: l1_czcs_hdf.c:32
double yds2unix(int16_t year, int16_t day, double secs)
Definition: yds2unix.c:7
double ms2_const[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:64
void geonav_lonlat_(float *orb_vec, float *sen_mat, float *scan_ell, float *sun_ref, int32_t *nsta, int32_t *ninc, int32_t *npix, float ylat[], float xlon[])
int16 * gain
Definition: l1_czcs_hdf.c:33
int32_t ninc
Definition: l1a_seawifs.c:82
int16_t * l1a_back
Definition: l1a_seawifs.c:85
#define GENBUFSIZ
Definition: l1a_seawifs.c:22
int16_t fileID
#define GAINS_DIMS_1A
char cal_path_tab[128]
Definition: l1a_seawifs.c:70
#define FALSE
Definition: rice.h:164
void read_caltable(char *cal_path)
Definition: get_cal_swf.c:153
#define NULL
Definition: decode_rs.h:63
int16_t entry_year
Definition: l1a_seawifs.c:39
#define MASK_HIGHLT1
Definition: l1a_seawifs.c:21
read l1rec
#define STRAYLIGHT
Definition: l2_flags.h:19
int geonav_(FLOAT32 pos[3], FLOAT32 rm[3][3], FLOAT32 coef[6], FLOAT32 sunref[3], INT32 *spix, INT32 *ipix, INT32 *npix, FLOAT32 lat[], FLOAT32 lon[], FLOAT32 solz[], FLOAT32 sola[], FLOAT32 senz[], FLOAT32 sena[])
int32_t do_st
Definition: l1a_seawifs.c:116
int16_t * l1a_data
Definition: l1a_seawifs.c:84
float pcal_rads[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
Definition: l1a_seawifs.c:78
int16_t * dark_rest
Definition: l1a_seawifs.c:89
float ylat[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:92
float pcal_counts[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
Definition: l1a_seawifs.c:77
double fp_tref[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:58
#define NOTDONE
Definition: l1a_seawifs.c:19
int32_t get_l1a_rec(int32_t sd_id, int32_t recno, cal_mod_struc *cal_mod, int16_t *l1a_dum, float **l1b_data, int16_t **l2_flags)
Definition: l1a_seawifs.c:118
short l2_flags_buffer[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:79
double ms2_linear_2[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:67
int openl1a_seawifs(filehandle *file)
Definition: l1a_seawifs.c:350
double t_linear_1[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:50
int16_t stray_light
Definition: l1a_seawifs.c:100
int32_t * msec
Definition: l1a_seawifs.c:87
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed file
Definition: HISTORY.txt:413
#define NREC_IN_BUF
Definition: l1a_seawifs.c:17
int readl1a_seawifs(filehandle *file, int32_t recnum, l1str *l1rec)
Definition: l1a_seawifs.c:484
character(len=1000) if
Definition: names.f90:13
int16_t entry_day
Definition: l1a_seawifs.c:40
int16_t out_band
Definition: l1a_seawifs.c:102
double t_exponential_1[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:51
double cal_offs[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:54
float Ltyp_frac
Definition: l1a_seawifs.c:101
double t_linear_2[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:52
read recnum
double zulu2unix(char *zulu)
Definition: zulu2unix.c:3
#define BANDS_DIMS_1A
Definition: level_1a_index.h:8
float sena[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:97
float sen_mat[3 *3]
Definition: l1a_seawifs.c:111
double ms2_exponential_2[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:68
int32_t npix
Definition: l1a_seawifs.c:31
int32_t nsta
Definition: l1a_seawifs.c:81
void cdata_()
double inst_tcorr[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:55
l1_input_t * l1_input
Definition: l1_options.c:9
float solz[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:94
int getHDFattr(int32_t fileID, const char attrname[], const char sdsname[], void *data)
int16_t tdi[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:37
short gain8
Definition: l1a.c:197
integer, parameter double
int16_t eday
Definition: l1a_seawifs.c:28
float dark_std[8]
Definition: l1a_seawifs.c:35
int16_t eyear
Definition: l1a_seawifs.c:28
int32_t spix
Definition: l1a_seawifs.c:32
int readl1a_lonlat_seawifs(filehandle *file, int32_t recnum, l1str *l1rec)
Definition: l1a_seawifs.c:618
int16_t ref_day
Definition: l1a_seawifs.c:42
float fp_temps[256][BANDS_DIMS_1A]
Definition: l1a_seawifs.c:44
#define HILT
Definition: l2_flags.h:15
int32_t emsec
Definition: l1a_seawifs.c:29
double inst_tref[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:56
float xlon[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:93
int32_t smsec
Definition: l1a_seawifs.c:27
int16_t sday
Definition: l1a_seawifs.c:26
int closel1a_seawifs(filehandle *file)
Definition: l1a_seawifs.c:646
double ms1_linear_1[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:60
float * l1b_buffer
Definition: l1a_seawifs.c:86
double ms1_const[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:59
float orb_vec[3]
Definition: l1a_seawifs.c:109
int32_t l1b_rad(int syear, int sday, int32_t smsec, int32_t msec, char *dtype, int32_t nsta, int32_t ninc, int32_t npix, float *dark_mean, short *gain, short *tdi, short *scan_temp, float *inst_temp, int mside, short *l1a_data, float *l1b_data, cal_mod_struc *cal_mod)
Definition: get_cal_swf.c:701
int16_t gain[8]
Definition: l1a_seawifs.c:105
int dark_rest_stat(int16 *data, int nrec, float *dark_mean, float *dark_std)
Definition: l1a.c:261
dtype
Definition: DDataset.hpp:31
int16_t * side
Definition: l1a_seawifs.c:88
float * tilt
Definition: l1a_seawifs.c:90
double ms2_linear_1[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:65
double ms2_exponential_1[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:66
int scan_ell(float p[3], double sm[3][3], double coef[10])
float senz[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:96
int16_t ref_year
Definition: l1a_seawifs.c:41
float scan_mod[2][1285]
Definition: l1a_seawifs.c:45
double ms1_exponential_2[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:63
float scan_ell[6]
Definition: l1a_seawifs.c:112
int32_t stray_light_corr(int32_t *initial, float Ltyp_frac, float Styp_frac, int32_t nscans, int32_t nsamples, int32_t scan_no, char *dtype, int16_t gn, float *rads, float *l1b_data, int32_t *sl_scan, int16_t *l2_flags, int32_t *AS_pixels)
Definition: st_lt.c:65
#define LAC_PIXEL_NUM
Definition: l1a_seawifs.c:15
float counts[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
Definition: l1a_seawifs.c:46
l2prod offset
int16_t syear
Definition: l1a_seawifs.c:26
#define KNEES_DIMS_1A
#define SEAWIFS
Definition: sensorDefs.h:12
int i
Definition: decode_rs.h:71
double ms1_linear_2[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:62
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
double t_exponential_2[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:53
float sun_ref[3]
Definition: l1a_seawifs.c:110
float cal_counts[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
#define FIRST_KNEE
Definition: l1a_seawifs.c:20
int32_t nscan
Definition: l1a_seawifs.c:30
int16_t ref_minute
Definition: l1a_seawifs.c:43
#define STBUFSIZ
Definition: l1a_seawifs.c:18
double ms1_exponential_1[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:61
int32_t dpix
Definition: l1a_seawifs.c:33