Go to the documentation of this file.
15 static int32_t
spix = 0;
38 fprintf(
stderr,
"-E- %s line %d: SDstart(%s, %d) failed.\n",
39 __FILE__, __LINE__,
file->name, DFACC_RDONLY);
44 sds_id = SDselect(
fileID, SDnametoindex(
fileID, (
"ocm_ch1")));
45 if (SDgetinfo(sds_id,
NULL, &
rank, dims, &
type, &numattr) == -1) {
46 fprintf(
stderr,
"-E- %s line %d: error getting dimension info.\n",
55 sprintf(date,
"%d%g", itmp, itmp2);
83 static int firstCall = 1;
85 static uint16 **dataarr;
86 static float **scanarr;
90 static uint16 **valid_range;
91 static uint16 *FillValue;
93 static char *
names[] = {
"ocm_ch1",
"ocm_ch2",
"ocm_ch3",
"ocm_ch4",
94 "ocm_ch5",
"ocm_ch6",
"ocm_ch7",
"ocm_ch8"};
103 printf(
"OCM has %d bands\n",
l1rec->l1file->nbands);
105 dataarr = (uint16 **) calloc(1,
l1rec->l1file->nbands * sizeof (uint16*));
106 scanarr = (
float **) calloc(1,
l1rec->l1file->nbands * sizeof (
float*));
108 m = (
double *) calloc(1,
l1rec->l1file->nbands * sizeof (
double));
109 b = (
double *) calloc(1,
l1rec->l1file->nbands * sizeof (
double));
111 valid_range = (uint16 **) calloc(1,
l1rec->l1file->nbands * sizeof (uint16*));
112 FillValue = (uint16 *) calloc(1,
l1rec->l1file->nbands * sizeof (uint16));
114 for (ib = 0; ib <
l1rec->l1file->nbands; ib++) {
115 if ((dataarr[ib] = (uint16 *) calloc(
npix,
sizeof (uint16))) ==
NULL) {
116 printf(
"-E- %s line %d: Error allocating data space.\n",
120 if ((scanarr[ib] = (
float *) calloc(
npix,
sizeof (
float))) ==
NULL) {
121 printf(
"-E- %s line %d: Error allocating scan space.\n",
125 if ((valid_range[ib] = (uint16 *) calloc(2,
sizeof (uint16))) ==
NULL) {
126 printf(
"-E- %s line %d: Error allocating scan space.\n",
131 printf(
"-E- %s line %d: Error reading reflectance scale attribute.\n",
136 printf(
"-E- %s line %d: Error reading reflectance scale attribute.\n",
141 printf(
"-E- %s line %d: Error reading reflectance scale attribute.\n",
146 printf(
"-E- %s line %d: Error reading reflectance scale attribute.\n",
150 printf(
"OCM Channel %s\n",
names[ib]);
151 printf(
"\tscale_factor %g, add_offset %g\n", m[ib],
b[ib]);
152 printf(
"\t_FillValue %d\n", (
int) FillValue[ib]);
153 printf(
"\tvalid_range [%d,%d]\n", (
int) valid_range[ib][0], (
int) valid_range[ib][1]);
161 READ_SDS_ID(
fileID,
"latitude",
l1rec->lat,
scan,
spix, 0, 0, 1,
npix, 1, 1);
162 READ_SDS_ID(
fileID,
"longitude",
l1rec->lon,
scan,
spix, 0, 0, 1,
npix, 1, 1);
163 READ_SDS_ID(
fileID,
"sun_zenith",
l1rec->solz,
scan,
spix, 0, 0, 1,
npix, 1, 1);
164 READ_SDS_ID(
fileID,
"rel_azimuth",
l1rec->sola,
scan,
spix, 0, 0, 1,
npix, 1, 1);
165 READ_SDS_ID(
fileID,
"sat_zenith",
l1rec->senz,
scan,
spix, 0, 0, 1,
npix, 1, 1);
166 READ_SDS_ID(
fileID,
"scatter_phase",
l1rec->sena,
scan,
spix, 0, 0, 1,
npix, 1, 1);
168 for (ip = 0; ip <
npix; ip++) {
172 if (
l1rec->lon[ip] < -181.0 ||
l1rec->lon[ip] > 181.0 ||
173 l1rec->lat[ip] < -91.0 ||
l1rec->lat[ip] > 91.0)
174 l1rec->navfail[ip] = 1;
179 for (ib = 0; ib <
l1rec->l1file->nbands; ib++) {
180 READ_SDS_ID(
fileID,
names[ib], &dataarr[ib][0],
scan,
spix, 0, 0, 1,
npix, 1, 1);
181 for (ip = 0; ip <
npix; ip++) {
182 scanarr[ib][ip] = (
float) dataarr[ib][ip] * m[ib] +
b[ib];
188 for (ip = 0; ip <
npix; ip++) {
189 for (ib = 0; ib <
l1rec->l1file->nbands; ib++) {
192 ipb = ip *
l1rec->l1file->nbands + ib;
193 l1rec->Lt[ipb] = scanarr[ib][ip];
195 if (dataarr[ib][ip] < valid_range[ib][0] || dataarr[ib][ip] > valid_range[ib][1]) {
197 l1rec->Lt[ipb] = 1000.0;
199 if (dataarr[ib][ip] == FillValue[ib]) {
201 l1rec->Lt[ipb] = 1000.0;
203 if (dataarr[ib][ip] == 0) {
205 l1rec->Lt[ipb] = 1000.0;
224 fprintf(
stderr,
"-E- %s line %d: SDend(%d) failed for file, %s.\n",
double yds2unix(int16_t year, int16_t day, double secs)
int closel1_ocmdb_hdf(filehandle *file)
int openl1_ocmdb_hdf(filehandle *file)
MOD_PR01 Production producing one five minute granule of output data in each run It can be configured to produce as many as three five minute granules per run Each execution with one construction record and one date file for each dataset In normal these are created by which splits them out of the hour datasets For LANCE they are created by which merges all session MODIS L0 datasets overlapping the requested time and extracts from the merged data those packets which fall within that time period Each scan of data is stored in the L1A granule that covers the start time of that scan
#define READ_SDS_ID(sd_id, nam, ptr, s0, s1, s2, s3, e0, e1, e2, e3)
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 getHDFattr(int32_t fileID, const char attrname[], const char sdsname[], void *data)
Extra metadata that will be written to the HDF4 file l2prod rank
void date2ydmsec(char *date, int32_t *year, int32_t *day, int32_t *msec)
int readl1_ocmdb_hdf(filehandle *file, int32_t scan, l1str *l1rec)
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
#define HDF_FUNCTION_ERROR