Go to the documentation of this file.
9 int compute_l1b(int32 sd_id,
int iline,
float *l1b_data[],
char *calibtable,
char newfile) {
11 static int32
smsec, Nlines, Npixels;
14 static uint8 *sflags =
NULL;
16 static int32 sds_id,
start[6], edge[6];
18 int32 hdf_ind,
rank, dimsize[6], numtype, nattrs;
20 float32 *l1b_data_bip;
30 if (
read_attr(sd_id,
"Number of Scan Lines", &Nlines) == -1 ||
31 read_attr(sd_id,
"Pixels per Scan Line", &Npixels) == -1 ||
36 if ((hdf_ind = SDnametoindex(sd_id,
"l1a_data")) < 0) {
37 fprintf(
stderr,
"can't locate SDS l1a_data\n");
40 if ((sds_id = SDselect(sd_id, hdf_ind)) < 0) {
41 fprintf(
stderr,
"can't select SDS l1a_data\n");
44 if (SDgetinfo(sds_id,
name, &
rank, dimsize, &numtype, &nattrs) < 0) {
45 fprintf(
stderr,
"can't get info for SDS l1a_data\n");
54 msec = (int32 *) realloc(
msec, Nlines *
sizeof (int32));
55 sflags = (uint8 *) realloc(sflags, Nlines * 4 *
sizeof (uint8));
58 fprintf(
stderr,
"can't compute L1B data\n");
61 if (
read_sds(sd_id,
"s_flags", sflags) == -1)
return -1;
64 for (ib = 0; ib <
NBANDS; ib++) {
78 if (sflags[4 * iline] > 127) {
79 printf(
"Scan %d is corrupted. Skipped.\n", iline);
84 l1b_data_bip = (float32 *) malloc(Npixels *
NBANDS *
sizeof (float32));
86 if (SDreaddata(sds_id,
start,
NULL, edge, l1a_data_bip) < 0) {
87 fprintf(
stderr,
"can't read Level 1A data\n");
91 calibrate_l1a(calibtable,
syear,
sday,
smsec,
eday,
msec[iline],
dtype, 1, Npixels, &
dark_rest[iline *
NBANDS],
dark_mean, &
gain[iline *
NBANDS], &
tdi[iline *
NBANDS], &scan_temp[iline *
NBANDS],
side[iline], l1a_data_bip, l1b_data_bip,
NULL);
93 for (ib = 0; ib <
NBANDS; ib++)
95 for (ipix = 0; ipix < Npixels; ipix++)
96 l1b_data[ib][ipix] = l1b_data_bip[ipix *
NBANDS + ib];
int32 calibrate_l1a(char *cal_path, int16 syear, int16 sday, int32 smsec, int16 eday, int32 msec, char *dtype, int32 st_samp, int32 nsamp, int16 *dark_rest, float32 *dark_mean, int16 *gain, int16 *tdi, int16 *scan_temp, int16 side, int16 *l1a_data, float32 *l1b_data, cal_mod_struc *cal_mod)
int get_calib_sds(int32 sd_id, int16 *dark_rest, int16 *gain, int16 *tdi, int16 *scan_temp, int16 *side, int32 *msec)
int read_attr(int32 sd_id, char *attrname, void *attr)
int16_t tdi[BANDS_DIMS_1A]
void free_all(void *dark_rest, void *gain, void *tdi, void *scan_temp, void *side, void *msec)
Extra metadata that will be written to the HDF4 file l2prod rank
int compute_l1b(int32 sd_id, int iline, float *l1b_data[], char *calibtable, char newfile)
int32 read_sds(l1info_struct l1info, char *arr_name, int32 *exp_ntyp, void *array)