Go to the documentation of this file.
15 using namespace netCDF;
16 using namespace netCDF::exceptions;
19 #define LAC_PIXEL_NUM 1285
20 #define GAC_PIXEL_NUM 248
21 #define NREC_IN_BUF 10
25 #define MASK_HIGHLT1 16
26 #define GENBUFSIZ NREC_IN_BUF*sizeof(float)*40
79 static int32_t
do_st = 1;
109 vector<size_t>
start = {start0, start1, start2};
110 vector<size_t>
count = {count0, count1, count2};
111 dataFile.getVar(variable).getVar(
start,
count, (
void*)genBuf);
112 for (
int i = 0;
i < n_read;
i++)
113 if (variable ==
"gain")
114 memcpy(&rdBuf[
i].
gain, &genBuf[
i * numBytes], numBytes);
115 else if (variable ==
"tdi")
116 memcpy(&rdBuf[
i].
tdi, &genBuf[
i * numBytes], numBytes);
117 else if (variable ==
"scan_temp")
118 memcpy(&rdBuf[
i].scan_temp, &genBuf[
i * numBytes], numBytes);
119 else if (variable ==
"inst_ana")
120 memcpy(&rdBuf[
i].inst_temp, &genBuf[
i * numBytes], numBytes);
121 else if (variable ==
"orb_vec")
122 memcpy(&rdBuf[
i].orb_vec, &genBuf[
i * numBytes], numBytes);
123 else if (variable ==
"sun_ref")
124 memcpy(&rdBuf[
i].sun_ref, &genBuf[
i * numBytes], numBytes);
125 else if (variable ==
"scan_ell")
126 memcpy(&rdBuf[
i].
scan_ell, &genBuf[
i * numBytes], numBytes);
127 else if (variable ==
"sen_mat")
128 memcpy(&rdBuf[
i].sen_mat, &genBuf[
i * numBytes], numBytes);
132 int16_t *l1a_dum,
float **l1b_data, int16_t **l2_flags) {
143 float Styp_frac = 0.9;
152 static int32_t crec = -1;
153 static int16_t recursive_flag = 0;
154 static int16_t n_read = 0;
155 static int32_t max_rec_in_rdbuf;
158 static int32_t stray_light_scan_no;
160 static float *st_l1b_data;
161 static int16_t *st_l2_flags;
163 static int32_t initial = 1;
164 static byte first = 1;
173 vector<size_t>
start = {0, 0, 0};
174 vector<size_t>
count = {0, 0, 0};
182 if (first || recno < crec) {
183 max_rec_in_rdbuf = recno - 1;
184 stray_light_scan_no = recno;
189 if (crec >
nscan)
return 0;
191 if (crec > max_rec_in_rdbuf) {
203 NcFile dataFile(
file->name, NcFile::read);
214 for (irec = 0; irec < n_read; irec++) {
215 start[0]= (size_t) (recno - 1 + irec);
216 dataFile.getVar(
"l1a_data").getVar(
start,
count, (
void*) band_buf);
217 for (ipix = 0; ipix <
npix; ipix++) {
218 for (idet = 0; idet < 8; idet++) {
220 band_buf[ipix * 8 + idet];
316 offset = max_rec_in_rdbuf + 1;
317 max_rec_in_rdbuf += n_read;
320 catch (NcException& e) {
321 cout <<
"-E- Error getting L1A Data in Seawifs l2gen reader: " << e.what() << endl;
326 if ((crec -
offset) >= 0) {
329 gain_ptr = rdBuf[
j].
gain;
335 rdBuf[
j].scan_temp, rdBuf[
j].inst_temp,
side[recno - 1],
338 if (!recursive_flag) {
341 ylat,
xlon, solz, sola, senz, sena);
347 gain_ptr = bkBuf[
j].
gain;
350 if (!recursive_flag) {
353 ylat,
xlon, solz, sola, senz, sena);
362 if (!recursive_flag) {
363 for (ipix = 0; ipix <
npix; ipix++) {
367 for (idet = 6; (idet < 8)&&(hi_Lt[ipix] ==
FALSE); idet++) {
368 pixvalue = l1a_ptr[ipix +
npix * idet];
374 hi_Lt[ipix] = ((pixvalue - pixdark) >= kneevalue);
385 for (ipix = 0; ipix <
npix; ipix++)
388 }
else if (!recursive_flag) {
391 if (stray_light_scan_no != scan_no) {
396 l1a_dum, &st_l1b_data, &st_l2_flags);
407 for (ipix = 0; ipix <
npix; ipix++) {
432 NcFile dataFile(
file->name, NcFile::read);
439 char tempTimeCoverage[27];
442 dataFile.getAtt(
"time_coverage_start").getValues((
void*) &tempTimeCoverage);
445 int32_t tempDay, tempYear;
451 dataFile.getAtt(
"time_coverage_end").getValues((
void*) &tempTimeCoverage);
457 npix = dataFile.getDim(
"pixels").getSize();
458 nscan = dataFile.getDim(
"scans").getSize();
460 dataFile.getAtt(
"data_type").getValues((
void*) &
dtype);
461 dataFile.getAtt(
"LAC_pixel_start_number").getValues((
void*) &
nsta);
462 dataFile.getAtt(
"LAC_pixel_subsampling").getValues((
void*) &
ninc);
463 dataFile.getAtt(
"orbit_node_longitude").getValues((
void*) &
file->orbit_node_lon);
464 dataFile.getAtt(
"orbit_number").getValues((
void*) &
file->orbit_number);
465 dataFile.getAtt(
"node_crossing_time").getValues((
void*) &buf);
470 msec = (int32_t *) calloc(
nscan,
sizeof (int32_t));
471 side = (int16_t *) calloc(
nscan,
sizeof (int16_t));
473 tilt = (
float *) calloc(
nscan,
sizeof (
float));
475 dataFile.getVar(
"scan_time").getVar(
msec);
476 dataFile.getVar(
"side").getVar(
side);
477 dataFile.getVar(
"dark_rest").getVar(
dark_rest);
478 dataFile.getVar(
"tilt").getVar(
tilt);
480 catch (NcException& e) {
481 cout <<
"-E- Error in reading in openl1a_seawifs_netcdf. NetCDF: " << e.what() << endl;
494 if (strcmp(
dtype,
"GAC") == 0)
501 if (cal_path ==
NULL) {
503 "-E %s Line %d: No calibration file specified.\n",
514 if (strcmp(
dtype,
"GAC") == 0)
538 static cal_mod_struc cal_mod;
539 static int16_t *l2_flags;
540 static float *l1b_data;
544 int32_t nwave =
l1rec->l1file->nbands;
545 int32_t *
bindx = (int32_t*)
l1rec->l1file->bindx;
553 int16_t *l1a_dum =
NULL;
555 static int32_t prev_recnum = -1;
557 static int16_t first = 1;
558 static int32_t ntilts;
559 static int16_t tilt_flags[20];
560 static int16_t tilt_ranges[2 * 20];
568 printf(
"Reading out-of-sequence %d %d\n",
recnum, prev_recnum);
576 NcFile dataFile(
file->name, NcFile::read);
579 ntilts = dataFile.getDim(
"tilts").getSize();
580 dataFile.getVar(
"tilt_flags").getVar(tilt_flags);
581 dataFile.getVar(
"tilt_ranges").getVar(tilt_ranges);
587 for (
i = 0;
i < ntilts;
i++) {
588 if (tilt_ranges[2 *
i] <=
recnum + 1 && tilt_ranges[2 *
i + 1] >=
recnum)
594 vector<size_t>
count = {1, 8};
595 dataFile.getVar(
"nflag").getVar(
start,
count, (
void*)&nflag);
597 catch (NcException& e) {
598 cout <<
"-E- Error in reading in readl1a_seawifs_netcdf. NetCDF: " << e.what() << endl;
605 for (
i = prev_recnum + 1;
i <=
recnum;
i++)
607 &l1b_data, &l2_flags);
614 memcpy(
l1rec->solz, solz,
npix * sizeof (
float));
615 memcpy(
l1rec->sola, sola,
npix * sizeof (
float));
616 memcpy(
l1rec->senz, senz,
npix * sizeof (
float));
617 memcpy(
l1rec->sena, sena,
npix * sizeof (
float));
623 for (ipix = 0; ipix <
file->npix; ipix++) {
624 if (
l1rec->sena[ipix] > 180) {
625 l1rec->sena[ipix] -= 360.0;
627 if (
l1rec->sola[ipix] > 180) {
628 l1rec->sola[ipix] -= 360.0;
631 for (iw = 0; iw < nwave; iw++) {
633 l1rec->Lt [ipix * nwave + ib] = l1b_data[iw *
npix + ipix];
636 l1rec->hilt [ipix] = ((l2_flags[ipix] &
HILT) > 0);
637 l1rec->navwarn[ipix] = (nflag[7] & 1) | (nflag[0] & 1);
645 int16_t year =
syear;
650 if (
day > (365 + (year % 4 == 0))) {
671 NcFile dataFile(
file->name, NcFile::read);
674 vector<size_t>
count = {0, 0};
690 catch (NcException& e) {
691 cout <<
"-E- Error in reading seawifs lon and lat data netcdf." << endl;
702 int16_t year =
syear;
707 if (
day > (365 + (year % 4 == 0))) {
int closel1_seawifs_netcdf(filehandle *file)
int readl1_lonlat_seawifs_netcdf(filehandle *file, int32_t recnum, l1str *l1rec)
float cal_rads[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
double yds2unix(int16_t year, int16_t day, double secs)
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[])
void getVariableAndCopyToRdBuffer(inputBuffer rdBuf[], byte genBuf[], NcFile &dataFile, string variable, size_t start0, size_t start1, size_t start2, size_t count0, size_t count1, size_t count2, int numBytes, int n_read)
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]
short l2_flags_buffer[LAC_PIXEL_NUM]
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 openl1_seawifs_netcdf(filehandle *file)
int16_t tdi[BANDS_DIMS_1A]
int readl1_seawifs_netcdf(filehandle *file, int32_t recnum, l1str *l1rec)
integer, parameter double
void isodate2ydmsec(char *date, int32_t *year, int32_t *day, int32_t *msec)
float xlon[LAC_PIXEL_NUM]
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)
int scan_ell(float p[3], double sm[3][3], double coef[10])
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)
int32_t get_l1a_rec_netcdf(filehandle *file, int32_t recno, cal_mod_struc *cal_mod, int16_t *l1a_dum, float **l1b_data, int16_t **l2_flags)
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
float cal_counts[BANDS_DIMS_1A][GAINS_DIMS_1A][KNEES_DIMS_1A]
double isodate2unix(const char *isodate)