NASA Logo
Ocean Color Science Software

ocssw V2022
l1cgen.cpp
Go to the documentation of this file.
1 
2 //**********************************************************
3 // l1cgen firstly defined as mainL1C.cpp
4 // Originally created by Martin Montes on 3/27/2021 (first version)
5 
6 //**********************************************************
7 #include <allocate2d.h>
8 #include <allocate3d.h>
9 #include "allocate4d.h"
10 #include <iostream>
11 #include "l1c_input.h"
12 #include "l1c_filehandle.h"
13 #include "l1c_str.h"
14 #include "l1c.h"
15 #include "hawkeye_methods.h"
16 #include <chrono>
17 #include <sys/stat.h>
18 #include "l2_str.h"
19 
20 #include <filehandle.h>
21 #include <l1.h>
22 #include <genutils.h>
23 
24 #include "l1c_latlongrid.h"
25 #include <netcdf>
26 
27 #include <global_attrs.h>
28 
29 using namespace std;
30 using namespace l1c;
31 using namespace std::chrono;
32 using namespace netCDF;
33 using namespace netCDF::exceptions;
34 
35 #define PROGRAM_NAME "l1cgen"
36 #define VERSION "5.63 7/2/2024"
37 
38 
39 int main(int argc, char** argv) {
40  int status;
42  double etime;
43  string ifile_str;
44  char* ifile_char;
46  vector<pair<float, int>> vp;
47 
48  L1C_input l1cinput;
49  l1c_filehandle l1cfile;
50  l1c_str l1cstr;
51  l2_str l2str;
52  L1C* ptl1c = new L1C();
53  filehandle l1file;
54  l1str l1rec;
55  //-------------------------------------------------------------------
56  if (argc == 1) {
57  l1cinput.l1c_usage(PROGRAM_NAME, VERSION);
58  return 1;
59  }
60 
61  for (int i = 0; i < argc; i++) {
62  if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-help") == 0)) {
63  l1cinput.l1c_usage(PROGRAM_NAME, VERSION);
64  }
65  }
66 
67  cout << PROGRAM_NAME << " " << VERSION << endl;
68  l1cfile.version = VERSION;
69  l1cfile.progname=PROGRAM_NAME;
70  // grab CLI info
71  l1cinput.l1c_inputmain(argc, argv, &l1cinput, &l1cfile, PROGRAM_NAME, VERSION);
72 
73  ifile_str = l1cinput.files[0];
74  ifile_char = (char*)ifile_str.c_str();
75  file_format format = getFormat(ifile_char);
76  l1cfile.format = format.type;
77 
78  if (format.type != FT_INVALID)
79  {
80  if (ptl1c->load_l1c_filehandle4(&l1cfile, &l1cinput) != 0) {
81  printf("-E- %s: Error loading %sl1c filehandle.\n", argv[0], l1cfile.l1b_name.c_str());
82  exit(1);
83  }
84  //----- READING HKT FILES -----------------------------------------------------------------
85  //**********************************************************************************************************-
86  if (l1cfile.l1c_pflag == 5) {
87  cout << "Reading telemetry from L1A files..--> SOCEA -- L1C grid.." << endl;
88 
89  string history = "", stri;
90  for (int i = 0; i < argc; i++) {
91  stri = argv[i];
92  history += stri + " ";
93  }
94 
95  strcpy(l1cinput.history, history.c_str());
96 
97  if (status = ptl1c->open_l1atol1c3(&l1cinput, &l1cfile) > 1) {
98  printf("-E- %d: status=2 error opening..L1A file for sensor...............\n", format.type);
99  exit(1);
100  }
101 
102  if (ptl1c != nullptr)
103  delete ptl1c;
104 
105  auto stop1 = high_resolution_clock::now();
106  auto duration = duration_cast<microseconds>(stop1 - start);
107  etime = duration.count();
108  etime /= (1000000 * 60);
109  cout << "done processing options #5..(creating SOCEA L1C common grid from telemetry " << etime
110  << "minutes..." << endl;
111  }
112 
113  else if (l1cfile.l1c_pflag == 7) {
114  string senstr;
115  string l1c_str = l1cinput.l1c_grid;
116  cout << "producing L1C grid from L1C granules and at CTH "
117  "......................................................"
118  << endl;
119 
120  if (l1cinput.sensor == 34) {
121  senstr = "SPEXone";
122  l1cfile.nbinx = 25;
123  } else if (l1cinput.sensor == 30) {
124  senstr = "OCI";
125  l1cfile.nbinx = 519;
126  } else if (l1cinput.sensor == 35) {
127  senstr = "HARP2";
128  l1cfile.nbinx = 457;
129  } else if (l1cinput.sensor == 28) {
130  senstr = "MISR";
131  l1cfile.nbinx = 81;
132  } else {
133  if (l1cinput.verbose)
134  cout << "sensor by default is OCI option 2....." << endl;
135  senstr = "OCI";
136  l1cfile.nbinx = 519;
137  }
138 
139  if (l1cinput.verbose) {
140  cout << "number of L1B files to be processed..." << 1 << endl;
141  cout << "number of L1C granules for screening scantime..." << l1cinput.files_l1c.size()
142  << endl;
143  }
144 
145  ptl1c->l1_cloud_correct(&l1cinput, &l1cfile);
146 
147  if (ptl1c != nullptr)
148  delete ptl1c;
149 
150  auto stop1 = high_resolution_clock::now();
151  auto duration = duration_cast<microseconds>(stop1 - start);
152  etime = duration.count();
153  etime /= (1000000 * 60);
154  cout << "done processing options #7..(cloud height parallax correction for L1B and L1C) in "
155  << etime << "minutes..." << endl;
156  }
157 
158  //**********************************************************************************************************************
159  else if (l1cfile.l1c_pflag == 8)
160  {
161  //---------------------------------------------------------
162  // DISCRETE BINNING -------------------------
163  //---------------------------------------------------------
164  if (l1cinput.verbose)
165  cout << "init filehandle and add options.." << endl;
167  l1_input_init();
170  // add extra options from CLI and coming in msl12_defaults.par
171  clo_addOption(optionList, "suite", CLO_TYPE_STRING, "OC", "suite of OC products");
172  clo_addOption(optionList, "aermodfile", CLO_TYPE_STRING, "Unspecified",
173  "path dir for aerosol files anc data");
174  clo_addOption(optionList, "aer_wave_short", CLO_TYPE_INT, "765",
175  "default shortest wavelength used for aerosol correction, epsilon");
176  clo_addOption(optionList, "aer_wave_long", CLO_TYPE_INT, "865",
177  "default longest wavelength used for aerosol correction, epsilon");
178  clo_addOption(optionList, "mumm_alpha", CLO_TYPE_FLOAT, "1.72",
179  "mumm alpha for AC Rudick turbid waters");
180  clo_addOption(optionList, "mumm_gamma", CLO_TYPE_FLOAT, "1.0",
181  "mumm gamma for AC Rudick turbid waters");
182  clo_addOption(optionList, "mumm_epsilon", CLO_TYPE_FLOAT, "1.0",
183  "mumm epsilon for AC Rudick turbid waters");
184  clo_addOption(optionList, "chloc2_wave", CLO_TYPE_INT, "[-1,-1]",
185  "sensor wavelengths for OC2 chlorophyll\n algorithm");
186  clo_addOption(optionList, "chloc2_coef", CLO_TYPE_FLOAT, "[0.0,0.0,0.0,0.0,0.0]",
187  "coefficients for OC2\n chlorophyll algorithm");
188  clo_addOption(optionList, "chloc3_wave", CLO_TYPE_INT, "[-1,-1]",
189  "sensor wavelengths for OC3 chlorophyll\n algorithm");
190  clo_addOption(optionList, "chloc3_coef", CLO_TYPE_FLOAT, "[0.0,0.0,0.0,0.0,0.0]",
191  "coefficients for OC3\n chlorophyll algorithm");
192  clo_addOption(optionList, "chloc4_wave", CLO_TYPE_INT, "[-1,-1]",
193  "sensor wavelengths for OC4 chlorophyll\n algorithm");
194  clo_addOption(optionList, "chloc4_coef", CLO_TYPE_FLOAT, "[0.0,0.0,0.0,0.0,0.0]",
195  "coefficients for OC4\n chlorophyll algorithm");
196  clo_addOption(optionList, "kd2_wave", CLO_TYPE_INT, "[-1,-1]",
197  "sensor wavelengths for polynomial Kd(490)\n algorithm");
198  clo_addOption(optionList, "kd2_coef", CLO_TYPE_FLOAT, "[0.0,0.0,0.0,0.0,0.0,0.0]",
199  "sensor wavelengths\n for polynomial Kd(490) algorithm");
200  clo_addOption(optionList, "coccolith", CLO_TYPE_FLOAT, "[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]",
201  "coefficients for coccolith algorithm");
202  clo_addOption(optionList, "qaa_wave", CLO_TYPE_INT, NULL, "sensor wavelengths for QAA algorithm");
203  clo_addOption(optionList, "giop_wave", CLO_TYPE_FLOAT, "-1",
204  "optimization comma-separated list, default is all visible bands (400-700nm)");
205  clo_addOption(optionList, "aer_wave_base", CLO_TYPE_INT, "865",
206  "base sensor wavelength for aerosol \n extrapolation");
207  clo_addOption(optionList, "aer_opt", CLO_TYPE_INT, "99", "aerosol mode option");
208  clo_addOption(optionList, "gas_opt", CLO_TYPE_INT, "1", "gaseous transmittance bitmask selector");
209  clo_addOption(optionList, "mbac_wave", CLO_TYPE_INT, NULL,
210  "bands used for mbac atmospheric correction");
211  clo_addOption(optionList, "wavelength_3d", CLO_TYPE_STRING, NULL,
212  "wavelength_3d input, written in ascending order\n"
213  " with format 'wavelength_3d=nnn,nnn,nnn' where nnn is a sensor wavelength\n"
214  " or a range of wavelengths as follows 'nnn:nnn'");
215  clo_addOption(optionList, "uncertaintyfile", CLO_TYPE_IFILE, NULL, "uncertainty LUT");
216  clo_addOption(optionList, "aermodels", CLO_TYPE_STRING, NULL, "aerosol models");
217  clo_addOption(optionList, "oxaband_opt", CLO_TYPE_INT, "0", "oxygen A-band correction");
218  clo_addOption(optionList, "filter_opt", CLO_TYPE_BOOL, NULL, "filtering input data option");
219  clo_addOption(optionList, "filter_file", CLO_TYPE_IFILE, "$OCDATAROOT/sensor/sensor_filter.dat", "\n data file for input filtering");
220  clo_addOption(optionList, "absaer_opt", CLO_TYPE_INT, "0", "absorbing aerosol flagging option\n"
221  " 0: disabled\n"
222  " 1: use rhow_412 aerosol index test\n"
223  " 2: GMAO ancillary aerosol test");
224  clo_addOption(optionList, "flh_base_wavelengths", CLO_TYPE_FLOAT, NULL, "flh baseline wavelengths");
225  clo_addOption(optionList, "flh_height_wavelength", CLO_TYPE_FLOAT, "-1.0", "flh height wavelength");
226  clo_addOption(optionList, "gas_transmittance_file", CLO_TYPE_IFILE, NULL, "gaseous transmittance file");
227  clo_addOption(optionList, "watervapor_bands", CLO_TYPE_INT, NULL, "bands used for calculating water vapor based on 3-band depth approach");
228 
229  l1_read_default_files(optionList, &l1file, ifile_char);
232 
233  string l1c_str = l1cinput.l1c_grid;
234  string l1c_str2 = l1cinput.l1c_anc;
235 
236  const char* l1c_grid = l1c_str.c_str();
237  const char* l1c_anc = l1c_str2.c_str();
238 
239  bin_str binl1c;
240  string history = "", stri;
241  for (int i = 0; i < argc; i++) {
242  stri = argv[i];
243  history += stri + " ";
244  }
245 
246  binl1c.history = history;
247  binl1c.version = l1cfile.version;
248  strcpy(binl1c.l1c_anc, l1cinput.l1c_anc);
249  binl1c.verbose = l1cinput.verbose;
250  binl1c.cloudem_flag = l1cinput.cloud_correct;
251  binl1c.cloud_type = l1cinput.cloud_type;
252  binl1c.dem_flag = l1cinput.demcloud_flag;
253 
254  int nfiles = l1cfile.ifiles.size();
255  int timebin_ok[nfiles];
256  int32_t npix_tot = 0;
257  int timeflag = -1;
258  const char* char_file;
259 
260  // checking time limits -------------
261  for (int f = 0; f < nfiles; f++) {
262  string str_file = l1cinput.files[f];
263  char_file = str_file.c_str();
264  if (l1cinput.verbose)
265  cout << "screening time for l1b.." << str_file << "granule # " << f + 1 << "of.."
266  << l1cinput.files.size() << endl;
267  strcpy(l1file.name, char_file);
268 
269  timeflag = check_l1c_time(char_file, l1c_grid, &binl1c);
270 
271  if (l1cinput.verbose)
272  cout << "time flag.." << timeflag << endl;
273  if (timeflag == 0) { // inside the grid
274  timebin_ok[f] = 0;
275  } else
276  timebin_ok[f] = 1;
277  if (l1cinput.verbose)
278  cout << "timebinok.." << timebin_ok[f] << endl;
279  }
280 
281  if (l1cinput.verbose)
282  cout << "checking time limits of ANC L1C file" << endl;
283  if (binl1c.l1c_anc[0] != '\0' && strcmp(binl1c.l1c_anc, char_file) == 0) {
284  timeflag = check_l1c_time(l1c_anc, l1c_grid, &binl1c);
285  }
286 
287  //-------- creating output L1C file ------------------------
288  string str_file;
289  if (nfiles >= 2) {
290  str_file = l1cinput.files[1]; // index 1 assuming 3 files, this is the middle one
291  } else if (nfiles == 1) {
292  str_file = l1cinput.files[0];
293  } else {
294  cout << "ERROR- no L1B files provided!!" << endl;
295  exit(1);
296  }
297 
298  char_file = str_file.c_str();
299  strcpy(l1file.name, char_file);
300  openl1(&l1file);
301  if (alloc_l1(&l1file, &l1rec) == 0) {
302  cout << "Unable to allocate L1 record....." << endl;
303  exit(1);
304  }
305  int32_t spix = MAX(l1_input->spixl - 1, 0);
306  int32_t epix = MAX(l1_input->epixl - 1, l1file.npix - 1);
307  int32_t dpix = MAX(l1_input->dpixl, 1);
308  int32_t sscan = MAX(l1_input->sline - 1, 0);
309  int32_t escan = MAX(l1_input->eline - 1, l1file.nscan - 1);
310  int32_t dscan = MAX(l1_input->dline - 1, 1);
311 
312  l1file.spix = spix;
313  l1file.epix = epix;
314 
315  int32_t npix = (epix - spix) / dpix + 1;
316  int32_t nscan = (escan - sscan) / dscan + 1;
317 
318  l1file.npix = npix;
319  l1file.nscan = nscan;
320 
321  short** gdindex = nullptr;
322 
323  if (l1cinput.verbose)
324  cout << "number of 'working' bands..." << l1file.nbands << endl;
325 
326  ifile_char = l1file.name;
327  file_format format = getFormat(ifile_char);
328 
329  NcFile* nc_output;
330  string l1c_full_str, ofile, senstr;
331  if (format.type == FT_OCIL1B)
332  senstr = "OCI";
333 
334  // check if ofile is empty
335  if (strcmp(l1cinput.ofile, "") == 0) {
336  if (l1cinput.verbose)
337  cout << "ofile not provided - use DEFAULT based on L1C grid.." << l1c_str << endl;
338  string substr = ".";
339  size_t ixstr1 = l1c_str.find(substr);
340  if (ixstr1 == string::npos) {
341  cout << "ERROR building L1C ofile from L1C grid" << endl;
342  exit(1);
343  }
344 
345  char arr[] = ".";
346  size_t ixstr2 = l1c_str.find(arr, ixstr1 + 1);
347  if (ixstr2 == string::npos) {
348  cout << "ERROR building L1C ofile from L1C grid" << endl;
349  exit(1);
350  }
351 
352  ofile = "PACE_" + senstr + l1c_str.substr(ixstr1, ixstr2) + ".nc";
353  if (l1cinput.verbose)
354  cout << "ofile default..." << ofile << endl;
355  l1c_full_str = ofile;
356  strcpy(l1cinput.ofile, ofile.c_str());
357  } else {
358  l1c_full_str = string(l1cinput.ofile);
359  if (l1cinput.verbose)
360  cout << "ofile.." << l1cinput.ofile << endl;
361  }
362 
363  binl1c.full_l1cgrid = l1c_full_str;
364 
365  cout << "creating FULL L1C file---------------" << l1c_full_str << endl;
366 
367  // empty file
368  try {
369  nc_output = new NcFile(l1cinput.ofile, NcFile::replace);
370  } catch (NcException& e) {
371  cerr << e.what() << "l1cgen l1c_pflag= 8:: Failure to replace FULL L1C grid: " + l1c_full_str
372  << endl;
373  exit(1);
374  }
375 
376  history = get_history(nc_output);
377  history.append(call_sequence(argc, argv));
378  set_global_attrs(nc_output, history);
379 
380  nc_output->close();
381 
382  if (l1cinput.verbose)
383  cout << "adding more metadata to the FULL L1C file---------------" << l1c_full_str << endl;
384 
385  try {
386  nc_output = new NcFile(l1cinput.ofile, NcFile::write);
387 
388  } catch (NcException& e) {
389  cerr << e.what() << "l1cgen l1c_pflag= 8:: Failure to write FULL L1C grid: " + l1c_full_str
390  << endl;
391  exit(1);
392  }
393 
394  strcpy(binl1c.outlist, l1cinput.outlist);
395  if(l1cinput.pversion[0])
396  binl1c.pversion = l1cinput.pversion;
397  if(l1cinput.doi[0])
398  binl1c.doi = l1cinput.doi;
399 
400  meta_l1c_full(&l1file, &binl1c, l1cinput.l1c_grid,
401  nc_output); // sensor view bands, geolocation, calls global attributes
402 
403  readl1(&l1file, 1, &l1rec);
404  closel1(&l1file);
405 
406  gdindex = allocate2d_short(npix, 2);
407  int32_t skipped[nfiles], nscan_tot = 0;
408 
409  for (int f = 0; f < nfiles; f++) {
410  skipped[f] = 0;
411  int firstcall=0;
412  if (timebin_ok[f] == 0) {
413  l1cfile.l1b_name = l1cfile.ifiles[f];
414  const char* char_file = l1cfile.l1b_name.c_str();
415 
416  //----binning --------------------------
417  strcpy(l1file.name, char_file);
418  openl1(&l1file);
419  if (l1cinput.verbose)
420  cout << "binning filename :" << l1file.name << endl;
421 
422  if (alloc_l1(&l1file, &l1rec) == 0) {
423  cout << "Unable to allocate L1 record....." << endl;
424  exit(1);
425  }
426  int32_t spix = MAX(l1_input->spixl - 1, 0);
427  int32_t epix = MAX(l1_input->epixl - 1, l1file.npix - 1);
428  int32_t dpix = MAX(l1_input->dpixl, 1);
429  int32_t sscan = MAX(l1_input->sline - 1, 0);
430  int32_t escan = MAX(l1_input->eline - 1, l1file.nscan - 1);
431  int32_t dscan = MAX(l1_input->dline - 1, 1);
432 
433  nscan_tot += l1file.nscan;
434 
435  l1file.spix = spix;
436  l1file.epix = epix;
437 
438  int32_t npix = (epix - spix) / dpix + 1;
439  int32_t nscan = (escan - sscan) / dscan + 1;
440 
441  l1file.npix = npix;
442  l1file.nscan = nscan;
443  npix_tot += npix * nscan;
444 
445  double timetemp = 0.0, time_offset = 0.;
446  for (int sline = 0; sline < l1file.nscan; sline++) {
447  readl1(&l1file, sline, &l1rec);
448 
449  // set timetemp to the beginning of the day
450  // only need to calculate for the first line
451  if (sline == 0) {
452  int16_t syear, smon, sday;
453  double secs;
454  unix2ymds(l1rec.scantime, &syear, &smon, &sday, &secs);
455  time_offset = ymds2unix(syear, smon, sday, 0.0);
456  }
457  timetemp = l1rec.scantime - time_offset;
458 
459  int result = search_l1c(&l1file, &l1rec, &binl1c, gdindex);
460  if (result == 110) {
461  if (l1cinput.verbose) {
462  cout << "WARNING---- some lat/lon out of boundaries or FILLVALUES at line # "
463  << sline + 1 << endl;
464  cout << "skipping line # :" << sline + 1 << endl;
465  }
466  skipped[f] += 1;
467  binl1c.outpix += npix;
468  } else {
469  if (l1cinput.cloud_correct > 0) {
470  result =
471  parallax(&l1file, l1c_anc, l1c_grid, &l1rec, &binl1c, gdindex, nc_output,sline,firstcall);
472  if (result == 110) {
473  if (l1cinput.verbose) {
474  cout << "WARNING---- some lat/lon out of boundaries or FILLVALUES "
475  "at line # "
476  << sline + 1 << endl;
477  cout << "skipping line # :" << sline + 1 << endl;
478  }
479  skipped[f] += 1;
480  }
481  }
482 
483  bintime_l1c(&l1file, &l1rec, &binl1c, gdindex, timetemp,
484  nc_output); // TIME VARS
485  bin_l1c(&l1file, &l1rec, &binl1c, gdindex, nc_output); // NO TIME VARS
486  rmse_l1c_alt(&l1file, &binl1c, &l1rec, gdindex); // diff2 height
487  }
488  if (sline % 100 == 0)
489  cout << "scanline " << sline + 1
490  << ", pixels binned " << binl1c.inpix
491  << ", pixels outside the grid " << binl1c.outpix << endl;
492  }
493 
494  closel1(&l1file);
495  } else {
496  if (l1cinput.verbose)
497  cout << "L1B granule # " << f + 1
498  << "is SKIPPED due to time beyond L1C granule boundaries" << endl;
499  }
500  } // end files
501 
502  meta_l1c_bin(&l1file, &binl1c, nc_output); // time offset/ mean geometry and I
503  meta_l1c_altvar(&binl1c, nc_output); // RMS or stdev height
504 
505  free(gdindex);
506  nc_output->close();
507  ptl1c->add_proc_group_l1c(&l1cinput,&l1cfile,l1cinput.ofile);
508 
509 
510  int32_t sk_tot = 0;
511  for (int f = 0; f < nfiles; f++) {
512  cout << "file # :" << f + 1 << " skipped lines # :" << skipped[f] << endl;
513  if (nscan_tot > 0) {
514  cout << "percentage of missing scans due to geolocation # :"
515  << 100.0 * skipped[f] / nscan_tot << endl;
516  } else {
517  cout << "WARNING: L1B FILES HAVE NO DATA!! " << endl;
518  break;
519  }
520  sk_tot += skipped[f];
521  }
522 
523  cout << "#badgeo " << binl1c.badgeo << "#inpix: " << binl1c.inpix << "#outpix: " << binl1c.outpix
524  << "tot pixels: " << npix_tot << "missing scans %.." << 100.0 * sk_tot / nscan_tot << endl;
525 
526  binl1c.close_bin(&binl1c);
527  delete (l1_input);
528 
529  if (ptl1c != nullptr)
530  delete ptl1c;
531 
532  auto stop1 = high_resolution_clock::now();
533  auto duration = duration_cast<microseconds>(stop1 - start);
534  etime = duration.count();
535  etime /= (1000000 * 60);
536 
537  cout << "done processing options #8..(using L1C functions from libl1 and l1 readers) in " << etime
538  << "minutes..." << endl;
539 
540  if (binl1c.inpix == 0 && binl1c.outpix == 0 && binl1c.badgeo > 0) {
541  cout << "WARNING: L1B files have EMPTY OR /BAD geolocation data" << endl;
542  return (110);
543  } else if (binl1c.inpix == 0 && binl1c.outpix != 0 && binl1c.badgeo == 0) {
544  cout << "WARNING: L1B files have geolocation data but outside the grid" << endl;
545  return (130);
546  } else
547  return (0);
548  }
549  }
550 
551  else {
552  printf("-E- %s: Error opening %s for reading unknown sensor...................\n", argv[0],
553  l1cfile.l1b_name.c_str());
554  return (1);
555  }
556 
557  return (0);
558 }
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
Definition: l1stat_chk.c:586
int cloud_type
void l1_input_init()
Definition: l1_options.c:11
#define MAX(A, B)
Definition: swl0_utils.h:25
clo_option_t * clo_addOption(clo_optionList_t *list, const char *key, enum clo_dataType_t dataType, const char *defaultVal, const char *desc)
Definition: clo.c:684
int main(int argc, char **argv)
Definition: l1cgen.cpp:39
std::string doi
int readl1(filehandle *l1file, int32_t recnum, l1str *l1rec)
Definition: l1_io.c:439
Utility functions for allocating and freeing three-dimensional arrays of various types.
int meta_l1c_altvar(bin_str *binl1c, NcFile *nc_output)
std::string progname
int status
Definition: l1_czcs_hdf.c:32
std::string l1b_name
int rmse_l1c_alt(filehandle *l1file, bin_str *binl1c, l1str *l1rec, short **gdindex)
#define NULL
Definition: decode_rs.h:63
void filehandle_init(filehandle *file)
read l1rec
void unix2ymds(double usec, int16_t *year, int16_t *mon, int16_t *day, double *secs)
Definition: unix2ymds.c:8
#define PROGRAM_NAME
Definition: l1cgen.cpp:35
int parallax(filehandle *l1file, const char *l1c_anc, const char *l1c_grid, l1str *l1rec, bin_str *binl1c, short **gdindex, NcFile *nc_output, int32_t sline, int firstcall)
int syear
Definition: l1_czcs_hdf.c:15
@ CLO_TYPE_FLOAT
Definition: clo.h:84
int32 nscan
Definition: l1_czcs_hdf.c:19
@ string
@ CLO_TYPE_BOOL
Definition: clo.h:81
virtual int32_t l1c_inputmain(int argc, char **argv, L1C_input *l1cinput, l1c_filehandle *l1cfile, const char *prog, const char *version)
Definition: l1c_input.cpp:579
int meta_l1c_bin(filehandle *l1file, bin_str *binl1c, NcFile *nc_output)
int sday
Definition: l1_czcs_hdf.c:15
char l1c_grid[FILENAME_MAX]
Definition: l1c_input.h:30
int demcloud_flag
Definition: l1c_input.h:76
double precision function f(R1)
Definition: tmd.lp.f:1454
int check_l1c_time(const char *l1b_file, const char *l1c_grid, bin_str *binl1c)
clo_optionList_t * clo_createList()
Definition: clo.c:532
Definition: l1c.h:44
Utility functions for allocating and freeing four-dimensional arrays of various types.
char pversion[256]
Definition: l1c_input.h:36
string call_sequence(int argc, char *argv[])
char outlist[FILENAME_MAX]
int32_t badgeo
@ CLO_TYPE_INT
Definition: clo.h:82
string get_history(int argc, char *argv[])
Definition: DDOptions.cpp:496
file_format getFormat(char *filename)
Definition: filetype.c:192
void l1_add_options(clo_optionList_t *list)
Definition: l1_options.c:77
int32_t sensor
Definition: l1c_input.h:64
void set_global_attrs(NcFile *outfile, string history, string doi, string pversion)
char l1c_anc[FILENAME_MAX]
Definition: l1c_input.h:31
virtual int32_t open_l1atol1c3(L1C_input *l1cinput, l1c_filehandle *l1cfile)
Definition: l1c.cpp:1061
l1_input_t * l1_input
Definition: l1_options.c:9
@ CLO_TYPE_IFILE
Definition: clo.h:87
virtual int32_t add_proc_group_l1c(L1C_input *l1cinput, l1c_filehandle *l1cfile, const char *filename)
Definition: l1c.cpp:79
Definition: l1c.cpp:71
char doi[256]
Definition: l1c_input.h:37
string history
Definition: ncattredit.py:30
virtual int close_bin(bin_str *binstr)
#define VERSION
Definition: l1cgen.cpp:36
Utility functions for allocating and freeing two-dimensional arrays of various types.
std::vector< std::string > files_l1c
Definition: l1c_input.h:45
std::vector< std::string > files
Definition: l1c_input.h:44
clo_optionList_t * optionList
void closel1(filehandle *l1file)
Definition: l1_io.c:73
virtual int32_t l1_cloud_correct(L1C_input *l1cinput, l1c_filehandle *l1cfile)
Definition: l1c.cpp:245
char ofile[FILENAME_MAX]
Definition: l1c_input.h:28
int32 dpix
Definition: l1_czcs_hdf.c:22
int meta_l1c_full(filehandle *l1file, bin_str *binl1c, const char *l1c_grid, NcFile *nc_output)
char history[200]
Definition: l1c_input.h:35
int32 spix
Definition: l1_czcs_hdf.c:21
virtual int32_t load_l1c_filehandle4(l1c_filehandle *l1cfile, L1C_input *l1cinput)
Definition: l1c.cpp:3479
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
@ FT_INVALID
Definition: filetype.h:12
int search_l1c(filehandle *l1file, l1str *l1rec, bin_str *binl1c, short **gdindex)
void l1_load_options(clo_optionList_t *list, filehandle *l1file)
Definition: l1_options.c:255
int cloudem_flag
void l1_read_default_files(clo_optionList_t *list, filehandle *l1file, const char *ifile)
Definition: l1_options.c:200
int cloud_correct
Definition: l1c_input.h:74
void clo_deleteList(clo_optionList_t *list)
Definition: clo.c:875
int32 epix
Definition: l1_czcs_hdf.c:23
short ** allocate2d_short(size_t h, size_t w)
Allocate a two-dimensional array of type short of a given size.
Definition: allocate2d.c:79
int32_t alloc_l1(filehandle *l1file, l1str *l1rec)
Definition: alloc_l1.c:18
double ymds2unix(short year, short month, short day, double secs)
char outlist[FILENAME_MAX]
Definition: l1c_input.h:29
char l1c_anc[FILENAME_MAX]
@ FT_OCIL1B
Definition: filetype.h:43
int32_t outpix
virtual int32_t l1c_usage(const char *prog, const char *version)
Definition: l1c_input.cpp:71
std::string version
int i
Definition: decode_rs.h:71
int bintime_l1c(filehandle *l1file, l1str *l1rec, bin_str *binstr, short **gdindex, double scantime, NcFile *nc_output)
int openl1(filehandle *l1file)
Definition: l1_io.c:230
@ CLO_TYPE_STRING
Definition: clo.h:86
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int32_t inpix
bool verbose
std::vector< std::string > ifiles
int npix
Definition: get_cmp.c:28
std::string history
#define str(s)
int bin_l1c(filehandle *l1file, l1str *l1rec, bin_str *binl1c, short **gdindex, NcFile *nc_output)
std::string full_l1cgrid
std::string pversion