OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
calfile_utils.c
Go to the documentation of this file.
1 /* ========================================================================
2  * Procedures create, read, and write detector/mirror side pixel data
3  *
4  * Programmer Organization Date Description of change
5  * -------------- ------------ -------- ---------------------
6  * Sean Bailey Futuretech 23 July 2014 Original development
7  * based on l1det_hdf.c
8  * ======================================================================== */
9 
10 #include <stdio.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <stdlib.h>
14 #include <fcntl.h>
15 #include <string.h>
16 #include <errno.h>
17 #include <unistd.h>
18 #include <libgen.h>
19 #include <math.h>
20 
21 #include <netcdf.h>
22 #include "passthebuck.h"
23 #include "filehandle.h"
24 
25 #include "dfutils.h"
26 #include "l2prod_struc.h"
27 #include "calfile_utils.h"
28 #include "l12_proto.h"
29 
48 idDS calfile_open(char *ofile, int sensorID, int ydim, int xdim, int nprods,
49  int nvars1d, char l2prods[L1_MAXPROD][32], char vars1Dnames[L1_MAXPROD][32],
50  long* numExistingRecords, caltype ctype) {
51  idDS ds_id;
52  int status;
53  int i, j;
54  *numExistingRecords = 0;
55  int32 dm[3];
56  int start[3] = {0, 0, 0};
57  int stride[3] = {1, 1, 1};
58  int count[3] = {1, 1, 0};
59  char name[MAX_NC_NAME];
60 
61  ds_id = openDS(ofile);
62  if (ds_id.fid == FAIL) {
63  status = calfile_create(ofile, &ds_id, sensorID, ydim, xdim, nprods,
64  nvars1d, l2prods, vars1Dnames, ctype);
65  if (status) {
66  printf("Whoops! problem creating output file %s\n", ofile);
67  exit(EXIT_FAILURE);
68  }
69  } else {
70  //get the number of runs in the existing file
71  status = getDimsDS(ds_id, "fileID", dm);
72 
73  if (status) {
74  printf(
75  "Sorry, Charlie, output file %s already exists, but does not contain fileID array...try a new output file\n",
76  ofile);
77  exit(EXIT_FAILURE);
78  }
79  // Bump the fileID
80  start[0] = dm[0] - 1;
81  int16_t fileIDold;
82  DPTB(readDS(ds_id, "fileID", start, stride, count, &fileIDold));
83  fileID = fileIDold + 1;
84 
85  *numExistingRecords = dm[0];
86  // close the old file so we can move it to ".old"
87  status = endDS(ds_id);
88 
89  char *oldfile = (char *) malloc(strlen(ofile) + 5);
90  strcpy(oldfile, ofile);
91  strcat(oldfile, ".old");
92  char cmd[2048];
93  sprintf(cmd, "mv %s %s", ofile, oldfile);
94  system(cmd);
95  // bump nruns by numExistingRecords and create new ofile
96  ydim += *numExistingRecords;
97  status = calfile_create(ofile, &ds_id, sensorID, ydim, xdim, nprods,
98  nvars1d, l2prods, vars1Dnames, ctype);
99  if (status) {
100  printf("Whoops! problem creating output file %s\n", ofile);
101  exit(EXIT_FAILURE);
102  }
103 
104  // open old file
105  idDS old_ds_id;
106  old_ds_id = openDS(oldfile);
107  if (old_ds_id.fid == FAIL) {
108  printf("Whoops! problem opening old file %s\n", oldfile);
109  exit(EXIT_FAILURE);
110  }
111 
112  start[0] = 0;
113  count[0] = dm[0];
114  count[1] = xdim;
115  VOIDP data = malloc(count[0] * count[1] * sizeof (float));
116 
117  // loop through old file and write records to new ofile
118 
119  // copy filename global attributes
120  for (i = 0; i < fileIDold + 1; i++) {
121  sprintf(name, "filename%03d", i);
122  char* val = readAttrStr(old_ds_id, name);
123  if (val) {
124  DPTB(SetChrGA(ds_id, name, val));
125  free(val);
126  }
127  }
128 
129  // copy data
130  DPTB(readDS(old_ds_id, "fileID", start, stride, count, data));
131  DPTB(writeDS(ds_id, "fileID", data, 0, 0, 0, count[0], count[1],
132  count[2]));
133 
134  DPTB(readDS(old_ds_id, "year", start, stride, count, data));
135  DPTB(writeDS(ds_id, "year", data, 0, 0, 0, count[0], count[1],
136  count[2]));
137 
138  DPTB(readDS(old_ds_id, "day", start, stride, count, data));
139  DPTB(writeDS(ds_id, "day", data, 0, 0, 0, count[0], count[1], count[2]));
140 
141  DPTB(readDS(old_ds_id, "msec", start, stride, count, data));
142  DPTB(writeDS(ds_id, "msec", data, 0, 0, 0, count[0], count[1],
143  count[2]));
144 
145  DPTB(readDS(old_ds_id, "iscan", start, stride, count, data));
146  DPTB(writeDS(ds_id, "iscan", data, 0, 0, 0, count[0], count[1],
147  count[2]));
148 
149  for (i = 0; i < nvars1d; i++) {
150  DPTB(readDS(old_ds_id, vars1Dnames[i], start, stride, count, data));
151  DPTB(writeDS(ds_id, vars1Dnames[i], data, 0, 0, 0, count[0], count[1],
152  count[2]));
153  }
154  // DPTB(readDS(old_ds_id, "lon", start, stride, count, data));
155  // DPTB(
156  // writeDS(ds_id, "lon", data, 0, 0, 0, count[0], count[1],
157  // count[2]));
158  //
159  // DPTB(readDS(old_ds_id, "lat", start, stride, count, data));
160  // DPTB(
161  // writeDS(ds_id, "lat", data, 0, 0, 0, count[0], count[1],
162  // count[2]));
163 
164  DPTB(readDS(old_ds_id, "mside", start, stride, count, data));
165  DPTB(writeDS(ds_id, "mside", data, 0, 0, 0, count[0], count[1],
166  count[2]));
167 
168  DPTB(readDS(old_ds_id, "pixnum", start, stride, count, data));
169  DPTB(writeDS(ds_id, "pixnum", data, 0, 0, 0, count[0], count[1],
170  count[2]));
171 
172  if (ctype == CROSSCAL || ctype == BINMATCH) {
173  DPTB(readDS(old_ds_id, "detnum", start, stride, count, data));
174  DPTB(writeDS(ds_id, "detnum", data, 0, 0, 0, count[0], count[1],
175  count[2]));
176  }
177 
178  for (i = 0; i < nprods; i++) {
179  int skip = 0;
180  for (j = 0; j < nvars1d; j++) {
181  if (strcmp(l2prods[i], vars1Dnames[j]) == 0) {
182  skip = 1;
183  break;
184  }
185  }
186  if (skip == 0 && strcmp(l2prods[i], "pixnum") != 0
187  && strcmp(l2prods[i], "mside") != 0
188  && strcmp(l2prods[i], "detnum") != 0
189  && strcmp(l2prods[i], "l2_flags") != 0) {
190  DPTB(readDS(old_ds_id, l2prods[i], start, stride, count, data));
191  DPTB(writeDS(ds_id, l2prods[i], data, 0, 0, 0, count[0],
192  count[1], count[2]));
193  }
194  }
195  // close old file and remove it.
196  free(data);
197  status = endDS(old_ds_id);
198  sprintf(cmd, "rm -f %s", oldfile);
199  system(cmd);
200 
201  }
202  return ds_id;
203 }
204 
210 int calfile_close(idDS ds_id) {
211  int status;
212  status = endDS(ds_id);
213  return status;
214 }
215 
230 int calfile_create(char *ofile, idDS *ds_id, int sensorID, int ydim, int xdim,
231  int nprods, int nvars1d, char l2prods[L1_MAXPROD][32],
232  char vars1Dnames[L1_MAXPROD][32], caltype ctype) {
233 
234  char title[255];
235  int i, j;
236  int dumdim;
237  int status;
238  char name[MAX_NC_NAME];
239  int32 dm[3];
240  const char dm_name[3][80];
241  dm[0] = ydim;
242  dm[1] = xdim;
243  switch (ctype) {
244 
245  case DET2DET:
246  strcpy((char *) dm_name[0], "runs");
247  strcpy((char *) dm_name[1], "detectors");
248  sprintf(title,
249  "%s Level-1 detector/mirror-side runs of consecutive pixels",
251  break;
252  case CROSSCAL:
253  strcpy((char *) dm_name[0], "pixels");
254  strcpy((char *) dm_name[1], "xdim");
255  sprintf(title, "%s Level-2 cross-calibration pixels",
257  break;
258  case BINMATCH:
259  strcpy((char *) dm_name[0], "pixels");
260  strcpy((char *) dm_name[1], "L2L3");
261  sprintf(title, "%s Level-2/3 matched pixels",
263  break;
264  default:
265  fprintf(stderr, "Unknown caltype! \n");
266  exit(EXIT_FAILURE);
267  break;
268  }
269 
270  if (strcmp(input->oformat, "netCDF4") == 0) {
271  *ds_id = startDS(ofile, DS_NCDF, DS_WRITE, input->deflate);
272  for (i = 0; i < 2; i++) {
273  status = nc_def_dim((*ds_id).fid, dm_name[i], dm[i], &dumdim);
274  if (status != NC_NOERR) {
275  fprintf(stderr, "%s\n", nc_strerror(status));
276  exit(EXIT_FAILURE);
277  }
278  }
279  } else {
280  *ds_id = startDS(ofile, DS_HDF, DS_WRITE, 0);
281  }
282 
283  /* */
284  /* Create the SDSes */
285  /* ---------------------------------------------------------------- */
286  /* */
287  PTB(SetChrGA(*ds_id, "title", title));
288  PTB(SetI32GA(*ds_id, "sensorID", (int32) sensorID));
289  sprintf(name, "filename%03d", fileID);
290  PTB(SetChrGA(*ds_id, name, basename(input->ifile[0])));
291 
292  PTB(createDS(*ds_id, (int) sensorID, "fileID", dm, dm_name));
293  PTB(createDS(*ds_id, (int) sensorID, "year", dm, dm_name));
294  PTB(createDS(*ds_id, (int) sensorID, "day", dm, dm_name));
295  PTB(createDS(*ds_id, (int) sensorID, "msec", dm, dm_name));
296 
297  PTB(createDS(*ds_id, (int) sensorID, "iscan", dm, dm_name));
298  // PTB(createDS(*ds_id, (int ) sensorID, "lon", dm, dm_name));
299  // PTB(createDS(*ds_id, (int ) sensorID, "lat", dm, dm_name));
300  PTB(createDS(*ds_id, (int) sensorID, "mside", dm, dm_name));
301  PTB(createDS(*ds_id, (int) sensorID, "pixnum", dm, dm_name));
302 
303  for (i = 0; i < nvars1d; i++) {
304  PTB(createDS(*ds_id, (int) sensorID, vars1Dnames[i], dm, dm_name));
305  }
306 
307  if (ctype == CROSSCAL || ctype == BINMATCH) {
308  PTB(createDS(*ds_id, (int) sensorID, "detnum", dm, dm_name));
309  }
310 
311  for (i = 0; i < nprods; i++) {
312  int skip = 0;
313  for (j = 0; j < nvars1d; j++) {
314  if (strcmp(l2prods[i], vars1Dnames[j]) == 0) {
315  skip = 1;
316  break;
317  }
318  }
319  if (skip == 0 && strcmp(l2prods[i], "pixnum") != 0
320  && strcmp(l2prods[i], "mside") != 0
321  && strcmp(l2prods[i], "detnum") != 0
322  && strcmp(l2prods[i], "l2_flags") != 0) {
323  PTB(
324  createDS(*ds_id, (int) sensorID, l2prods[i], dm,
325  dm_name));
326  }
327  }
328 
329  return (LIFE_IS_GOOD);
330 
331 }
332 
348 int calfile_write(idDS ds_id, calstr *calrec, int recnum, int ydim, int xdim,
349  int nprods, int nbands, int nvars1d, char l2prods[L1_MAXPROD][32],
350  char vars1Dnames[L1_MAXPROD][32], caltype ctype) {
351 
352  int32 i, j;
353  static int firstWrite = 1;
354  static l2prodstr** prodptr;
355  VOIDP *pbuf;
356  int iwave[nbands + NBANDSIR], *iwave_p;
357 
358  static productInfo_t **v1Dp_info;
359  static productInfo_t **p_info;
360 
361  if (firstWrite) {
362  if ((v1Dp_info = (productInfo_t **) malloc(nvars1d * sizeof (struct productInfo_t *))) == NULL) {
363  printf("%s -Error: Cannot allocate memory to productInfo data\n",
364  __FILE__);
365  exit(FATAL_ERROR);
366  }
367  if ((p_info = (productInfo_t **) malloc(nprods * sizeof (struct productInfo_t *))) == NULL) {
368  printf("%s -Error: Cannot allocate memory to productInfo data\n",
369  __FILE__);
370  exit(FATAL_ERROR);
371  }
372  rdsensorinfo(calrec->sensorID, 0, "iwave", (void **) &iwave_p);
373  for (i = 0; i < nbands + NBANDSIR; i++) {
374  iwave[i] = iwave_p[i];
375  }
376  if ((prodptr = (l2prodstr **) malloc(L1_MAXPROD * sizeof (l2prodstr *)))
377  == NULL) {
378  printf(
379  "-E- : Error allocating memory for product info record structures\n");
380  exit(EXIT_FAILURE);
381  }
382  for (i = 0; i < nprods; i++) {
383  p_info[i] = allocateProductInfo();
384  if (!findProductInfo(l2prods[i], calrec->sensorID, p_info[i])) {
385  printf("%s not found in XML product table\n", l2prods[i]);
386  exit(EXIT_FAILURE);
387  }
388  if ((prodptr[i] = get_l2prod_index(l2prods[i], calrec->sensorID,
389  nbands, xdim, ydim, iwave)) == NULL) {
390  fprintf(stderr, "-E- %s line %d: product index failure.\n",
391  __FILE__, __LINE__);
392  return (1);
393  };
394  }
395  for (i = 0; i < nvars1d; i++) {
396  v1Dp_info[i] = allocateProductInfo();
397  if (!findProductInfo(vars1Dnames[i], calrec->sensorID, v1Dp_info[i])) {
398  printf("%s not found in XML product table\n", vars1Dnames[i]);
399  exit(EXIT_FAILURE);
400  }
401  j = i + nprods;
402  if ((prodptr[j] = get_l2prod_index(vars1Dnames[i], calrec->sensorID,
403  nbands, xdim, ydim, iwave)) == NULL) {
404  fprintf(stderr, "-E- %s line %d: product index failure.\n",
405  __FILE__, __LINE__);
406  return (1);
407  };
408  }
409 
410  firstWrite = 0;
411  }
412  PTB(writeDS(ds_id, "fileID", (VOIDP) & fileID, recnum, 0, 0, 1, 1, 1));
413  PTB(writeDS(ds_id, "year", (VOIDP) & (calrec->year), recnum, 0, 0, 1, 1, 1));
414  PTB(writeDS(ds_id, "day", (VOIDP) & (calrec->day), recnum, 0, 0, 1, 1, 1));
415  PTB(writeDS(ds_id, "msec", (VOIDP) & (calrec->msec), recnum, 0, 0, 1, 1, 1));
416  PTB(writeDS(ds_id, "iscan", (VOIDP) & (calrec->iscan), recnum, 0, 0, 1, 1, 1));
417  for (i = 0; i < nvars1d; i++) {
418  j = i + nprods;
419  if ((v1Dp_info[i])->scaleFactor == 1.0 && (v1Dp_info[i])->addOffset == 0.0)
420  pbuf = (VOIDP) & calrec->vars1D[i];
421  else
422  pbuf = scale_sds(&calrec->vars1D[i], v1Dp_info[i], 1);
423  PTB(writeDS(ds_id, vars1Dnames[i], pbuf, recnum, 0, 0, 1, 1, 1));
424  }
425  for (i = 0; i < xdim; i++) {
426  PTB(writeDS(ds_id, "pixnum", (VOIDP) & (calrec->pixnum), recnum, i, 0, 1, 1, 1));
427  }
428  PTB(writeDS(ds_id, "mside", (VOIDP) & (calrec->mside), recnum, 0, 0, 1, 1, 1));
429 
430  if (ctype == CROSSCAL || ctype == BINMATCH) {
431  PTB(writeDS(ds_id, "detnum", (VOIDP) & (calrec->detnum), recnum, 0, 0, 1, 1, 1));
432  }
433  int Ltix = 0;
434  int vLtix = 0;
435  for (i = 0; i < nprods; i++) {
436  int skip = 0;
437  for (j = 0; j < nvars1d; j++) {
438  if (strcmp(l2prods[i], vars1Dnames[j]) == 0) {
439  skip = 1;
440  break;
441  }
442  }
443  if (skip == 0 && strcmp(l2prods[i], "pixnum") != 0
444  && strcmp(l2prods[i], "mside") != 0
445  && strcmp(l2prods[i], "detnum") != 0
446  && strcmp(l2prods[i], "l2_flags") != 0) {
447 
448  if (strncmp(l2prods[i], "Lt", 2) == 0) {
449  pbuf = (VOIDP) calrec->Lt[Ltix++];
450  } else if (strncmp(l2prods[i], "vLt", 3) == 0) {
451  pbuf = (VOIDP) calrec->vLt[vLtix++];
452  } else {
453  if ((p_info[i])->scaleFactor == 1.0 && (p_info[i])->addOffset == 0.0)
454  pbuf = (VOIDP) calrec->data[i];
455  else
456  pbuf = scale_sds(calrec->data[i], p_info[i], xdim);
457  }
458  PTB(writeDS(ds_id, l2prods[i], pbuf, recnum, 0, 0, 1, xdim, 1));
459  }
460  }
461 
462  return (LIFE_IS_GOOD);
463 
464 }
465 
480 void inversion_init(long ndets, long iscan, int nbands, long ipix, aestr *aerec,
481  tgstr *tgrec) {
482  int band;
483  long kscan;
484  float avg_nLw;
485  float avg_aot;
486 
487  for (band = 0; band < nbands; band++) {
488  avg_nLw = 0;
489  avg_aot = 0;
490  for (kscan = iscan; kscan < iscan + ndets; kscan++) {
491  avg_nLw += nlws[kscan][ipix][band];
492  avg_aot += aots[kscan][ipix][band];
493  }
494  avg_nLw /= ndets;
495  avg_aot /= ndets;
496  if (avg_nLw < 0)
497  avg_nLw = 0.0;
498  if (avg_aot < 0)
499  avg_aot = 0.0;
500 
501  tgrec->nLw[ipix * nbands + band] = avg_nLw;
502  aerec->taua[ipix * nbands + band] = avg_aot;
503  }
504 }
505 
516 calstr* alloc_calrec(int ydim, int nbands, int nprods, int nvar1d) {
517 
518  calstr* record = calloc(1, sizeof (calstr));
519  int band, prod;
520 
521  if ((record->Lt = (float **) malloc(nbands * sizeof (float *))) == NULL) {
522  printf("%s -Error: Cannot allocate memory to detector data\n",
523  __FILE__);
524  exit(FATAL_ERROR);
525  }
526  if ((record->vLt = (float **) malloc(nbands * sizeof (float *))) == NULL) {
527  printf("%s -Error: Cannot allocate memory to detector data\n",
528  __FILE__);
529  exit(FATAL_ERROR);
530  }
531 
532  if ((record->data = (float **) malloc(nprods * sizeof (float *))) == NULL) {
533  printf("%s -Error: Cannot allocate memory to detector data\n",
534  __FILE__);
535  exit(FATAL_ERROR);
536  }
537 
538  if ((record->vars1D = (float *) calloc(nvar1d, sizeof (float))) == NULL) {
539  printf("%s -Error: Cannot allocate memory to 1D data array\n",
540  __FILE__);
541  exit(FATAL_ERROR);
542  }
543 
544 
545  for (band = 0; band < nbands; band++) {
546  if ((record->Lt[band] = (float *) calloc(ydim, sizeof (float)))
547  == NULL) {
548  printf("%s -Error: Cannot allocate memory to detector data\n",
549  __FILE__);
550  exit(FATAL_ERROR);
551  }
552  if ((record->vLt[band] = (float *) calloc(ydim, sizeof (float)))
553  == NULL) {
554  printf("%s -Error: Cannot allocate memory to detector data\n",
555  __FILE__);
556  exit(FATAL_ERROR);
557  }
558 
559  }
560  for (prod = 0; prod < nprods; prod++) {
561  if ((record->data[prod] = (float *) calloc(ydim, sizeof (float)))
562  == NULL) {
563  printf("%s -Error: Cannot allocate memory to detector data\n",
564  __FILE__);
565  exit(FATAL_ERROR);
566  }
567  }
568  return record;
569 }
570 
578 void free_calrec(calstr *calrec, int nbands, int nprods) {
579  int band, prod;
580  for (band = 0; band < nbands; band++) {
581  free(calrec->Lt[band]);
582  free(calrec->vLt[band]);
583  }
584  for (prod = 0; prod < nprods; prod++) {
585  free(calrec->data[prod]);
586  }
587  free(calrec->Lt);
588  free(calrec->vLt);
589  free(calrec->data);
590  free(calrec->vars1D);
591 
592  free(calrec);
593 }
594 
599 void free_prodptr(l2prodstr **p) {
600  int i;
601  for (i = 0; i < L1_MAXPROD; i++) {
602  free(p[i]);
603  }
604  free(p);
605 }
606 
#define L1_MAXPROD
Definition: filehandle.h:20
int getDimsDS(idDS ds_id, const char sdsname[], int32_t dims[])
int j
Definition: decode_rs.h:73
caltype
Definition: calfile_utils.h:20
int status
Definition: l1_czcs_hdf.c:32
#define NBANDSIR
Definition: filehandle.h:23
idDS openDS(const char *filename)
Definition: wrapper.c:616
int16_t fileID
int calfile_write(idDS ds_id, calstr *calrec, int recnum, int ydim, int xdim, int nprods, int nbands, int nvars1d, char l2prods[L1_MAXPROD][32], char vars1Dnames[L1_MAXPROD][32], caltype ctype)
#define FAIL
Definition: ObpgReadGrid.h:18
float *** aots
#define MAX_NC_NAME
Definition: Granule.h:9
#define NULL
Definition: decode_rs.h:63
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second band
int createDS(idDS ds_id, int sensorId, const char *sname, int32_t dm[3], const char dm_name[3][80])
Definition: wrapper.c:344
instr * input
#define LIFE_IS_GOOD
Definition: passthebuck.h:4
#define DPTB(function)
Definition: passthebuck.h:24
@ CROSSCAL
Definition: calfile_utils.h:21
read recnum
char * readAttrStr(idDS ds_id, const char *name)
Definition: wrapper.c:102
productInfo_t * allocateProductInfo()
idDS startDS(const char *filename, ds_format_t format, ds_access_t accessmode, int32_t deflate)
Definition: wrapper.c:561
void free_prodptr(l2prodstr **p)
void free_calrec(calstr *calrec, int nbands, int nprods)
#define FATAL_ERROR
Definition: swl0_parms.h:5
int writeDS(idDS ds_id, const char *name, const void *data, int32_t s0, int32_t s1, int32_t s2, int32_t e0, int32_t e1, int32_t e2)
Definition: wrapper.c:475
float *** nlws
@ DS_NCDF
Definition: dfutils.h:20
#define PTB(function)
Definition: passthebuck.h:16
int readDS(idDS ds_id, const char *name, int32_t *start, int32_t *stride, int32_t *count, void *data)
@ BINMATCH
Definition: calfile_utils.h:21
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
@ DET2DET
Definition: calfile_utils.h:21
int SetI32GA(idDS ds_id, const char *name, int32_t value)
Definition: wrapper.c:326
#define basename(s)
Definition: l0chunk_modis.c:29
int findProductInfo(const char *productName, int sensorId, productInfo_t *info)
calstr * alloc_calrec(int ydim, int nbands, int nprods, int nvar1d)
void inversion_init(long ndets, long iscan, int nbands, long ipix, aestr *aerec, tgstr *tgrec)
int32_t nbands
const char * sensorId2SensorName(int sensorId)
Definition: sensorInfo.c:198
@ DS_WRITE
Definition: dfutils.h:25
int SetChrGA(idDS ds_id, const char *name, const char *value)
Definition: wrapper.c:236
int32_t iscan
void * scale_sds(float *data, productInfo_t *p, int32_t npix)
int32_t fid
Definition: dfutils.h:29
This should be set to the NetCDF standard name if exists for this product Create a function that computes your product edit get_myprod c add prototype to l12_proto h add get_myprod c to add_executable for l2gen and l3gen in CMakeLists txt Add an entry to the output routine to call your function edit prodgen c edit function prodgen() case CAT_myprod pbuf
int calfile_create(char *ofile, idDS *ds_id, int sensorID, int ydim, int xdim, int nprods, int nvars1d, char l2prods[L1_MAXPROD][32], char vars1Dnames[L1_MAXPROD][32], caltype ctype)
@ DS_HDF
Definition: dfutils.h:19
Definition: dfutils.h:28
int32_t rdsensorinfo(int32_t, int32_t, const char *, void **)
Definition: rdsensorinfo.c:69
int calfile_close(idDS ds_id)
int endDS(idDS ds_id)
Definition: wrapper.c:634
idDS calfile_open(char *ofile, int sensorID, int ydim, int xdim, int nprods, int nvars1d, char l2prods[L1_MAXPROD][32], char vars1Dnames[L1_MAXPROD][32], long *numExistingRecords, caltype ctype)
Definition: calfile_utils.c:48
int i
Definition: decode_rs.h:71
msiBandIdx val
Definition: l1c_msi.cpp:34
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 sensorID[MAXNFILES]
Definition: l2bin.cpp:97
float p[MODELMAX]
Definition: atrem_corl1.h:131
int32_t get_l2prod_index(const l2_prod &l2, const char *prodname)
Definition: l2bin.cpp:345
int count
Definition: decode_rs.h:79