Go to the documentation of this file.
14 #define LAC_PIXEL_NUM 1285
15 #define NREC_IN_BUF 10
25 static int16_t cal_year;
26 static int16_t cal_day;
27 static int32_t cal_msec;
30 static float egain[8], temps[8], mirror[8];
33 static float sm[1044];
49 static double *sc_ttag;
50 static double *sc_ttag_inc;
64 int32_t
get_l1a_rec_osmi(int32_t, int32_t, cal_mod_struc *,
float **, int16_t **);
66 void intpos_(
double *epoch1,
double pos1[3],
double vel1[3],
67 double *epoch2,
double pos2[3],
double vel2[3],
68 double *epoch,
double pos [3],
double vel [3]);
88 "-E %s Line %d: Error opening %s for reading.\n",
89 __FILE__, __LINE__,
file->name);
108 if (cal_path ==
NULL) {
110 "-E %s Line %d: No calibration file specified.\n",
115 &cal_year, &cal_day, &cal_msec,
116 &eoffset, &egain[0], &temps[0],
117 &mirror[0], &
t_const[0], &t_linear[0],
118 &t_quadratic[0], &
slope[0], &dc[0],
122 "-E- %s line %d: Error applying calibration table \"%s\".\n",
123 __FILE__, __LINE__, cal_path);
139 msec = (int32_t *) calloc(
nscan,
sizeof (int32_t));
142 sc_ana = (
float *) calloc(
nscan * 40,
sizeof (
float));
145 sc_ttag = (
double *) calloc(
nscan,
sizeof (
double));
148 sc_ttag_inc = (
double *) calloc(
nscan,
sizeof (
double));
149 status =
rdSDS(
file->sd_id,
"sc_ttag_inc", 0, 0, 0, 0, (VOIDP) sc_ttag_inc);
160 static cal_mod_struc cal_mod;
161 static int16_t *l2_flags;
162 static float *l1b_data;
163 static int chindx[6] = {0, 1, 2, 4, 6, 7};
167 int32_t nwave =
l1rec->l1file->nbands;
181 &l1b_data, &l2_flags);
189 memcpy(
l1rec->solz, solz,
npix * sizeof (
float));
190 memcpy(
l1rec->sola, sola,
npix * sizeof (
float));
191 memcpy(
l1rec->senz, senz,
npix * sizeof (
float));
192 memcpy(
l1rec->sena, sena,
npix * sizeof (
float));
198 for (ipix = 0; ipix <
file->npix; ipix++) {
200 if (
l1rec->sena[ipix] < -180.0)
l1rec->sena[ipix] += 360.0;
202 for (iw = 0; iw < nwave; iw++) {
207 l1rec->hilt [ipix] = ((l2_flags[ipix] &
HILT) > 0);
209 if (ipix < 15)
l1rec->hilt[ipix] = 1;
210 if (ipix > 1028)
l1rec->hilt[ipix] = 1;
222 if (
day > (365 + (
year % 4 == 0))) {
248 float **l1b_data, int16_t **l2_flags) {
257 int32_t
start[3] = {0, 0, 0};
263 static int16_t n_read = 0;
264 static int32_t max_rec_in_rdbuf;
268 static byte first = 1;
272 int32_t recno1, recno2;
273 double uepoch, epoch, epoch1, epoch2;
274 double pos1[3], vel1[3];
275 double pos2[3], vel2[3];
276 double pos [3], vel [3];
285 max_rec_in_rdbuf = recno - 1;
290 if (crec >
nscan)
return 0;
293 if (crec > max_rec_in_rdbuf || crec <
offset) {
303 for (irec = 0; irec < n_read; irec++) {
304 start[0] = recno - 1 + irec;
305 SDreaddata(SDselect(sd_id, SDnametoindex(sd_id,
"l1a_data")),
307 for (ipix = 0; ipix <
npix; ipix++)
308 for (idet = 0; idet < 8; idet++)
314 max_rec_in_rdbuf =
offset + n_read - 1;
318 if ((crec -
offset) >= 0) {
323 (recno - 1) % 96, &i16dum, i16dum, 0,
333 uepoch =
itojul(700101, 0);
340 recno2 = recno - 96 - 1;
344 epoch1 = uepoch + sc_ttag[recno1] / 86400.0;
345 pos1[0] = sc_ana[40 * (recno1) + 9] * 1000.0;
346 pos1[1] = sc_ana[40 * (recno1) + 10] * 1000.0;
347 pos1[2] = sc_ana[40 * (recno1) + 11] * 1000.0;
348 vel1[0] = sc_ana[40 * (recno1) + 12] * 1000.0;
349 vel1[1] = sc_ana[40 * (recno1) + 13] * 1000.0;
350 vel1[2] = sc_ana[40 * (recno1) + 14] * 1000.0;
352 epoch2 = uepoch + sc_ttag[recno2] / 86400.0;
353 pos2[0] = sc_ana[40 * (recno2) + 9] * 1000.0;
354 pos2[1] = sc_ana[40 * (recno2) + 10] * 1000.0;
355 pos2[2] = sc_ana[40 * (recno2) + 11] * 1000.0;
356 vel2[0] = sc_ana[40 * (recno2) + 12] * 1000.0;
357 vel2[1] = sc_ana[40 * (recno2) + 13] * 1000.0;
358 vel2[2] = sc_ana[40 * (recno2) + 14] * 1000.0;
362 epoch = uepoch + (sc_ttag[recno - 1] +
366 ((
i) * sc_ttag_inc[recno - 1])) / 86400.0;
376 if (sola[
i] < 0.0) sola[
i] = sola[
i] + 360.0;
378 intpos_(&epoch1, pos1, vel1, &epoch2, pos2, vel2, &epoch,
pos, vel);
389 if (sena[
i] < 0.0) sena[
i] = sena[
i] + 360.0;
int32_t get_l1a_rec_osmi(int32_t, int32_t, cal_mod_struc *, float **, int16_t **)
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)
void ctotc(r, struct GEODETIC *obs, double gha, struct TOPOCENTRIC *top, daer)
void intpos_(double *epoch1, double pos1[3], double vel1[3], double *epoch2, double pos2[3], double vel2[3], double *epoch, double pos[3], double vel[3])
int readl1a_osmi(filehandle *file, int32_t recnum, l1str *l1rec)
double itojul(int32_t date, int32_t time)
float ylat[LAC_PIXEL_NUM]
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
int32_t get_cal_osmi(char *cal_path, int16_t syear, int16_t sday, int16_t eday, int32_t msec, int16_t *cal_year, int16_t *cal_day, int32_t *cal_msec, float *eoffset, float *egain, float *temp, float *mirror, float *t_const, float *t_linear, float *t_quadratic, float *slope, float *dc, float *sm)
int openl1a_osmi(filehandle *file)
int getHDFattr(int32_t fileID, const char attrname[], const char sdsname[], void *data)
int closel1a_osmi(filehandle *file)
float xlon[LAC_PIXEL_NUM]
double tconv(double tjd, char conv[], char **errstr)
int32_t calibrate_l1a_osmi(char *cal_path, int16_t syear, int16_t sday, int32_t smsec, int16_t eday, int32_t msec, char *dtype, int32_t st_samp, int32_t nsamp, int32_t fpixel, int16_t gain[4], int16_t offset, int16_t scan_temp, int16_t *l1a_data, float *l1b_data, cal_mod_struc *cal_mod)
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int sunpos(double tjd, double r[3], char **errstr)