25 int main(
int argc,
char *argv[]) {
26 int iscn, ipx, ibnd, idet, n_bad,
msec;
28 sdr_info_struc sdr_info;
30 out_rec_struc out_rec;
34 double esdist_(
int *,
int *,
int *);
46 strcpy(sdr_info.origin, ctl.id_origin);
47 strcpy(sdr_info.domain, ctl.id_domain);
52 printf(
"%s, %d: failure to read sensor information\n",
55 out_rec.lam_band = in_rec.lam_band;
57 printf(
"%s, %d: failure to read sensor information\n",
64 if (
rd_sim_init(&ctl, &sdr_info, &in_rec) != 0)
return 1;
68 in_rec.year = sdr_info.year;
69 in_rec.yday = sdr_info.day;
70 msec = *sdr_info.scan_time * 1000.;
72 for (ibnd = 0; ibnd < in_rec.nbnd; ibnd++)
74 out_rec.f0 = &(in_rec.f0[0]);
75 printf(
"%s, %d: info: earth sun distance correction is %f\n",
76 __FILE__, __LINE__,
esdist);
80 if (
init_sdr(&ctl, &sdr_info, &in_rec, &out_rec) != 0)
return 1;
84 for (iscn = 0; iscn < in_rec.nscan; iscn++) {
88 if (
rd_sdr_scan(iscn, &ctl, &sdr_info, &in_rec) != 0)
return 1;
92 msec = *(sdr_info.scan_time + iscn) * 1000.;
96 for (ibnd = 0; ibnd < in_rec.nbnd; ibnd++)
99 out_rec.year = in_rec.year;
100 out_rec.yday = in_rec.yday;
101 out_rec.msec = in_rec.msec;
102 out_rec.f0 = &(in_rec.f0[0]);
107 for (idet = 0; idet < in_rec.ndet_scan; idet++)
108 for (ipx = 0; ipx < in_rec.npix; ipx++)
110 if (*(in_rec.bnd_q[ibnd] + ipx + in_rec.npix * idet) != 0)
113 printf(
"%s %d: scan: %d, # bad samples: %d\n", __FILE__, __LINE__,
119 if ((ctl.any_artifact == 1) && (in_rec.scn_fmt != 0))
124 if (
scan_cvt(&in_rec, &out_rec) != 0)
130 if (ctl.vic_cal_chg == 1) {
131 for (ibnd = 0; ibnd < in_rec.nbnd; ibnd++)
132 for (idet = 0; idet < out_rec.ndet_scan; idet++)
133 for (ipx = 0; ipx < out_rec.npix; ipx++)
134 if (*(out_rec.bnd_q[ ibnd ] + ipx + idet * out_rec.ndet_scan)
136 *(out_rec.bnd_lt[ ibnd ] + ipx + idet * out_rec.npix) -=
138 *(out_rec.bnd_lt[ ibnd ] + ipx + idet * out_rec.npix) /=
146 if ((ctl.bowtie_opt == 1) && (out_rec.scn_fmt == 0)) {
147 for (idet = 0; idet <
NDET; idet++) {
151 for (ibnd = 0; ibnd < in_rec.nbnd; ibnd++) {
152 for (ipx = 0; ipx < 1008; ipx++)
153 *(out_rec.bnd_q[ibnd] + idet * 3200 + ipx) = 1;
154 for (ipx = 2192; ipx < 3200; ipx++)
155 *(out_rec.bnd_q[ibnd] + idet * 3200 + ipx) = 1;
160 for (ibnd = 0; ibnd < in_rec.nbnd; ibnd++) {
161 for (ipx = 0; ipx < 640; ipx++)
162 *(out_rec.bnd_q[ibnd] + idet * 3200 + ipx) = 1;
163 for (ipx = 2560; ipx < 3200; ipx++)
164 *(out_rec.bnd_q[ibnd] + idet * 3200 + ipx) = 1;
178 if (
fin_sdr(&ctl, &in_rec, &out_rec) != 0)
return 1;
180 for (iscn = 0; iscn < out_rec.nbnd + 1; iscn++)
181 printf(
"Created file # %d: %s\n", iscn, sdr_info.sdr_files[iscn]);
182 printf(
"Path: %s\n", ctl.out_loc);
183 printf(
"Start date: %s\n", sdr_info.st_date);
184 printf(
"Start time: %s\n", sdr_info.st_time);
185 printf(
"End date: %s\n", sdr_info.en_date);
186 printf(
"End time: %s\n", sdr_info.en_time);
187 if (ctl.meta_use != 0) {
188 if ((meta_id = fopen(ctl.meta_file,
"w")) ==
NULL) {
189 printf(
"%s, line %d: Failure to create the metadata file\n",
193 for (iscn = 0; iscn < out_rec.nbnd + 1; iscn++)
194 fprintf(meta_id,
"%s\n", sdr_info.sdr_files[iscn]);
195 fprintf(meta_id,
"%s\n", ctl.out_loc);
196 fprintf(meta_id,
"%s\n", sdr_info.st_date);
197 fprintf(meta_id,
"%s\n", sdr_info.st_time);
198 fprintf(meta_id,
"%s\n", sdr_info.en_date);
199 fprintf(meta_id,
"%s\n", sdr_info.en_time);
203 printf(
"Successfully completed simulated SDR generation\n");