Go to the documentation of this file.
15 #define LAC_PIXEL_NUM 1285
16 #define GAC_PIXEL_NUM 248
17 #define NREC_IN_BUF 10
21 #define MASK_HIGHLT1 16
22 #define GENBUFSIZ NREC_IN_BUF*sizeof(float)*40
107 int16_t scan_temp[8];
111 float sen_mat[3 * 3];
118 int32_t
get_l1a_rec(int32_t sd_id, int32_t recno, cal_mod_struc *cal_mod,
119 int16_t *l1a_dum,
float **l1b_data, int16_t **l2_flags) {
126 int32_t
start[3] = {0, 0, 0};
133 float Styp_frac = 0.9;
142 static int32_t crec = -1;
143 static int16_t recursive_flag = 0;
144 static int16_t n_read = 0;
145 static int32_t max_rec_in_rdbuf;
148 static int32_t stray_light_scan_no;
150 static float *st_l1b_data;
151 static int16_t *st_l2_flags;
153 static int32_t initial = 1;
154 static byte first = 1;
167 if (first || recno < crec) {
168 max_rec_in_rdbuf = recno - 1;
169 stray_light_scan_no = recno;
174 if (crec >
nscan)
return 0;
177 if (crec > max_rec_in_rdbuf) {
192 for (irec = 0; irec < n_read; irec++) {
193 start[0] = recno - 1 + irec;
194 SDreaddata(SDselect(sd_id, SDnametoindex(sd_id,
"l1a_data")),
196 for (ipix = 0; ipix <
npix; ipix++)
197 for (idet = 0; idet < 8; idet++)
199 band_buf[ipix * 8 + idet];
203 rdSDS(sd_id,
"gain", recno - 1, 0, n_read, 8, (VOIDP) genBuf);
204 for (
i = 0;
i < n_read;
i++)
205 memcpy(&rdBuf[
i].
gain, &genBuf[
i * 8 * 2], 8 * 2);
207 rdSDS(sd_id,
"tdi", recno - 1, 0, n_read, 8, (VOIDP) genBuf);
208 for (
i = 0;
i < n_read;
i++)
209 memcpy(&rdBuf[
i].
tdi, &genBuf[
i * 8 * 2], 8 * 2);
211 rdSDS(sd_id,
"scan_temp", recno - 1, 0, n_read, 8, (VOIDP) genBuf);
212 for (
i = 0;
i < n_read;
i++)
213 memcpy(&rdBuf[
i].scan_temp, &genBuf[
i * 8 * 2], 8 * 2);
215 rdSDS(sd_id,
"inst_ana", recno - 1, 0, n_read, 40, (VOIDP) genBuf);
216 for (
i = 0;
i < n_read;
i++)
217 memcpy(&rdBuf[
i].inst_temp, &genBuf[
i * 40 * 4], 40 * 4);
219 rdSDS(sd_id,
"orb_vec", recno - 1, 0, n_read, 3, (VOIDP) genBuf);
220 for (
i = 0;
i < n_read;
i++)
221 memcpy(&rdBuf[
i].orb_vec, &genBuf[
i * 3 * 4], 3 * 4);
223 rdSDS(sd_id,
"sun_ref", recno - 1, 0, n_read, 3, (VOIDP) genBuf);
224 for (
i = 0;
i < n_read;
i++)
225 memcpy(&rdBuf[
i].sun_ref, &genBuf[
i * 3 * 4], 3 * 4);
227 rdSDS(sd_id,
"scan_ell", recno - 1, 0, n_read, 6, (VOIDP) genBuf);
228 for (
i = 0;
i < n_read;
i++)
229 memcpy(&rdBuf[
i].
scan_ell, &genBuf[
i * 6 * 4], 6 * 4);
232 start[0] = recno - 1;
237 SDreaddata(SDselect(sd_id, SDnametoindex(sd_id,
"sen_mat")),
239 for (
i = 0;
i < n_read;
i++)
240 memcpy(&rdBuf[
i].sen_mat, &genBuf[
i * 9 * 4], 9 * 4);
243 offset = max_rec_in_rdbuf + 1;
244 max_rec_in_rdbuf += n_read;
247 if ((crec -
offset) >= 0) {
250 gain_ptr = rdBuf[
j].
gain;
256 rdBuf[
j].scan_temp, rdBuf[
j].inst_temp,
side[recno - 1],
266 if (!recursive_flag) {
275 gain_ptr = bkBuf[
j].
gain;
278 if (!recursive_flag) {
292 if (!recursive_flag) {
293 for (ipix = 0; ipix <
npix; ipix++) {
297 for (idet = 6; (idet < 8)&&(hi_Lt[ipix] ==
FALSE); idet++) {
298 pixvalue = l1a_ptr[ipix +
npix * idet];
304 hi_Lt[ipix] = ((pixvalue - pixdark) >= kneevalue);
315 for (ipix = 0; ipix <
npix; ipix++)
318 }
else if (!recursive_flag) {
321 if (stray_light_scan_no != scan_no) {
326 l1a_dum, &st_l1b_data, &st_l2_flags);
339 for (ipix = 0; ipix <
npix; ipix++) {
375 "-E %s Line %d: Error opening %s for reading.\n",
376 __FILE__, __LINE__,
file->name);
408 if (strcmp(
dtype,
"GAC") == 0)
417 if (cal_path ==
NULL) {
419 "-E %s Line %d: No calibration file specified.\n",
440 "-E- %s line %d: Error applying calibration table \"%s\".\n",
441 __FILE__, __LINE__, cal_path);
454 if (strcmp(
dtype,
"GAC") == 0)
465 msec = (int32_t *) calloc(
nscan,
sizeof (int32_t));
467 side = (int16_t *) calloc(
nscan,
sizeof (int16_t));
475 tilt = (
float *) calloc(
nscan,
sizeof (
float));
489 static cal_mod_struc cal_mod;
490 static int16_t *l2_flags;
491 static float *l1b_data;
496 int32_t nwave =
l1rec->l1file->nbands;
497 int32_t *
bindx = (int32_t*)
l1rec->l1file->bindx;
505 int16_t *l1a_dum =
NULL;
507 static int32_t prev_recnum = -1;
509 static int16_t first = 1;
510 static int32_t ntilts;
511 static int16_t tilt_flags[20];
512 static int16_t tilt_ranges[2 * 20];
520 printf(
"Reading out-of-sequence %d %d\n",
recnum, prev_recnum);
529 status =
rdSDS(
file->sd_id,
"tilt_flags", 0, 0, 0, 0, (VOIDP) tilt_flags);
530 status =
rdSDS(
file->sd_id,
"tilt_ranges", 0, 0, 0, 0, (VOIDP) tilt_ranges);
537 for (
i = 0;
i < ntilts;
i++) {
538 if (tilt_ranges[2 *
i] <=
recnum + 1 && tilt_ranges[2 *
i + 1] >=
recnum)
558 for (
i = prev_recnum + 1;
i <=
recnum;
i++)
560 &l1b_data, &l2_flags);
576 for (ipix = 0; ipix <
file->npix; ipix++) {
577 if (
l1rec->sena[ipix] > 180) {
578 l1rec->sena[ipix] -= 360.0;
580 if (
l1rec->sola[ipix] > 180) {
581 l1rec->sola[ipix] -= 360.0;
584 for (iw = 0; iw < nwave; iw++) {
586 l1rec->Lt [ipix * nwave + ib] = l1b_data[iw *
npix + ipix];
589 l1rec->hilt [ipix] = ((l2_flags[ipix] &
HILT) > 0);
590 l1rec->navwarn[ipix] = (nflag[7] & 1) | (nflag[0] & 1);
603 if (
day > (365 + (
year % 4 == 0))) {
636 SDreaddata(SDselect(
file->sd_id, SDnametoindex(
file->sd_id,
"sen_mat")),
float rads[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
double fp_tcorr[BANDS_DIMS_1A]
float sola[LAC_PIXEL_NUM]
float cal_rads[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
int rdSDS(int32_t fileID, const char sdsname[], int32_t start1, int32_t start2, int32_t edges1, int32_t edges2, void *array_data)
double t_const[BANDS_DIMS_1A]
double yds2unix(int16_t year, int16_t day, double secs)
double ms2_const[BANDS_DIMS_1A]
void geonav_lonlat_(float *orb_vec, float *sen_mat, float *scan_ell, float *sun_ref, int32_t *nsta, int32_t *ninc, int32_t *npix, float ylat[], float xlon[])
void read_caltable(char *cal_path)
int geonav_(FLOAT32 pos[3], FLOAT32 rm[3][3], FLOAT32 coef[6], FLOAT32 sunref[3], INT32 *spix, INT32 *ipix, INT32 *npix, FLOAT32 lat[], FLOAT32 lon[], FLOAT32 solz[], FLOAT32 sola[], FLOAT32 senz[], FLOAT32 sena[])
float pcal_rads[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
float ylat[LAC_PIXEL_NUM]
float pcal_counts[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
double fp_tref[BANDS_DIMS_1A]
int32_t get_l1a_rec(int32_t sd_id, int32_t recno, cal_mod_struc *cal_mod, int16_t *l1a_dum, float **l1b_data, int16_t **l2_flags)
short l2_flags_buffer[LAC_PIXEL_NUM]
double ms2_linear_2[BANDS_DIMS_1A]
int openl1a_seawifs(filehandle *file)
double t_linear_1[BANDS_DIMS_1A]
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed file
int readl1a_seawifs(filehandle *file, int32_t recnum, l1str *l1rec)
double t_exponential_1[BANDS_DIMS_1A]
double cal_offs[BANDS_DIMS_1A]
double t_linear_2[BANDS_DIMS_1A]
double zulu2unix(char *zulu)
float sena[LAC_PIXEL_NUM]
double ms2_exponential_2[BANDS_DIMS_1A]
double inst_tcorr[BANDS_DIMS_1A]
float solz[LAC_PIXEL_NUM]
int getHDFattr(int32_t fileID, const char attrname[], const char sdsname[], void *data)
int16_t tdi[BANDS_DIMS_1A]
integer, parameter double
int readl1a_lonlat_seawifs(filehandle *file, int32_t recnum, l1str *l1rec)
float fp_temps[256][BANDS_DIMS_1A]
double inst_tref[BANDS_DIMS_1A]
float xlon[LAC_PIXEL_NUM]
int closel1a_seawifs(filehandle *file)
double ms1_linear_1[BANDS_DIMS_1A]
double ms1_const[BANDS_DIMS_1A]
int32_t l1b_rad(int syear, int sday, int32_t smsec, int32_t msec, char *dtype, int32_t nsta, int32_t ninc, int32_t npix, float *dark_mean, short *gain, short *tdi, short *scan_temp, float *inst_temp, int mside, short *l1a_data, float *l1b_data, cal_mod_struc *cal_mod)
int dark_rest_stat(int16 *data, int nrec, float *dark_mean, float *dark_std)
double ms2_linear_1[BANDS_DIMS_1A]
double ms2_exponential_1[BANDS_DIMS_1A]
int scan_ell(float p[3], double sm[3][3], double coef[10])
float senz[LAC_PIXEL_NUM]
double ms1_exponential_2[BANDS_DIMS_1A]
int32_t stray_light_corr(int32_t *initial, float Ltyp_frac, float Styp_frac, int32_t nscans, int32_t nsamples, int32_t scan_no, char *dtype, int16_t gn, float *rads, float *l1b_data, int32_t *sl_scan, int16_t *l2_flags, int32_t *AS_pixels)
float counts[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
double ms1_linear_2[BANDS_DIMS_1A]
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
double t_exponential_2[BANDS_DIMS_1A]
float cal_counts[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
double ms1_exponential_1[BANDS_DIMS_1A]