Go to the documentation of this file.
16 static short *tmpShort;
18 static size_t num_scans, num_pixels;
19 static size_t num_bands;
23 static double *scan_time;
24 static double file_start_day;
27 static int geolocationGrp;
28 static int lonId, latId;
29 static float latFillValue =
BAD_FLT;
30 static float lonFillValue =
BAD_FLT;
48 printf(
"Opening L1C file\n");
49 status = nc_open(
file->name, NC_NOWRITE, &ncid_L1C);
51 fprintf(
stderr,
"-E- %s line %d: nc_open(%s) failed.\n",
52 __FILE__, __LINE__,
file->name);
57 status = nc_inq_dimid(ncid_L1C,
"bins_along_track", &dimid);
59 fprintf(
stderr,
"-E- Error reading bins_along_track.\n");
62 nc_inq_dimlen(ncid_L1C, dimid, &num_scans);
65 status = nc_inq_dimid(ncid_L1C,
"bins_across_track", &dimid);
67 fprintf(
stderr,
"-E- Error reading bins_across_track.\n");
70 nc_inq_dimlen(ncid_L1C, dimid, &num_pixels);
73 status = nc_inq_dimid(ncid_L1C,
"intensity_bands_per_view", &dimid);
75 fprintf(
stderr,
"-E- Error reading intensity_bands_per_view.\n");
78 nc_inq_dimlen(ncid_L1C, dimid, &num_bands);
81 printf(
"L1C Npix :%d Nlines:%d\n", (
int)num_pixels, (
int)num_scans);
85 tmpShort = (
short*) malloc(num_pixels *
sizeof(
short));
86 scan_time = (
double*) malloc(num_scans *
sizeof(
double));
90 if ((nc_inq_grp_ncid(ncid_L1C,
"bin_attributes", &groupid)) == NC_NOERR) {
92 fprintf(
stderr,
"-E- Error finding bin_attributes.\n");
96 double scan_timeFillValue =
BAD_FLT;
97 status = nc_inq_varid(groupid,
"nadir_view_time", &varid);
99 fprintf(
stderr,
"-E- Error finding nadir_view_time.\n");
102 status = nc_inq_var_fill(groupid, varid,
NULL, &scan_timeFillValue);
104 status = nc_get_var_double(groupid, varid, scan_time);
109 status = nc_inq_attlen(ncid_L1C, NC_GLOBAL,
"time_coverage_start", &att_len);
113 char*
time_str = (
char *) malloc(att_len + 1);
116 status = nc_get_att_text(ncid_L1C, NC_GLOBAL,
"time_coverage_start",
time_str);
128 for(
int i=0;
i<num_scans;
i++) {
129 if(scan_time[
i] == scan_timeFillValue)
134 status = nc_inq_grp_ncid(ncid_L1C,
"geolocation_data", &geolocationGrp);
136 status = nc_inq_varid(geolocationGrp,
"longitude", &lonId);
138 status = nc_inq_var_fill(geolocationGrp, lonId,
NULL, &lonFillValue);
140 status = nc_inq_varid(geolocationGrp,
"latitude", &latId);
142 status = nc_inq_var_fill(geolocationGrp, latId,
NULL, &latFillValue);
145 file->sd_id = ncid_L1C;
146 file->nbands = num_bands;
147 file->npix = num_pixels;
148 file->nscan = num_scans;
150 file->terrain_corrected = 1;
154 printf(
"file->nbands = %d\n", (
int)
file->nbands);
175 size_t start[] = { 0, 0, 0 };
176 size_t count[] = { 1, 1, 1 };
178 for (
int ip = 0; ip < num_pixels; ip++) {
179 l1rec->pixnum[ip] = ip;
187 l1rec->scantime = file_start_day + scan_time[
line];
195 int32_t
msec = (int32_t) (secs * 1000.0);
205 count[1] = num_pixels;
212 for(
int i=0;
i<num_pixels;
i++) {
213 if(
l1rec->lat[
i] == latFillValue)
215 if(
l1rec->lon[
i] == lonFillValue)
235 printf(
"Closing L1C file\n");
241 if (tmpShort) free(tmpShort);
242 if (scan_time) free(scan_time);
void check_err(const int stat, const int line, const char *file)
int readl1_l1c(filehandle *file, int32_t line, l1str *l1rec)
void unix2ymds(double usec, int16_t *year, int16_t *mon, int16_t *day, double *secs)
double esdist_(int32_t *year, int32_t *day, int32_t *msec)
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 time_str(short, short, int, char *)
void unix2yds(double usec, short *year, short *day, double *secs)
int openl1_l1c(filehandle *file)
real *8 function esdist(iyr, iday, msec)
double ymds2unix(short year, short month, short day, double secs)
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int closel1_l1c(filehandle *file)
double isodate2unix(const char *isodate)