OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
main_l1brsgen.c
Go to the documentation of this file.
1 /* ========================================================================
2  * MSl1b2browse - converts any L1B file to a ppm file or browse format
3  *
4  * Synopsis:
5  *
6  * MSl1b2browse input-l1b-filename output-ppm-filename
7  *
8  * Description:
9  *
10  * Modification history:
11  *
12  * Programmer Organization Date Description of change
13  * -------------- ------------ -------- ---------------------
14  * Bryan A. Franz GSC Jul 1998 Original development
15  * Joel Gales Futuretech Jan 2001 Added 8 and 24-bit hdf
16  * Norman Kuring NASA/GSFC Feb 2005 New scaling for true color
17  * Sean Bailey Futuretech Nov 2007 Made scaling consistent with
18  * l1mapgen, use a sensor
19  * dependent defaults, and
20  * generally clean up the code
21  * Joel Gales Futuretech Oct 2012 Define fftype to make
22  * compatible with new HDF/NCDF
23  * libhdfutils
24  *
25  * ======================================================================== */
26 
27 #include "l12_proto.h"
28 #include "input_struc.h"
29 #include <libnav.h>
30 
31 #include <png.h>
32 #include <imageutils.h>
33 #include <scene_meta.h>
34 
35 #define INT32 int32_t
36 #define FLOAT32 float
37 #define BYTE unsigned char
38 
39 #define HDF8 0
40 #define HDF24 1
41 #define PPM 2
42 #define FLATBINARY 3
43 #define PNG 4
44 
45 #define MALLOC(ptr,typ,num) { \
46  (ptr) = (typ *)malloc((num) * sizeof(typ)); \
47  if((ptr) == NULL){ \
48  fprintf(stderr,"-E- %s line %d: Memory allocation failure.\n", \
49  __FILE__,__LINE__); \
50  exit(EXIT_FAILURE); \
51  } \
52 }
53 
54 BYTE logscale(float val, float min, float max);
55 BYTE linscale(float val, float min, float max);
56 float toa_reflect(l1str * l1rec, int32_t ip, int32_t ib);
57 
58 void dfr8_addimage(char *fname,
59  unsigned char *raster,
60  int32_t width,
61  int32_t height, unsigned char *palette, char *label) {
62  uint16 ref;
63 
64  if (DFR8setpalette(palette) == FAIL) {
65  fprintf(stderr,
66  "-E- %s line %d: DFR8setpalette() failed for file, %s.\n",
67  __FILE__, __LINE__, fname);
68  exit(EXIT_FAILURE);
69  }
70  if (DFR8addimage(fname, raster, width, height, COMP_NONE) == FAIL) {
71  fprintf(stderr,
72  "-E- %s line %d: DFR8addimage() failed for file, %s.\n",
73  __FILE__, __LINE__, fname);
74  exit(EXIT_FAILURE);
75  }
76  ref = DFR8lastref();
77  if (ref == 0) {
78  fprintf(stderr,
79  "-E- %s line %d: DFR8lastref() failed for file, %s.\n",
80  __FILE__, __LINE__, fname);
81  exit(EXIT_FAILURE);
82  }
83  if (DFANputlabel(fname, DFTAG_RIG, ref, "brs_data")) {
84  fprintf(stderr,
85  "-E- %s line %d: DFANputlabel() failed for file, %s.\n",
86  __FILE__, __LINE__, fname);
87  exit(EXIT_FAILURE);
88  }
89 }
90 
91 /* -------------------------------------------------------------------- *
92  * main *
93  * -------------------------------------------------------------------- */
94 int main(int argc, char *argv[]) {
95 
96  int32_t iscan = 0; /* input scan number */
97  int32_t spix = 0; /* start pixel for subscene process */
98  int32_t epix = -1; /* end pixel for subscene process */
99  int32_t dpix = 1; /* pixel increment for sub-sampling */
100  int32_t sscan = 0; /* start scan for subscene process */
101  int32_t escan = -1; /* end scan for subscene process */
102  int32_t dscan = 1; /* scan subsampling increment */
103  int32_t ip; /* input pixel number */
104  int32_t iw; /* wavelength number */
105  int32_t sfactor = 10;
106  double esdist;
107 
108  float rhoc = 0.0; /* cirrus reflectance */
109  float twc = 0.8; /* water vapor transmittance above cirrus */
110 
111  int32_t npix = 0; /* Number of output pixels per scan */
112  int32_t nscan = 0; /* Number of output scans */
113 
114  BYTE rgb[3];
115  int32_t r, g, b;
116  int want_bin = 0;
117  int want_ppm = 0;
118  int want_hdf = 0;
119  int want_8bit = 0;
120  int want_24bit = 0;
121  int want_atmocor = 0;
122  int want_linscale = 0;
123  int want_png = 0;
124 
125  float sr_r, sr_g, sr_b;
126  float min = 0.01;
127  float max = 0.9;
128 
129  l1str l1rec; /* generic level-1b scan structure */
130  filehandle l1file; /* input file handle */
131  FILE *outfp = NULL;
132  int32_t hdr[5];
133  int32_t length;
134 
135  char outfile[FILENAME_MAX] = "";
136 
137  int32_t dims[8];
138  int32_t rank;
139  // int32_t HDFfid_w;
140  int32_t sd_id_w;
141  int32_t sds_id_rgb;
142  int32_t sds_id_lon;
143  int32_t sds_id_lat;
144  int32_t start_w[3] = {0, 0, 0};
145  int32_t count_w[3] = {1, 1, 3};
146  float32 f32;
147  char strbuf[80];
148 
149  img_rgb_t* img = NULL;
150  uint8_t* pix = NULL;
151 
152  unsigned char palette[768];
153  unsigned char *raster;
154  int32_t numoutpix;
155  int32_t nbands;
156 
157  int i;
158  int16_t year, day;
159  double dmsec;
160 
161  int16 *lonBuffer = NULL;
162  int16 *latBuffer = NULL;
163  BYTE *lineBuffer = NULL;
164 
165  png_structp png_ptr = NULL;
166  png_infop info_ptr = NULL;
167 
168 
169  /* hold all of the command line options */
171 
172  if (argc == 1) {
173  l2gen_usage("l1brsgen");
174  return 0;
175  }
176 
177  // see if help on command line
178  for (i = 0; i < argc; i++) {
179  if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-help") == 0)) {
180  l2gen_usage("l1brsgen");
181  return 1;
182  }
183  }
184 
185  cdata_();
188 
189  // create an option list
190  list = clo_createList();
191 
192  /* initialize the option list with descriptions and default values */
193  l2gen_init_options(list, "l1brsgen");
194 
195  // change the default values for this program
196  clo_setString(list, "atmocor", "off", "default");
197  clo_setString(list, "proc_land", "1", "default");
198  clo_setString(list, "sl_pixl", "0", "default");
199 
200  // Parse input parameters
201  if (msl12_option_input(argc, argv, list, "l1brsgen", &l1file) != 0) {
202  printf("-E- %s: Error parsing input parameters.\n", argv[0]);
203  exit(FATAL_ERROR);
204  }
205  strcpy(outfile, input->ofile[0]);
206 
207  want_linscale = input->stype;
208  if (input->atmocor == 1)
209  want_atmocor = 1;
210 
211 
212  /* */
213  /* Open input file and get sensor and scan information from handle */
214  /* */
215  if (openl1(&l1file) != 0) {
216  printf("-E- %s: Error opening %s for reading.\n", argv[0],
217  l1file.name);
218  exit(1);
219  }
220 
221  r = bindex_get(input->rgb[0]);
222  g = bindex_get(input->rgb[1]);
223  b = bindex_get(input->rgb[2]);
224  if (r < 0 || g < 0 || b < 0) {
225  printf("-E- Invalid RGB set for this sensor\n");
226  if (r < 0)
227  printf(" Invalid R: %d\n", input->rgb[0]);
228  if (g < 0)
229  printf(" Invalid G: %d\n", input->rgb[1]);
230  if (b < 0)
231  printf(" Invalid B: %d\n", input->rgb[2]);
232  exit(FATAL_ERROR);
233  }
234 
235  min = input->datamin;
236  max = input->datamax;
237 
238 
239  /* */
240  /* Allocate memory for L1 scan data */
241  /* */
242  nbands = l1file.nbands;
243  if (alloc_l1(&l1file, &l1rec) == 0) {
244  printf("-E- %s: Unable to allocate L1 record.\n", argv[0]);
245  exit(FATAL_ERROR);
246  }
247 
248  /* Set the end pixel if it was not set by command argument */
249  if (l1_input->epixl < 1 || l1_input->epixl > l1file.npix)
250  l1_input->epixl = l1file.npix;
251  if (l1_input->eline < 1 || l1_input->eline > l1file.nscan)
252  l1_input->eline = l1file.nscan;
253  if (l1_input->spixl < 1)
254  l1_input->spixl = 1;
255  if (l1_input->sline < 1)
256  l1_input->sline = 1;
257  sfactor = MAX(input->subsamp, 1);
258  spix = MAX(l1_input->spixl - 1, 0);
259  epix = MIN(l1_input->epixl - 1, l1file.npix - 1);
260  sscan = MAX(l1_input->sline - 1, 0);
261  escan = MIN(l1_input->eline - 1, l1file.nscan - 1);
262  dpix = sfactor;
263  dscan = sfactor;
264 
265  npix = (epix - spix) / sfactor + 1;
266  nscan = (escan - sscan) / sfactor + 1;
267 
268  l1file.spix = spix;
269  l1file.epix = epix;
270 
271  l1_input->sline = sscan + 1;
272  l1_input->eline = escan + 1;
273  l1_input->dline = dscan;
274  l1_input->spixl = spix + 1;
275  l1_input->epixl = epix + 1;
276  l1_input->dpixl = dpix;
277 
278  printf("Using r,g,b = %d, %d, %d\n", input->rgb[0], input->rgb[1],
279  input->rgb[2]);
280 
281  if (strcmp(input->oformat, "HDF4") == 0) {
282  if (strcmp(input->oformat_depth, "8bit") == 0)
283  want_8bit = 1;
284  else
285  want_24bit = 1;
286  } else if (strcmp(input->oformat, "BIN") == 0)
287  want_bin = 1;
288  else if (strcmp(input->oformat, "PNG") == 0)
289  want_png = 1;
290  else if (strcmp(input->oformat, "PPM") == 0)
291  want_ppm = 1;
292 
293  if (want_ppm + want_24bit + want_8bit + want_bin + want_png > 1) {
294  printf("%s: Error: More than one output format has been chosen.\n", argv[0]);
295  exit(1);
296  }
297  if (want_ppm + want_24bit + want_8bit + want_bin + want_png < 1) {
298  want_8bit = 1;
299  }
300  if (want_8bit || want_24bit) {
301  want_hdf = 1;
302  }
303 
304  if (want_ppm) {
305 
306  if ((outfp = fopen(outfile, "w")) == NULL) {
307  printf("%s: Error: Unable to open %s for writing.\n",
308  argv[0], outfile);
309  exit(FATAL_ERROR);
310  }
311  /* Write output ppm file */
312  fprintf(outfp, "P6\n");
313  fprintf(outfp, "%d\n", npix);
314  fprintf(outfp, "%d\n", nscan);
315  fprintf(outfp, "255\n");
316 
317  } else if (want_hdf) {
318 
319  // HDFfid_w = Hopen (outfile, DFACC_CREATE, 0);
320  // status = Vstart (HDFfid_w);
321  // sd_id_w = SDstart (outfile, DFACC_RDWR);
322  sd_id_w = SDstart(outfile, DFACC_CREATE);
323 
324  rank = 2;
325  dims[0] = nscan;
326  dims[1] = npix;
327  sds_id_lon = SDcreate(sd_id_w, "longitude", DFNT_INT16, rank, dims);
328 
329  SDsetdimname(SDgetdimid(sds_id_lon, 0), "Number of Scans");
330  SDsetdimname(SDgetdimid(sds_id_lon, 1), "Pixels per Scan");
331 
332  f32 = 1. / 180;
333  SDsetattr(sds_id_lon, "slope", DFNT_FLOAT32, 1, &f32);
334  f32 = 0.0;
335  SDsetattr(sds_id_lon, "intercept", DFNT_FLOAT32, 1, &f32);
336 
337  rank = 2;
338  dims[0] = nscan;
339  dims[1] = npix;
340  sds_id_lat = SDcreate(sd_id_w, "latitude", DFNT_INT16, rank, dims);
341 
342  SDsetdimname(SDgetdimid(sds_id_lat, 0), "Number of Scans");
343  SDsetdimname(SDgetdimid(sds_id_lat, 1), "Pixels per Scan");
344 
345  f32 = 1. / 360;
346  SDsetattr(sds_id_lat, "slope", DFNT_FLOAT32, 1, &f32);
347  f32 = 0.0;
348  SDsetattr(sds_id_lat, "intercept", DFNT_FLOAT32, 1, &f32);
349 
350  lonBuffer = (int16*) malloc(npix * 2);
351  latBuffer = (int16*) malloc(npix * 2);
352 
353  count_w[1] = npix;
354 
355  if (want_24bit) {
356  rank = 3;
357  dims[0] = nscan;
358  dims[1] = npix;
359  dims[2] = 3;
360  sds_id_rgb = SDcreate(sd_id_w, "rgb", DFNT_UINT8, rank, dims);
361 
362  SDsetdimname(SDgetdimid(sds_id_rgb, 0), "Number of Scans");
363  SDsetdimname(SDgetdimid(sds_id_rgb, 1), "Pixels per Scan");
364  SDsetdimname(SDgetdimid(sds_id_rgb, 2), "Number of Colors");
365 
366  lineBuffer = (unsigned char*) malloc(npix * 3);
367  }
368 
369 
370  if (want_8bit) {
371  /* Initialize an Image structure to be used in color quantization. */
372  img = img_new(npix, nscan);
373  pix = img->pix;
374  }
375 
376  } else if (want_bin) {
377 
378  if ((outfp = fopen(outfile, "w")) == NULL) {
379  printf("%s: Error: Unable to open %s for writing.\n",
380  argv[0], outfile);
381  exit(FATAL_ERROR);
382  }
383 
384  /* Write file header */
385  length = 12 + npix * 2 * 4 + npix * 3;
386  hdr[0] = length;
387  hdr[1] = npix;
388  hdr[2] = nscan;
389  hdr[3] = l1file.sensorID;
390 
391  fwrite(hdr, sizeof (hdr), 1, outfp);
392  fseek(outfp, length, SEEK_SET);
393 
394  } else if (want_png) {
395 
396  if ((outfp = fopen(outfile, "w")) == NULL) {
397  printf("%s: Error: Unable to open %s for writing.\n",
398  argv[0], outfile);
399  exit(FATAL_ERROR);
400  }
401 
402  png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
403  NULL, NULL, NULL);
404  if (!png_ptr) {
405  fprintf(stderr, "%s: Error: Unable to create PNG write structure.\n", argv[0]);
406  exit(1);
407  }
408 
409  info_ptr = png_create_info_struct(png_ptr);
410  if (!info_ptr) {
411  png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
412  fprintf(stderr, "%s: Error: Unable to create PNG info structure.\n", argv[0]);
413  exit(1);
414  }
415  if (setjmp(png_jmpbuf(png_ptr))) {
416  png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
417  fprintf(stderr, "%s: Error: Unable to call PNG setjmp().\n", argv[0]);
418  exit(1);
419  }
420  png_init_io(png_ptr, outfp);
421  png_set_IHDR(png_ptr, info_ptr, npix, nscan,
422  8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
423  PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
424  png_write_info(png_ptr, info_ptr);
425 
426  lineBuffer = (unsigned char*) malloc(npix * 3);
427  if (!lineBuffer) {
428  png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
429  fprintf(stderr, "%s: Error: Unable to allocate line buffer.\n", argv[0]);
430  exit(1);
431  }
432 
433 
434 
435  } else {
436  printf("%s: Error: No output format specified.\n", argv[0]);
437  exit(FATAL_ERROR);
438 
439  }
440 
441  /* */
442  /* Read file scan by scan, scale radiances, and write. */
443  /* */
444  for (iscan = sscan; iscan <= escan; iscan += dscan) {
445 
446  if (readl1(&l1file, iscan, &l1rec) != 0) {
447  fprintf(stderr,
448  "-E- %s Line %d: error reading %s at scan %d.\n",
449  __FILE__, __LINE__, l1file.name, iscan);
450  exit(FATAL_ERROR);
451  }
452 
453 
454  unix2yds(l1rec.scantime, &year, &day, &dmsec);
455  int32_t msec = (int32_t) (dmsec * 1.e3);
456  if (want_bin) {
457  fwrite(&year, 4, 1, outfp);
458  fwrite(&day, 4, 1, outfp);
459  fwrite(&msec, 4, 1, outfp);
460 
461  for (ip = 0; ip < npix; ip++) {
462  fwrite(&l1rec.lon[ip], 4, 1, outfp);
463  }
464  for (ip = 0; ip < npix; ip++) {
465  fwrite(&l1rec.lat[ip], 4, 1, outfp);
466  }
467 
468  } else if (want_hdf) {
469  start_w[0] = (iscan - sscan) / sfactor;
470  for (ip = 0; ip < npix; ip++) {
471  if (l1rec.lon[ip] >= 0)
472  lonBuffer[ip] = (int16) ((l1rec.lon[ip] * 180) + 0.5);
473  if (l1rec.lon[ip] < 0)
474  lonBuffer[ip] = (int16) ((l1rec.lon[ip] * 180) - 0.5);
475 
476  if (l1rec.lat[ip] >= 0)
477  latBuffer[ip] = (int16) ((l1rec.lat[ip] * 360) + 0.5);
478  if (l1rec.lat[ip] < 0)
479  latBuffer[ip] = (int16) ((l1rec.lat[ip] * 360) - 0.5);
480  }
481 
482  SDwritedata(sds_id_lon, start_w, NULL, count_w,
483  (VOIDP) lonBuffer);
484 
485  SDwritedata(sds_id_lat, start_w, NULL, count_w,
486  (VOIDP) latBuffer);
487 
488  }
489 
490  if (want_atmocor) {
491  if (loadl1(&l1file, &l1rec) != 0) {
492  fprintf(stderr,
493  "-E- %s Line %d: error loading %s at scan %d.\n",
494  __FILE__, __LINE__, l1file.name, iscan);
495  exit(FATAL_ERROR);
496  }
497  } else {
498  /* Get correction for Earth-Sun distance and apply to Fo */
499  int32_t yr = (int32_t) year;
500  int32_t dy = (int32_t) day;
501 
502  esdist = esdist_(&yr, &dy, &msec);
503  l1rec.fsol = pow(1.0 / esdist, 2);
504  for (iw = 0; iw < nbands; iw++) {
505  l1rec.Fo[iw] = l1file.Fobar[iw] * l1rec.fsol;
506  }
507  }
508 
509  for (ip = 0; ip < npix; ip++) {
510  if ((l1rec.Lt[ip * nbands + r] > 0.01) &&
511  (l1rec.Lt[ip * nbands + g] > 0.01) &&
512  (l1rec.Lt[ip * nbands + b] > 0.01)) {
513  if (want_atmocor) {
514  if (input->cirrus_opt)
515  rhoc = l1rec.rho_cirrus[ip] / twc;
516  else
517  rhoc = 0.0;
518 
519  sr_r = l1rec.rhos[ip * nbands + r] - rhoc;
520  sr_g = l1rec.rhos[ip * nbands + g] - rhoc;
521  sr_b = l1rec.rhos[ip * nbands + b] - rhoc;
522 
523  } else {
524  sr_r = toa_reflect(&l1rec, ip, r);
525  sr_g = toa_reflect(&l1rec, ip, g);
526  sr_b = toa_reflect(&l1rec, ip, b);
527  }
528  if (want_linscale == 1) {
529  rgb[0] = linscale(sr_r, min, max);
530  rgb[1] = linscale(sr_g, min, max);
531  rgb[2] = linscale(sr_b, min, max);
532  } else {
533  rgb[0] = logscale(sr_r, min, max);
534  rgb[1] = logscale(sr_g, min, max);
535  rgb[2] = logscale(sr_b, min, max);
536  }
537  } else {
538  rgb[0] = rgb[1] = rgb[2] = 255;
539  }
540  if (l1file.sensorID == OCTS && rgb[2] > 234) {
541  if (rgb[0] < 230)
542  rgb[0] = 250;
543  if (rgb[1] < 230)
544  rgb[1] = 251;
545  rgb[2] = 252;
546  }
547 
548 
549  if (want_bin || want_ppm) {
550  fwrite(rgb, 1, 3, outfp);
551  } else if (want_hdf) {
552 
553  if (want_24bit) {
554  i = ip * 3;
555  lineBuffer[i++] = rgb[0];
556  lineBuffer[i++] = rgb[1];
557  lineBuffer[i] = rgb[2];
558  } else if (want_8bit) {
559  *pix++ = rgb[0];
560  *pix++ = rgb[1];
561  *pix++ = rgb[2];
562  }
563 
564  } else if (want_png) {
565  i = ip * 3;
566  lineBuffer[i++] = rgb[0];
567  lineBuffer[i++] = rgb[1];
568  lineBuffer[i] = rgb[2];
569  }
570 
571  } // for ip
572 
573  if (want_24bit) {
574  SDwritedata(sds_id_rgb, start_w, NULL, count_w,
575  (VOIDP) lineBuffer);
576 
577  } else if (want_png) {
578  png_write_row(png_ptr, lineBuffer);
579 
580  }
581 
582  } // for iscan
583 
584 
585  /* Write Global Attributes */
586 
587  if (want_hdf) {
588  idDS ds_id;
589  ds_id.deflate = 0;
590  ds_id.fid = sd_id_w;
591  ds_id.fftype = DS_HDF;
592  SetChrGA(ds_id, "Product Name", outfile);
593 
594  sprintf(strbuf, "%s Level-1 Browse Data",
595  sensorId2SensorName(l1file.sensorID));
596  SetChrGA(ds_id, "Title", strbuf);
597 
598  /*
599  sprintf (strbuf,
600  "NASA/GSFC %s Level-1 %s quasi-true-color browse data, day %d, %d",
601  sensorName[l1file.sensorID], strbuf2, *l1rec.day,
602  *l1rec.year);
603  */
604  sprintf(strbuf,
605  "NASA/GSFC %s Level-1 quasi-true-color browse data, day %d, %d",
606  sensorId2SensorName(l1file.sensorID), day, year);
607  SetChrGA(ds_id, "Legend", strbuf);
608 
609  SetChrGA(ds_id, "Processing Time", ydhmsf(now(), 'G'));
610  SDsetattr(sd_id_w, "Number of Scan Lines", DFNT_INT32, 1,
611  (VOIDP) & nscan);
612  SDsetattr(sd_id_w, "Pixels per Scan Line", DFNT_INT32, 1,
613  (VOIDP) & npix);
614 
615  scene_meta_write(ds_id);
616  }
617 
618  closel1(&l1file);
619 
620  if (want_bin || want_ppm) {
621  fclose(outfp);
622  } else if (want_hdf) {
623 
624  if (want_24bit)
625  SDendaccess(sds_id_rgb);
626 
627  if (want_8bit) {
628  numoutpix = nscan * npix;
629  MALLOC(raster, unsigned char, numoutpix);
630 
631  img_color_palette_quantization(img, 256, palette, raster);
632 
633  /* I don't need the Image structures anymore. */
634  img_free(img);
635  img = NULL;
636 
637  /* Write the image and its palette to the output file. */
638  dfr8_addimage(outfile, raster, npix, nscan, palette, "brs_data");
639  free(raster);
640 
641  }
642 
643  SDendaccess(sds_id_lon);
644  SDendaccess(sds_id_lat);
645  SDend(sd_id_w);
646  // Hclose (HDFfid_w);
647  // Vend (HDFfid_w);
648  } else if (want_png) {
649  png_write_end(png_ptr, info_ptr);
650  png_destroy_write_struct(&png_ptr, &info_ptr);
651 
652 
653  fclose(outfp);
654  }
655 
656  exit(0);
657 }
char * ydhmsf(double dtime, char zone)
Definition: ydhmsf.c:12
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
Definition: l1stat_chk.c:586
#define MAX(A, B)
Definition: swl0_utils.h:26
integer, parameter int16
Definition: cubeio.f90:3
#define MIN(x, y)
Definition: rice.h:169
int r
Definition: decode_rs.h:73
int readl1(filehandle *l1file, int32_t recnum, l1str *l1rec)
Definition: l1_io.c:400
int32_t day
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
Definition: CMakeLists.txt:7
int l2gen_init_options(clo_optionList_t *list, const char *prog)
Definition: msl12_input.c:667
These are used to scale the SD before writing it to the HDF4 file The default is and which means the product is not scaled at all Since the product is usually stored as a float inside of this is a way to write the float out as a integer l2prod min
#define FAIL
Definition: ObpgReadGrid.h:18
#define NULL
Definition: decode_rs.h:63
void filehandle_init(filehandle *file)
img_rgb_t * img_new(int w, int h)
Definition: color_quant.c:40
read l1rec
int msl12_option_input(int argc, char *argv[], clo_optionList_t *list, char *progName, filehandle *l1file)
int32_t deflate
Definition: dfutils.h:32
int32 * msec
Definition: l1_czcs_hdf.c:31
double esdist_(int32_t *year, int32_t *day, int32_t *msec)
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT32
void msl12_input_init()
Definition: msl12_input.c:485
void img_free(img_rgb_t *img)
Definition: color_quant.c:48
BYTE logscale(float val, float min, float max)
Definition: l1_imgscale.c:76
int clo_setString(clo_optionList_t *list, const char *key, const char *val, const char *source)
Definition: clo.c:1667
int32 nscan
Definition: l1_czcs_hdf.c:19
ds_format_t fftype
Definition: dfutils.h:31
#define MALLOC(ptr, typ, num)
Definition: main_l1brsgen.c:45
int l2gen_usage(const char *prog)
Definition: msl12_input.c:4254
instr * input
unsigned char BYTE
Definition: elements.h:4
int bindex_get(int32_t wave)
Definition: windex.c:45
void scene_meta_write(idDS ds_id)
Definition: scene_meta.c:241
clo_optionList_t * clo_createList()
Definition: clo.c:532
BYTE linscale(float val, float min, float max)
Definition: l1_imgscale.c:25
void cdata_()
l1_input_t * l1_input
Definition: l1_options.c:9
#define FATAL_ERROR
Definition: swl0_parms.h:5
void unix2yds(double usec, short *year, short *day, double *secs)
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT16
void closel1(filehandle *l1file)
Definition: l1_io.c:68
data_t b[NROOTS+1]
Definition: decode_rs.h:77
#define OCTS
Definition: sensorDefs.h:14
int32 dpix
Definition: l1_czcs_hdf.c:22
int32_t nbands
const char * sensorId2SensorName(int sensorId)
Definition: sensorInfo.c:198
int SetChrGA(idDS ds_id, const char *name, const char *value)
Definition: wrapper.c:236
int32 spix
Definition: l1_czcs_hdf.c:21
int32_t iscan
int32_t fid
Definition: dfutils.h:29
u5 which has been done in the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT production Changes from v6 which may affect scientific the sector rotation may actually occur during one of the scans earlier than the one where it is first reported As a the b1 values are about the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT to fill pixels affected by dead subframes with a special value Output the metadata of noisy and dead subframe Dead Subframe EV and Detector Quality Flag2 Removed the function call of Fill_Dead_Detector_SI to stop interpolating SI values for dead but also for all downstream products for science test only Changes from v5 which will affect scientific to conform to MODIS requirements Removed the Mixed option from the ScanType in the code because the L1A Scan Type is never Mixed Changed for ANSI C compliance and comments to better document the fact that when the HDF_EOS metadata is stricly the and products are off by and in the track respectively Corrected some misspelling of RCS swir_oob_sending_detector to the Reflective LUTs to enable the SWIR OOB correction detector so that if any of the sending detectors becomes noisy or non near by good detectors from the same sending band can be specified as the substitute in the new look up table Code change for adding an additional dimension of mirror side to the Band_21_b1 LUT to separate the coefficient of the two mirror sides for just like other thermal emissive so that the L1B code can calibrate Band scan to scan with mirror side dependency which leads better calibration result Changes which do not affect scientific when the EV data are not provided in this Crosstalk Correction will not be performed to the Band calibration data Changes which do not affect scientific and BB_500m in L1A Logic was added to turn off the or to spatial aggregation processes and the EV_250m_Aggr1km_RefSB and EV_500m_Aggr1km_RefSB fields were set to fill values when SDSs EV_250m and EV_500m are absent in L1A file Logic was added to skip the processing and turn off the output of the L1B QKM and HKM EV data when EV_250m and EV_500m are absent from L1A In this the new process avoids accessing and reading the and L1A EV skips and writing to the L1B and EV omits reading and subsampling SDSs from geolocation file and writing them to the L1B and omits writing metadata to L1B and EV and skips closing the L1A and L1B EV and SDSs Logic was added to turn off the L1B OBC output when the high resolution OBC SDSs are absent from L1A This is accomplished by skipping the openning the writing of metadata and the closing of the L1B OBC hdf which is Bit in the scan by scan bit QA has been changed Until now
Definition: HISTORY.txt:361
Extra metadata that will be written to the HDF4 file l2prod rank
float toa_reflect(l1str *l1rec, int32_t ip, int32_t ib)
Definition: l1_imgscale.c:8
@ DS_HDF
Definition: dfutils.h:19
Definition: dfutils.h:28
int32 epix
Definition: l1_czcs_hdf.c:23
real *8 function esdist(iyr, iday, msec)
Definition: esdist.f:3
int32_t alloc_l1(filehandle *l1file, l1str *l1rec)
Definition: alloc_l1.c:15
void dfr8_addimage(char *fname, unsigned char *raster, int32_t width, int32_t height, unsigned char *palette, char *label)
Definition: main_l1brsgen.c:58
void img_color_palette_quantization(img_rgb_t *in_image, int num_colors, uint8_t *palette, uint8_t *out_image)
Definition: color_quant.c:300
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_FLOAT32
int main(int argc, char *argv[])
Definition: main_l1brsgen.c:94
int loadl1(filehandle *l1file, l1str *l1rec)
Definition: loadl1.c:201
int i
Definition: decode_rs.h:71
msiBandIdx val
Definition: l1c_msi.cpp:34
int openl1(filehandle *l1file)
Definition: l1_io.c:207
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int npix
Definition: get_cmp.c:27
float32 f32
Definition: l2bin.cpp:104
l2prod max