16 #include <gsl/gsl_spline2d.h>
20 #define NEW_CACHE_SIZE 10000000
21 #define NEW_CACHE_NELEMS 23
22 #define NEW_CACHE_PREEMPTION 1.0
24 #define BANDINFO_FILENAME_MERIS "band_info_meris.txt"
25 #define BANDINFO_FILENAME_OLCI "band_info_olci.txt"
27 #define ANGLE_FILL_VALUE (-999)
30 static int64_t *scan_start_tai;
31 static double lastvalidtime;
32 static int lastvalidscan = 0;
33 static vector<string> radFilename;
34 static vector<int32_t> radFileID;
35 static vector<string> radVarname;
36 static string geoCoordinatesFilename, tieGeometriesFilename, instrumentFilename, timeCoordinatesFilename, qualityFlagsFilename;
37 static int32_t geoCoordinatesFileID, tieGeometriesFileID, instrumentFileID, timeCoordinatesFileID, qualityFileID;
41 size_t source_w, source_h, source_b;
43 int xid, yid, bid, retval, sds_id;
46 unsigned short orbit_number;
50 string tmpStr =
l1file->name;
51 size_t pos = tmpStr.rfind(
'/');
52 if(
pos != string::npos) {
53 indirStr = tmpStr.substr(0,
pos+1);
56 instrumentFilename = indirStr +
"instrument_data.nc";
57 timeCoordinatesFilename = indirStr +
"time_coordinates.nc";
58 geoCoordinatesFilename = indirStr +
"geo_coordinates.nc";
59 tieGeometriesFilename = indirStr +
"tie_geometries.nc";
60 qualityFlagsFilename = indirStr +
"qualityFlags.nc";
63 radFilename.resize(
l1file->nbands);
64 radFileID.resize(
l1file->nbands);
65 radVarname.resize(
l1file->nbands);
68 string numStr = to_string(
i+1);
69 if(numStr.size() == 1)
70 numStr = (
string)
"0" + numStr;
72 radFilename[
i] = indirStr +
"M" + numStr +
"_radiance.nc";
74 radFilename[
i] = indirStr +
"Oa" + numStr +
"_radiance.nc";
77 printf(
"SAFE rad=%s\n", radFilename[
i].c_str());
83 fprintf(
stderr,
"-E- %s line %d: nc_set_chunk_cache (%s) failed.\n",
84 __FILE__, __LINE__,
l1file->name);
87 retval = nc_open(instrumentFilename.c_str(), NC_NOWRITE, &instrumentFileID);
88 if (retval != NC_NOERR) {
89 fprintf(
stderr,
"-E- %s line %d: nc_open(%s) failed.\n",
90 __FILE__, __LINE__, instrumentFilename.c_str());
95 DPTB(nc_inq_dimid(instrumentFileID,
"rows", &yid));
96 DPTB(nc_inq_dimid(instrumentFileID,
"columns", &xid));
97 DPTB(nc_inq_dimid(instrumentFileID,
"bands", &bid));
98 DPTB(nc_inq_dimlen(instrumentFileID, xid, &source_w));
99 DPTB(nc_inq_dimlen(instrumentFileID, yid, &source_h));
100 DPTB(nc_inq_dimlen(instrumentFileID, bid, &source_b));
101 if (source_b != (
size_t)
l1file->nbands) {
102 fprintf(
stderr,
"-E- %s line %d: num bands (%d) does not match expected SAFE num bands (%d).\n",
103 __FILE__, __LINE__, (
int) source_b,
l1file->nbands);
107 DPTB(nc_get_att_ushort(instrumentFileID, NC_GLOBAL,
"absolute_orbit_number", &orbit_number));
108 DPTB(nc_inq_attlen(instrumentFileID, NC_GLOBAL,
"product_name", &attrLength));
109 char* productName = (
char*)
allocateMemory(attrLength + 1,
"product_name");
110 DPTB(nc_get_att_text(instrumentFileID, NC_GLOBAL,
"product_name", productName));
111 if (strstr(productName,
"ME_1_FRG")) {
113 }
else if (strstr(productName,
"ME_1_RRG")) {
115 }
else if (strstr(productName,
"OL_1_EFR")) {
117 }
else if (strstr(productName,
"OL_1_ERR")) {
120 fprintf(
stderr,
"-E- %s line %d: nc_open(%s) illegal product = \"%s\".\n",
121 __FILE__, __LINE__,
l1file->name, productName);
131 npix = (int32_t) source_w;
132 nscan = (int32_t) source_h;
134 l1file->orbit_number = orbit_number;
135 l1file->nbands = source_b;
139 scan_start_tai = (int64_t *) calloc(
nscan,
sizeof (int64_t));
144 retval = nc_open(timeCoordinatesFilename.c_str(), NC_NOWRITE, &timeCoordinatesFileID);
145 if (retval != NC_NOERR) {
146 fprintf(
stderr,
"-E- %s line %d: nc_open(%s) failed.\n",
147 __FILE__, __LINE__, timeCoordinatesFilename.c_str());
151 DPTB(nc_inq_varid(timeCoordinatesFileID,
"time_stamp", &sds_id));
152 DPTB(nc_get_vara_long(timeCoordinatesFileID, sds_id,
start,
count, (
long*) scan_start_tai));
154 retval = nc_open(geoCoordinatesFilename.c_str(), NC_NOWRITE, &geoCoordinatesFileID);
155 if (retval != NC_NOERR) {
156 fprintf(
stderr,
"-E- %s line %d: nc_open(%s) failed.\n",
157 __FILE__, __LINE__, geoCoordinatesFilename.c_str());
161 retval = nc_open(tieGeometriesFilename.c_str(), NC_NOWRITE, &tieGeometriesFileID);
162 if (retval != NC_NOERR) {
163 fprintf(
stderr,
"-E- %s line %d: nc_open(%s) failed.\n",
164 __FILE__, __LINE__, tieGeometriesFilename.c_str());
168 retval = nc_open(qualityFlagsFilename.c_str(), NC_NOWRITE, &qualityFileID);
169 if (retval != NC_NOERR) {
170 fprintf(
stderr,
"-E- %s line %d: nc_open(%s) failed.\n",
171 __FILE__, __LINE__, qualityFlagsFilename.c_str());
177 retval = nc_open(radFilename[
i].c_str(), NC_NOWRITE, &radFileID[
i]);
178 if (retval != NC_NOERR) {
180 "-E- %s line %d: nc_open failed for file, %s.\n",
181 __FILE__, __LINE__, radFilename[
i].c_str());
184 string numStr = to_string(
i+1);
185 if(numStr.size() == 1)
186 numStr = (
string)
"0" + numStr;
188 radVarname[
i] = (
string)
"M" + numStr +
"_radiance";
190 radVarname[
i] = (
string)
"Oa" + numStr +
"_radiance";
197 static int firstCall = 1;
198 static double time_interval;
199 static double tai93at2000;
200 static int32_t *
lon, *
lat;
201 static int32_t lonFillValue, latFillValue;
202 static int longitudeVarID, latitudeVarID;
203 static int solaVarID, solzVarID, senaVarID, senzVarID;
204 static double scale_lon, scale_lat;
205 static double scale_solz, scale_sola, scale_senz, scale_sena;
206 static int detectorIndexVarID;
207 static int16_t *detector_index;
208 static uint32_t *qualityFlags;
209 static vector<int> radVarID;
210 static vector<float> radScale;
211 static vector<float> radOffset;
212 static vector<uint16_t> radFillValue;
214 static float *lambda0, *solar_flux;
216 static uint16_t *rad_data;
217 static size_t num_tie_cols, num_tie_rows;
218 static uint16_t tie_row_subsample, tie_col_subsample;
220 static double *solz_xa, *solz_ya, *solz_za;
221 static double *sola_x_xa, *sola_x_ya, *sola_x_za;
222 static double *sola_y_xa, *sola_y_ya, *sola_y_za;
223 static double *senz_xa, *senz_ya, *senz_za;
224 static double *sena_x_xa, *sena_x_ya, *sena_x_za;
225 static double *sena_y_xa, *sena_y_ya, *sena_y_za;
226 static gsl_spline2d *solz_spline;
227 static gsl_spline2d *sola_x_spline;
228 static gsl_spline2d *sola_y_spline;
229 static gsl_spline2d *senz_spline;
230 static gsl_spline2d *sena_x_spline;
231 static gsl_spline2d *sena_y_spline;
232 static gsl_interp_accel *solz_xacc, *solz_yacc;
233 static gsl_interp_accel *sola_x_xacc, *sola_x_yacc;
234 static gsl_interp_accel *sola_y_xacc, *sola_y_yacc;
235 static gsl_interp_accel *senz_xacc, *senz_yacc;
236 static gsl_interp_accel *sena_x_xacc, *sena_x_yacc;
237 static gsl_interp_accel *sena_y_xacc, *sena_y_yacc;
239 float *detectorTmpFloat;
252 printf(
"file->nbands = %d, l1rec->nbands = %d\n",
253 (
int)
file->nbands, (
int)
l1rec->l1file->nbands);
259 radFillValue.resize(
nbands);
265 DPTB(nc_inq_dimid(tieGeometriesFileID,
"tie_columns", &xid));
266 DPTB(nc_inq_dimlen(tieGeometriesFileID, xid, &num_tie_cols));
267 DPTB(nc_inq_dimid(tieGeometriesFileID,
"tie_rows", &yid));
268 DPTB(nc_inq_dimlen(tieGeometriesFileID, yid, &num_tie_rows));
269 DPTB(nc_get_att_ushort(tieGeometriesFileID, NC_GLOBAL,
"ac_subsampling_factor", &tie_col_subsample));
270 DPTB(nc_get_att_ushort(tieGeometriesFileID, NC_GLOBAL,
"al_subsampling_factor", &tie_row_subsample));
272 if (((num_tie_rows-1) * tie_row_subsample + 1) != (
size_t)
file->nscan) {
273 printf(
"-E- %s line %d: Sanity check failed - tie_rows (%d) x tie_row_pts (%d) < nscan (%d) in file %s\n",
274 __FILE__, __LINE__, (
int) num_tie_rows, tie_row_subsample,
file->nscan, tieGeometriesFilename.c_str());
277 if (((num_tie_cols - 1) * tie_col_subsample + 1) != (
size_t)
file->npix) {
278 printf(
"-E- %s line %d: Sanity check failed - tie_cols (%d) x tie_col_pts (%d) != npix (%d) in file %s\n",
279 __FILE__, __LINE__, (
int) num_tie_cols, tie_col_subsample,
file->nscan, tieGeometriesFilename.c_str());
283 lon = (int32_t *) calloc(
npix,
sizeof (int32_t));
284 lat = (int32_t *) calloc(
npix,
sizeof (int32_t));
286 detector_index = (int16_t*) calloc(
npix,
sizeof (int16_t));
287 qualityFlags = (uint32_t*) calloc(
npix,
sizeof (uint32_t));
289 DPTB(nc_inq_dimid(instrumentFileID,
"detectors", &xid));
296 rad_data = (
unsigned short *) calloc(
npix,
sizeof (
unsigned short));
306 retval = nc_inq_varid(instrumentFileID,
"lambda0", &xid);
307 if (retval != NC_NOERR) {
309 "-E- %s line %d: nc_get_varid failed for file, %s field, %s.\n",
310 __FILE__, __LINE__, instrumentFilename.c_str(),
"lambda0");
313 retval = nc_get_vara_float(instrumentFileID, xid,
start,
count, detectorTmpFloat);
314 if (retval != NC_NOERR) {
316 "-E- %s line %d: nc_get_vara_float failed for file, %s field, %s.\n",
317 __FILE__, __LINE__, instrumentFilename.c_str(),
"lambda0");
325 retval = nc_inq_varid(instrumentFileID,
"solar_flux", &xid);
326 if (retval != NC_NOERR) {
328 "-E- %s line %d: nc_get_vara_float failed for file, %s field, %s.\n",
329 __FILE__, __LINE__, instrumentFilename.c_str(),
"solar_flux");
332 retval = nc_get_vara_float(instrumentFileID, xid,
start,
count, detectorTmpFloat);
333 if (retval != NC_NOERR) {
335 "-E- %s line %d: nc_get_vara_float failed for file, %s field, %s.\n",
336 __FILE__, __LINE__, instrumentFilename.c_str(),
"solar_flux");
343 free(detectorTmpFloat);
347 if ((tmp_str = getenv(
"OCDATAROOT")) ==
NULL) {
348 printf(
"OCDATAROOT environment variable is not defined.\n");
367 DPTB(nc_inq_varid(geoCoordinatesFileID,
"longitude", &longitudeVarID));
368 DPTB(nc_get_att_double(geoCoordinatesFileID, longitudeVarID,
"scale_factor", &scale_lon));
369 lonFillValue = -2147483648;
370 retval = nc_get_att_int(geoCoordinatesFileID, longitudeVarID,
"_FillValue", &lonFillValue);
371 DPTB(nc_inq_varid(geoCoordinatesFileID,
"latitude", &latitudeVarID));
372 DPTB(nc_get_att_double(geoCoordinatesFileID, latitudeVarID,
"scale_factor", &scale_lat));
373 latFillValue = -2147483648;
374 retval = nc_get_att_int(geoCoordinatesFileID, latitudeVarID,
"_FillValue", &latFillValue);
376 DPTB(nc_inq_varid(tieGeometriesFileID,
"SAA", &solaVarID));
377 DPTB(nc_get_att_double(tieGeometriesFileID, solaVarID,
"scale_factor", &scale_sola));
378 DPTB(nc_inq_varid(tieGeometriesFileID,
"SZA", &solzVarID));
379 DPTB(nc_get_att_double(tieGeometriesFileID, solzVarID,
"scale_factor", &scale_solz));
381 DPTB(nc_inq_varid(tieGeometriesFileID,
"OAA", &senaVarID));
382 DPTB(nc_get_att_double(tieGeometriesFileID, senaVarID,
"scale_factor", &scale_sena));
383 DPTB(nc_inq_varid(tieGeometriesFileID,
"OZA", &senzVarID));
384 DPTB(nc_get_att_double(tieGeometriesFileID, senzVarID,
"scale_factor", &scale_senz));
386 DPTB(nc_inq_varid(instrumentFileID,
"detector_index", &detectorIndexVarID));
388 for (ib = 0; ib <
nbands; ib++) {
389 retval = nc_inq_varid(radFileID[ib], radVarname[ib].c_str(), &radVarID[ib]);
390 if (retval != NC_NOERR) {
392 "-E- %s line %d: nc_inq_varid failed for file=%s, field=%s.\n",
393 __FILE__, __LINE__, radFilename[ib].c_str(), radVarname[ib].c_str());
396 retval = nc_get_att_float(radFileID[ib], radVarID[ib],
"scale_factor", &radScale[ib]);
397 if (retval != NC_NOERR) {
399 "-E- %s line %d: nc_get_att_float failed for file=%s, field=%s, attribute=scale_factor.\n",
400 __FILE__, __LINE__, radFilename[ib].c_str(), radVarname[ib].c_str());
403 retval = nc_get_att_float(radFileID[ib], radVarID[ib],
"add_offset", &radOffset[ib]);
404 if (retval != NC_NOERR) {
406 "-E- %s line %d: nc_get_att_float failed for file=%s, field=%s, attribute=add_offset.\n",
407 __FILE__, __LINE__, radFilename[ib].c_str(), radVarname[ib].c_str());
410 retval = nc_get_att_ushort(radFileID[ib], radVarID[ib],
"_FillValue", &radFillValue[ib]);
411 if (retval != NC_NOERR) {
413 "-E- %s line %d: nc_get_att_float failed for file=%s, field=%s, attribute=_FillValue.\n",
414 __FILE__, __LINE__, radFilename[ib].c_str(), radVarname[ib].c_str());
420 int num_tie_points = num_tie_cols * num_tie_rows;
421 int32_t *tmp_int = (int32_t*)
allocateMemory(num_tie_points *
sizeof(int32_t),
"tmp_int array for sol and sen");
422 uint32_t *tmp_uint = (uint32_t*) tmp_int;
424 solz_xa = (
double*)
allocateMemory(num_tie_cols *
sizeof(
double),
"solz_xa");
425 solz_ya = (
double*)
allocateMemory(num_tie_rows *
sizeof(
double),
"solz_ya");
426 solz_za = (
double*)
allocateMemory(num_tie_points *
sizeof(
double),
"solz_za");
427 sola_x_xa = (
double*)
allocateMemory(num_tie_cols *
sizeof(
double),
"sola_pos_xa");
428 sola_x_ya = (
double*)
allocateMemory(num_tie_rows *
sizeof(
double),
"sola_pos_ya");
429 sola_x_za = (
double*)
allocateMemory(num_tie_points *
sizeof(
double),
"sola_pos_za");
430 sola_y_xa = (
double*)
allocateMemory(num_tie_cols *
sizeof(
double),
"sola_neg_xa");
431 sola_y_ya = (
double*)
allocateMemory(num_tie_rows *
sizeof(
double),
"sola_neg_ya");
432 sola_y_za = (
double*)
allocateMemory(num_tie_points *
sizeof(
double),
"sola_neg_za");
433 senz_xa = (
double*)
allocateMemory(num_tie_cols *
sizeof(
double),
"senz_xa");
434 senz_ya = (
double*)
allocateMemory(num_tie_rows *
sizeof(
double),
"senz_ya");
435 senz_za = (
double*)
allocateMemory(num_tie_points *
sizeof(
double),
"senz_za");
436 sena_x_xa = (
double*)
allocateMemory(num_tie_cols *
sizeof(
double),
"sena_pos_xa");
437 sena_x_ya = (
double*)
allocateMemory(num_tie_rows *
sizeof(
double),
"sena_pos_ya");
438 sena_x_za = (
double*)
allocateMemory(num_tie_points *
sizeof(
double),
"sena_pos_za");
439 sena_y_xa = (
double*)
allocateMemory(num_tie_cols *
sizeof(
double),
"sena_neg_xa");
440 sena_y_ya = (
double*)
allocateMemory(num_tie_rows *
sizeof(
double),
"sena_neg_ya");
441 sena_y_za = (
double*)
allocateMemory(num_tie_points *
sizeof(
double),
"sena_neg_za");
443 for(
size_t i=0;
i<num_tie_cols;
i++) {
450 index += tie_col_subsample;
453 for(
size_t i=0;
i<num_tie_rows;
i++) {
460 index += tie_row_subsample;
462 DPTB(nc_get_var_uint(tieGeometriesFileID, solzVarID, tmp_uint));
463 for(
int i=0;
i<num_tie_points;
i++) {
464 solz_za[
i] = tmp_uint[
i] * scale_solz;
466 DPTB(nc_get_var_int(tieGeometriesFileID, solaVarID, tmp_int));
467 for(
int i=0;
i<num_tie_points;
i++) {
468 double angle = tmp_int[
i] * scale_sola /
RADEG;
469 sola_x_za[
i] = cos(angle);
470 sola_y_za[
i] = sin(angle);
472 DPTB(nc_get_var_uint(tieGeometriesFileID, senzVarID, tmp_uint));
473 for(
int i=0;
i<num_tie_points;
i++) {
474 senz_za[
i] = tmp_uint[
i] * scale_senz;
476 DPTB(nc_get_var_int(tieGeometriesFileID, senaVarID, tmp_int));
477 for(
int i=0;
i<num_tie_points;
i++) {
478 double angle = tmp_int[
i] * scale_sena /
RADEG;
479 sena_x_za[
i] = cos(angle);
480 sena_y_za[
i] = sin(angle);
482 const gsl_interp2d_type *splineType = gsl_interp2d_bilinear;
484 solz_spline = gsl_spline2d_alloc(splineType, num_tie_cols, num_tie_rows);
485 sola_x_spline = gsl_spline2d_alloc(splineType, num_tie_cols, num_tie_rows);
486 sola_y_spline = gsl_spline2d_alloc(splineType, num_tie_cols, num_tie_rows);
487 senz_spline = gsl_spline2d_alloc(splineType, num_tie_cols, num_tie_rows);
488 sena_x_spline = gsl_spline2d_alloc(splineType, num_tie_cols, num_tie_rows);
489 sena_y_spline = gsl_spline2d_alloc(splineType, num_tie_cols, num_tie_rows);
490 solz_xacc = gsl_interp_accel_alloc();
491 solz_yacc = gsl_interp_accel_alloc();
492 sola_x_xacc = gsl_interp_accel_alloc();
493 sola_x_yacc = gsl_interp_accel_alloc();
494 sola_y_xacc = gsl_interp_accel_alloc();
495 sola_y_yacc = gsl_interp_accel_alloc();
496 senz_xacc = gsl_interp_accel_alloc();
497 senz_yacc = gsl_interp_accel_alloc();
498 sena_x_xacc = gsl_interp_accel_alloc();
499 sena_x_yacc = gsl_interp_accel_alloc();
500 sena_y_xacc = gsl_interp_accel_alloc();
501 sena_y_yacc = gsl_interp_accel_alloc();
502 gsl_spline2d_init(solz_spline, solz_xa, solz_ya, solz_za, num_tie_cols, num_tie_rows);
503 gsl_spline2d_init(sola_x_spline, sola_x_xa, sola_x_ya, sola_x_za, num_tie_cols, num_tie_rows);
504 gsl_spline2d_init(sola_y_spline, sola_y_xa, sola_y_ya, sola_y_za, num_tie_cols, num_tie_rows);
505 gsl_spline2d_init(senz_spline, senz_xa, senz_ya, senz_za, num_tie_cols, num_tie_rows);
506 gsl_spline2d_init(sena_x_spline, sena_x_xa, sena_x_ya, sena_x_za, num_tie_cols, num_tie_rows);
507 gsl_spline2d_init(sena_y_spline, sena_y_xa, sena_y_ya, sena_y_za, num_tie_cols, num_tie_rows);
514 if (scan_start_tai[
scan] > 0) {
516 lastvalidtime =
l1rec->scantime;
518 time_interval = (scan_start_tai[
scan] - lastvalidtime) / (
scan - lastvalidscan);
519 lastvalidscan =
scan;
521 l1rec->scantime = lastvalidtime + (time_interval * (
scan - lastvalidscan));
522 lastvalidtime =
l1rec->scantime;
531 int32_t
msec = (int32_t) (secs * 1000.0);
543 for (ip = 0; ip <
npix; ip++) {
544 l1rec->navfail[ip] = 0;
554 retval = nc_get_vara_int(geoCoordinatesFileID, longitudeVarID,
start,
count,
lon);
555 if (retval != NC_NOERR) {
557 "-E- %s line %d: nc_get_vara_float failed for file, %s field, %s.\n",
558 __FILE__, __LINE__, geoCoordinatesFilename.c_str(),
"longitude");
561 retval = nc_get_vara_int(geoCoordinatesFileID, latitudeVarID,
start,
count,
lat);
562 if (retval != NC_NOERR) {
564 "-E- %s line %d: nc_get_vara_float failed for file, %s field, %s.\n",
565 __FILE__, __LINE__, geoCoordinatesFilename.c_str(),
"lat");
568 retval = nc_get_vara_short(instrumentFileID, detectorIndexVarID,
start,
count, detector_index);
569 if (retval != NC_NOERR) {
571 "-E- %s line %d: nc_get_vara_short failed for file, %s field, %s.\n",
572 __FILE__, __LINE__, instrumentFilename.c_str(),
"detector_index");
575 for (ip = 0; ip <
npix; ip++) {
576 l1rec->pixnum[ip] = ip;
577 l1rec->flags[ip] = 0;
578 l1rec->pixdet[ip] = detector_index[ip];
579 if(
lon[ip] == lonFillValue ||
lat[ip] == latFillValue) {
581 l1rec->navfail[ip] = 1;
583 l1rec->lon[ip] =
lon[ip] * scale_lon;
584 l1rec->lat[ip] =
lat[ip] * scale_lat;
588 retval = nc_inq_varid(qualityFileID,
"quality_flags", &xid);
589 if (retval != NC_NOERR) {
591 "-E- %s line %d: nc_get_varid failed for file, %s field, %s.\n",
592 __FILE__, __LINE__, qualityFlagsFilename.c_str(),
"quality_flags");
595 retval = nc_get_vara_uint(qualityFileID, xid,
start,
count, qualityFlags);
596 if (retval != NC_NOERR) {
598 "-E- %s line %d: nc_get_vara_uint failed for file, %s field, %s.\n",
599 __FILE__, __LINE__, qualityFlagsFilename.c_str(),
"quality_flags");
604 for (ib = 0; ib <
nbands; ib++) {
605 retval = nc_get_vara_ushort(radFileID[ib], radVarID[ib],
start,
count, rad_data);
606 if (retval != NC_NOERR) {
608 "-E- %s line %d: nc_get_vara_float failed for file, %s field, %s.\n",
609 __FILE__, __LINE__, radFilename[ib].c_str(), radVarname[ib].c_str());
613 for (ip = 0; ip <
npix; ip++) {
615 if(rad_data[ip] == radFillValue[ib]) {
617 l1rec->navfail[ip] = 1;
619 l1rec->Lt[ipb] = (rad_data[ip] * radScale[ib] + radOffset[ib]) / 10.;
622 if (
l1rec->Lt[ipb] < 0.0)
628 for (ip = 0; ip <
npix; ip++) {
630 l1rec->solz[ip] = gsl_spline2d_eval(solz_spline, ip,
scan, solz_xacc, solz_yacc);
631 x = gsl_spline2d_eval(sola_x_spline, ip,
scan, sola_x_xacc, sola_x_yacc);
632 y = gsl_spline2d_eval(sola_y_spline, ip,
scan, sola_y_xacc, sola_y_yacc);
634 l1rec->senz[ip] = gsl_spline2d_eval(senz_spline, ip,
scan, senz_xacc, senz_yacc);
635 x = gsl_spline2d_eval(sena_x_spline, ip,
scan, sena_x_xacc, sena_x_yacc);
636 y = gsl_spline2d_eval(sena_y_spline, ip,
scan, sena_y_xacc, sena_y_yacc);
641 uint32_t
isLand = qualityFlags[ip] & 2147483648;
644 for (ib = 0; ib <
nbands; ib++) {
645 if(
l1rec->navfail[ip] != 1) {
654 l1rec->l1file->terrain_corrected = 1;
662 free(scan_start_tai);
664 DPTB(nc_close(instrumentFileID));
665 DPTB(nc_close(timeCoordinatesFileID));
666 DPTB(nc_close(geoCoordinatesFileID));
667 DPTB(nc_close(tieGeometriesFileID));
668 DPTB(nc_close(qualityFileID));
669 for (
i = 0;
i <
file->nbands;
i++) {
670 DPTB(nc_close(radFileID[
i]));