Go to the documentation of this file.
12 int load_fcal_lut(
char* calfile, int64_t UTC58usec,
double ****ftable) {
15 size_t ntimes,
nbands, ndets, nms;
16 size_t itime, iband, idet, ims;
17 int64_t *times =
NULL;
20 size_t start[] = {0, 0, 0, 0, 0};
21 size_t count[] = {2, 1, 1, 1, 1};
22 double flut_vals[] = {0, 0};
27 nc_open(calfile, NC_NOWRITE, &fileid));
33 nc_inq_varid(fileid,
"Beginning_Time_IET", &varid));
34 ntimes = vars[varid].
dim[0].
len;
36 times = vars[varid].
data;
39 if (UTC58usec < times[0]) {
41 printf(
"\n- W - %s, %d: WARNING: ", __FILE__, __LINE__);
42 printf(
"granule time of %ld ", (
long int) UTC58usec);
43 printf(
"is below F-table start time of %ld\n", (
long int) times[0]);
44 }
else if (UTC58usec > times[ntimes - 1]) {
46 printf(
"\n- W - %s, %d: WARNING: ", __FILE__, __LINE__);
47 printf(
"granule time of %ld ", (
long int) UTC58usec);
48 printf(
"is above F-table end time of %ld\n", (
long int) times[ntimes - 1]);
50 for (itime = 0; itime < ntimes - 1; itime++)
51 if (times[itime + 1] > UTC58usec)
57 (
double) (UTC58usec - times[itime]) /
58 (
double) (times[itime + 1] - times[itime]);
62 nc_inq_varid(fileid,
"VIIRS-SDR-F-LUT", &varid));
83 *ftable = (
double ***) malloc(
nbands *
sizeof (
double**));
84 for (iband = 0; iband <
nbands; iband++) {
85 ftable[0][iband] = (
double **) malloc(ndets *
sizeof (
double*));
86 for (idet = 0; idet < ndets; idet++)
87 ftable[0][iband][idet] = (
double *) malloc(nms *
sizeof (
double));
92 for (iband = 0; iband <
nbands; iband++) {
94 for (idet = 0; idet < ndets; idet++) {
96 for (ims = 0; ims < nms; ims++) {
100 nc_get_vars_double(fileid, varid,
103 ftable[0][iband][idet][ims] =
104 (flut_vals[0] * (1.0 - factor)) +
105 (flut_vals[1] * factor);
113 TRY_NC(__FILE__, __LINE__, nc_close(fileid));
#define TRY_NC(file, line, ncstat)
var_str_nc * load_vars_nc(int ncid)
integer, parameter double
int load_fcal_lut(char *calfile, int64_t UTC58usec, double ****ftable)
int readall_var(var_str_nc *var)