00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 #include <jsoc_main.h>
00088
00089 char *module_name = "rdcoverage";
00090 char *module_desc = "report input data coverage for tracking options";
00091 char *version_id = "1.2";
00092
00093 ModuleArgs_t module_args[] = {
00094 {ARG_STRING, "ds", "", "input data series or dataset"},
00095 {ARG_STRING, "reject", "Not Specified", "file containing rejection list"},
00096 {ARG_INT, "qmask", "0x80000000", "quality bit mask for image rejection"},
00097 {ARG_INT, "max_miss", "All",
00098 "missing values threshold for image rejection"},
00099 {ARG_STRING, "tmid", "Not Specified", "midpoint of tracking interval"},
00100 {ARG_INT, "length", "0",
00101 "target length of tracking interval [input cadence]"},
00102
00103 {ARG_STRING, "tstart", "Not Specified", "start of coverage interval"},
00104 {ARG_STRING, "tstop", "Not Specified", "end of coverage interval"},
00105 {ARG_FLOAT, "tstep", "Not specified", "temporal cadence for output"},
00106 {ARG_STRING, "trec_key", "T_REC", "keyname of (slotted) prime key"},
00107 {ARG_STRING, "tobs_key", "T_OBS", "keyname for image observation time"},
00108 {ARG_STRING, "tstp_key", "CADENCE", "keyname for image observation time"},
00109 {ARG_STRING, "qual_key", "Quality",
00110 "keyname for 32-bit image quality field"},
00111 {ARG_STRING, "clon_key", "CRLN_OBS", "keyname for image central longitude"},
00112 {ARG_STRING, "clat_key", "CRLT_OBS", "keyname for image central latitude"},
00113 {ARG_STRING, "crot_key", "CAR_ROT", "keyname for image Carrington rotation"},
00114 {ARG_FLOAT, "pa", "Not Specified",
00115 "centre of acceptable roll angles [deg]"},
00116 {ARG_FLOAT, "dpa", "Not Specified",
00117 "maximum deviation of acceptable roll angles [deg]"},
00118 {ARG_STRING, "pa_key", "CROTA2", "keyname for image position angle"},
00119 {ARG_FLAG, "v", "", "verbose mode"},
00120 {}
00121 };
00122
00123 #include "keystuff.c"
00124 #include "selstuff.c"
00125 #include "soho_ephem.c"
00126
00127
00128
00129
00130
00131
00132 static int fgetline (FILE *in, char *line, int max) {
00133 if (fgets (line, max, in) == NULL) return 0;
00134 else return (strlen (line));
00135 }
00136
00137 static int read_reject_list (FILE *file, int **list) {
00138 int ds, sn, rec, last_rec;
00139 int allocd = 1024, ct = 0, gap = 0;
00140 char line[1024], t_str[64], estr[16];
00141
00142 *list = (int *)malloc (allocd * sizeof (int));
00143 while (fgetline (file, line, 1024)) {
00144 if (strlen (line) == 1) continue;
00145 if (line[0] == '#') continue;
00146 if (sscanf (line, "%d %d %d %s", &ds, &sn, &rec, t_str) != 4) {
00147 if (sscanf (line, "%d %s", &rec, t_str) != 2) {
00148 sscanf (line, "%s", estr);
00149 if (strcmp (estr, "...")) continue;
00150 gap = 1;
00151 last_rec = rec;
00152 continue;
00153 }
00154 }
00155 if (gap) {
00156 while (rec > last_rec) {
00157 last_rec++;
00158 (*list)[ct++] = last_rec;
00159 if (ct >= allocd) {
00160 allocd += 1024;
00161 *list = (int *)realloc (*list, allocd * sizeof (int));
00162 }
00163 }
00164 gap = 0;
00165 continue;
00166 }
00167 (*list)[ct++] = rec;
00168 if (ct >= allocd) {
00169 allocd += 1024;
00170 *list = (int *)realloc (*list, allocd * sizeof (int));
00171 }
00172 }
00173 return ct;
00174 }
00175
00176
00177 float missing_val;
00178
00179 static int verify_keys (DRMS_Record_t *rec, const char *trec, const char *clon,
00180 const char *clat, int *slotted) {
00181 DRMS_Keyword_t *keywd;
00182
00183 keywd = drms_keyword_lookup (rec, trec, 1);
00184 if (!keywd) {
00185 fprintf (stderr,
00186 "Error: Keyword \"%s\" for slotted time not found\n", trec);
00187 fprintf (stderr, " Must supply an appropriate value for trec_key\n");
00188 return -1;
00189 }
00190
00191 *slotted = drms_keyword_isslotted (keywd);
00192 if (!(*slotted))
00193 fprintf (stderr, "Warning: Keyword \"%s\" is not slotted\n", trec);
00194
00195 keywd = drms_keyword_lookup (rec, clon, 1);
00196 if (!keywd) {
00197 fprintf (stderr,
00198 "Error: Keyword \"%s\" for Carrington longitude of observer not found\n",
00199 clon);
00200 fprintf (stderr, " Must supply an appropriate value for clon_key\n");
00201 fprintf (stderr, " (Carrington longitude of disc center in deg)\n");
00202 return -1;
00203 }
00204 if (keywd->info->type == DRMS_TYPE_TIME ||
00205 keywd->info->type == DRMS_TYPE_STRING ||
00206 keywd->info->type == DRMS_TYPE_RAW) {
00207 fprintf (stderr,
00208 "Error: Keyword \"%s\" for observer Carrington longitude is of wrong type\n",
00209 clon);
00210 fprintf (stderr, " Must supply an appropriate value for clon_key\n");
00211 fprintf (stderr, " (Carrington longitude of disc centre in deg)\n");
00212 return -1;
00213 }
00214 if (strncasecmp (keywd->info->unit, "deg", 3)) {
00215 fprintf (stderr,
00216 "Warning: Keyword \"%s\" for observer Carrington longitude has unit of \"%s\"\n",
00217 clon, keywd->info->unit);
00218 fprintf (stderr, " ignored, \"deg\" assumed\n");
00219 }
00220
00221 keywd = drms_keyword_lookup (rec, clat, 1);
00222 if (!keywd) {
00223 fprintf (stderr,
00224 "Error: Keyword \"%s\" for observer heliographic latitude not found\n",
00225 clat);
00226 fprintf (stderr, " Must supply an appropriate value for clat_key\n");
00227 fprintf (stderr, " (heliographic latitude of disc centre in deg)\n");
00228 return -1;
00229 }
00230 if (keywd->info->type == DRMS_TYPE_TIME ||
00231 keywd->info->type == DRMS_TYPE_STRING ||
00232 keywd->info->type == DRMS_TYPE_RAW) {
00233 fprintf (stderr,
00234 "Error: Keyword \"%s\" for observer heliographic latitude is of wrong type\n",
00235 clat);
00236 fprintf (stderr, " Must supply an appropriate value for clat_key\n");
00237 fprintf (stderr, " (heliographic latitude of disc centre in deg)\n");
00238 return -1;
00239 }
00240 if (strncasecmp (keywd->info->unit, "deg", 3)) {
00241 fprintf (stderr,
00242 "Warning: Keyword \"%s\" for observer heliographic latitude has unit of \"%s\"\n",
00243 clat, keywd->info->unit);
00244 fprintf (stderr, " ignored, \"deg\" assumed\n");
00245 }
00246
00247 return 0;
00248 }
00249
00250 int DoIt (void) {
00251 CmdParams_t *params = &cmdparams;
00252 DRMS_RecordSet_t *ds = NULL;
00253 DRMS_Record_t *irec;
00254 DRMS_Array_t *tvec;
00255 DRMS_Keyword_t *keywd;
00256 TIME trec, tobs, tmid, tbase, tfirst, tlast, tstrt, tstop;
00257 double data_cadence, coverage, t_eps, phase;
00258 double lat, lon, img_lat, img_lon;
00259 double tmid_cl;
00260 double img_xc, img_yc, img_xscl, img_yscl, img_radius, img_pa;
00261 float pa_rec, dpa;
00262
00263 long long nn;
00264 unsigned int quality;
00265 int *reject_list;
00266 int recct, rgn, rgnct, segct, valid;
00267 int tmid_cr;
00268 int col, row, pixct, i, found, n, nr;
00269 int blankvals, no_merid_v, rejects, status;
00270 int need_cadence;
00271 int badpkey, badqual, badfill, badtime, badpa, blacklist;
00272 int pkeyslotted;
00273 char rec_query[256];
00274 char module_ident[64], key[64], tbuf[64], ptbuf[64], ctime_str[16];
00275 char keyvalstr[DRMS_DEFVAL_MAXLEN];
00276 enum platloc {LOC_UNKNOWN, LOC_MWO, LOC_GONG_MR, LOC_GONG_LE, LOC_GONG_UD,
00277 LOC_GONG_TD, LOC_GONG_CT, LOC_GONG_TC, LOC_GONG_BB, LOC_GONG_ML, LOC_SOHO,
00278 LOC_SDO} platform = LOC_UNKNOWN;
00279
00280 int check_platform = 0;
00281 int found_first = 0, found_last = 0;
00282
00283 char *inset = strdup (params_get_str (params, "ds"));
00284 char *rejectfile = strdup (params_get_str (params, "reject"));
00285 unsigned int qmask = cmdparams_get_int64 (params, "qmask", &status);
00286 int max_miss = params_get_int (params, "max_miss");
00287 char *tmid_str = strdup (params_get_str (params, "tmid"));
00288 char *tstrt_str = strdup (params_get_str (params, "tstart"));
00289 char *tstop_str = strdup (params_get_str (params, "tstop"));
00290 int length = params_get_int (params, "length");
00291 double tstep = params_get_double (params, "tstep");
00292 float pa_nom = params_get_float (params, "pa");
00293 float dpa_max = params_get_float (params, "dpa");
00294 int check_pa = (isfinite (pa_nom) && dpa_max < 180.0);
00295
00296 char *trec_key = strdup (params_get_str (params, "trec_key"));
00297 char *tobs_key = strdup (params_get_str (params, "tobs_key"));
00298 char *tstp_key = strdup (params_get_str (params, "tstp_key"));
00299 char *qual_key = strdup (params_get_str (params, "qual_key"));
00300 char *clon_key = strdup (params_get_str (params, "clon_key"));
00301 char *clat_key = strdup (params_get_str (params, "clat_key"));
00302 char *crot_key = strdup (params_get_str (params, "crot_key"));
00303 char *pang_key = strdup (params_get_str (params, "pa_key"));
00304
00305 int verbose = params_isflagset (params, "v");
00306
00307 snprintf (module_ident, 64, "%s v %s", module_name, version_id);
00308 if (verbose) printf ("%s: JSOC version %s\n", module_ident, jsoc_version);
00309
00310 need_cadence = isnan (tstep);
00311
00312 if (key_params_from_dspec (inset)) {
00313 TIME *tvals;
00314
00315 if (!(ds = drms_open_recordset (drms_env, inset, &status))) {
00316 fprintf (stderr, "Error: (%s) unable to open input data set %s\n",
00317 module_ident, inset);
00318 fprintf (stderr, " status = %d\n", status);
00319 return 1;
00320 }
00321 irec = drms_recordset_fetchnext (drms_env, ds, &status, NULL, NULL);
00322 if (!irec) {
00323 printf (" No records in selected input set\n");
00324 drms_close_records (ds, DRMS_FREE_RECORD);
00325 return 1;
00326 }
00327 status = verify_keys (irec, trec_key, clon_key, clat_key, &pkeyslotted);
00328 if (status) {
00329 fprintf (stderr, "Error: unable to verify keys\n");
00330 drms_close_records (ds, DRMS_FREE_RECORD);
00331 return 1;
00332 }
00333 tvec = drms_record_getvector (drms_env, inset, trec_key, DRMS_TYPE_DOUBLE,
00334 0, &status);
00335 tvals = (TIME *)tvec->data;
00336 recct = tvec->axis[1];
00337 if (recct < 2) {
00338 printf ("<2 records in selected input set\n");
00339 drms_free_array (tvec);
00340 drms_close_records (ds, DRMS_FREE_RECORD);
00341 return 0;
00342 }
00343 if (need_cadence) {
00344
00345 if ((keywd = drms_keyword_lookup (irec, tstp_key, 1))) {
00346
00347 if (keywd->info->recscope != 1) {
00348 fprintf (stderr, "Warning: cadence is variable in input series %s\n",
00349 inset);
00350 fprintf (stderr, " output cadence will be %f\n",
00351 drms_getkey_double (irec, tstp_key, &status));
00352 }
00353 } else {
00354
00355 fprintf (stderr,
00356 "Error: data cadence keyword %s not in input series %s\n",
00357 tstp_key, inset);
00358 fprintf (stderr, " Specify desired output cadence as tstep\n");
00359 drms_close_records (ds, DRMS_FREE_RECORD);
00360 return 1;
00361 }
00362 data_cadence = drms_getkey_double (irec, tstp_key, &status);
00363 tstep = data_cadence;
00364 }
00365 tstrt = tvals[0];
00366 tstop = tvals[recct - 1];
00367 length = (tstop - tstrt + 1.01 * tstep) / tstep;
00368 tmid = 0.5 * (tstrt + tstop);
00369 segct = drms_record_numsegments (irec);
00370 } else {
00371
00372
00373
00374
00375 irec = drms_template_record (drms_env, inset, &status);
00376 if (status) {
00377 fprintf (stderr, "Error: unable to create template record in %s\n", inset);
00378 fprintf (stderr, " status = %d\n", status);
00379 return 1;
00380 }
00381 status = verify_keys (irec, trec_key, clon_key, clat_key, &pkeyslotted);
00382 if (status) {
00383 fprintf (stderr, "Error: unable to verify keys from template record\n");
00384 drms_free_record (irec);
00385 return 1;
00386 }
00387 if ((keywd = drms_keyword_lookup (irec, tstp_key, 1))) {
00388
00389 if (keywd->info->recscope != 1) {
00390 fprintf (stderr, "Warning: cadence is variable in input series %s\n",
00391 inset);
00392 if (need_cadence)
00393 fprintf (stderr, " output cadence will be %f\n",
00394 drms_getkey_double (irec, tstp_key, &status));
00395 }
00396 } else {
00397
00398 fprintf (stderr,
00399 "Error: data cadence keyword %s not in input series %s\n",
00400 tstp_key, inset);
00401 fprintf (stderr, " Specify desired output cadence as tstep\n");
00402 drms_free_record (irec);
00403 return 1;
00404 }
00405 data_cadence = drms_getkey_double (irec, tstp_key, &status);
00406 t_eps = 0.5 * data_cadence;
00407 if (need_cadence)
00408
00409 tstep = data_cadence;
00410 if ((keywd = drms_keyword_lookup (irec, "TELESCOP", 1))) {
00411
00412 if (keywd->info->recscope != 1)
00413 fprintf (stderr, "Warning: TELESCOP is variable in input series %s\n",
00414 inset);
00415 if (!strcmp (drms_getkey_string (irec, "TELESCOP", &status), "SDO/HMI"))
00416 platform = LOC_SDO;
00417 else if (!strcmp (drms_getkey_string (irec, "TELESCOP", &status), "SOHO"))
00418 platform = LOC_SOHO;
00419 else if (!strcmp (drms_getkey_string (irec, "TELESCOP", &status),
00420 "NSO-GONG")) {
00421 if ((keywd = drms_keyword_lookup (irec, "SITE", 1))) {
00422 if (!strcmp (drms_getkey_string (irec, "SITE", &status), "MR"))
00423 platform = LOC_GONG_MR;
00424 else if (!strcmp (drms_getkey_string (irec, "SITE", &status), "LE"))
00425 platform = LOC_GONG_LE;
00426 else if (!strcmp (drms_getkey_string (irec, "SITE", &status), "UD"))
00427 platform = LOC_GONG_UD;
00428 else if (!strcmp (drms_getkey_string (irec, "SITE", &status), "TD"))
00429 platform = LOC_GONG_TD;
00430 else if (!strcmp (drms_getkey_string (irec, "SITE", &status), "CT"))
00431 platform = LOC_GONG_CT;
00432 else if (!strcmp (drms_getkey_string (irec, "SITE", &status), "BB"))
00433 platform = LOC_GONG_BB;
00434 else if (!strcmp (drms_getkey_string (irec, "SITE", &status), "ML"))
00435 platform = LOC_GONG_ML;
00436 else {
00437 platform = LOC_GONG_MR;
00438 }
00439 } else {
00440 fprintf (stderr, "Warning: unspecified GONG site: MR assumed\n");
00441 platform = LOC_GONG_MR;
00442 }
00443 }
00444 }
00445 if (platform == LOC_UNKNOWN) {
00446 fprintf (stderr,
00447 "Warning: observing location unknown, assumed geocenter\n");
00448 }
00449 segct = drms_record_numsegments (irec);
00450
00451 if (strcmp (tmid_str, "Not Specified")) {
00452
00453
00454 if (sscanf (tmid_str, "%d:%lf", &tmid_cr, &tmid_cl) == 2) {
00455
00456 if (platform == LOC_SDO || platform == LOC_SOHO ||
00457 (platform >= LOC_GONG_MR && platform <= LOC_GONG_ML) ||
00458 platform == LOC_UNKNOWN) {
00459 if (platform == LOC_SOHO)
00460 tmid = SOHO_meridian_crossing (tmid_cl, tmid_cr);
00461 else
00462 tmid = earth_meridian_crossing (tmid_cl, tmid_cr);
00463 sprint_time (ptbuf, tmid, "", 0);
00464
00465 tbase = drms_getkey_time (irec, trec_key, &status);
00466 phase = fmod ((tmid - tbase), data_cadence);
00467 tmid -= phase;
00468 if (phase > 0.5 * data_cadence) tmid += data_cadence;
00469 if (verbose) {
00470 sprint_time (tbuf, tmid, "", 0);
00471 printf ("Target time %d:%05.1f = %s adjusted to %s\n",
00472 tmid_cr, tmid_cl, ptbuf, tbuf);
00473 }
00474 } else {
00475 fprintf (stderr,
00476 "Time specification in CR:CL for observing platform not supported\n");
00477 drms_free_record (irec);
00478 return 1;
00479 }
00480 } else {
00481
00482 tmid = sscan_time (tmid_str);
00483 }
00484 tbase = drms_getkey_time (irec, trec_key, &status);
00485 phase = fmod ((tmid - tbase), data_cadence);
00486 tstrt = tmid - 0.5 * length * tstep;
00487 tstop = tstrt + (length - 1) * tstep;
00488 if (tstop <= tstrt) {
00489 fprintf (stderr,
00490 "Error: requested end time before or at start time for ");
00491 fprintf (stderr, "length= %d\n", length);
00492 drms_free_record (irec);
00493 return 1;
00494 }
00495
00496 if ((fabs (phase) < 0.001 * t_eps) && length % 2)
00497 tstop += tstep;
00498 if ((fabs (phase - t_eps) < 0.001 * t_eps) && (length % 2 == 0))
00499 tstop += tstep;
00500 } else {
00501
00502 if (sscanf (tstrt_str, "%d:%lf", &tmid_cr, &tmid_cl) == 2) {
00503 if (platform == LOC_SOHO)
00504 tstrt = SOHO_meridian_crossing (tmid_cl, tmid_cr);
00505 else
00506 tstrt = earth_meridian_crossing (tmid_cl, tmid_cr);
00507 } else tstrt = sscan_time (tstrt_str);
00508 if (sscanf (tstop_str, "%d:%lf", &tmid_cr, &tmid_cl) == 2) {
00509 if (platform == LOC_SOHO)
00510 tstop = SOHO_meridian_crossing (tmid_cl, tmid_cr);
00511 else
00512 tstop = earth_meridian_crossing (tmid_cl, tmid_cr);
00513 } else tstop = sscan_time (tstop_str);
00514 length = (tstop - tstrt + 1.01 * tstep) / tstep;
00515 }
00516 drms_free_record (irec);
00517 if (pkeyslotted) {
00518 TIME pbase;
00519 double pstep;
00520 int tstrt_ind, tstop_ind;
00521 char pkeyindx[32], pkeyepoch[32], pkeystep[32];
00522
00523 sprintf (pkeyindx, "%s_index", trec_key);
00524 sprintf (pkeyepoch, "%s_epoch", trec_key);
00525 sprintf (pkeystep, "%s_step", trec_key);
00526 pbase = drms_getkey_time (irec, pkeyepoch, &status);
00527 pstep = drms_getkey_double (irec, pkeystep, &status);
00528 tstrt_ind = (tstrt - pbase) / pstep;
00529 tstop_ind = (tstop + t_eps - pbase) / pstep;
00530 snprintf (rec_query, 256, "%s[?%s between %d and %d?]", inset,
00531 pkeyindx, tstrt_ind, tstop_ind);
00532 } else {
00533 snprintf (rec_query, 256, "%s[?%s between %23.16e and %23.16e?]", inset,
00534 trec_key, tstrt - t_eps, tstop + t_eps);
00535 }
00536 if (!(ds = drms_open_recordset (drms_env, rec_query, &status))) {
00537 fprintf (stderr, "Error: unable to open input data set %s\n", rec_query);
00538 fprintf (stderr, " status = %d\n", status);
00539 drms_close_records (ds, DRMS_FREE_RECORD);
00540 return 1;
00541 }
00542 irec = drms_recordset_fetchnext (drms_env, ds, &status, NULL, NULL);
00543 if (!irec) {
00544 printf (" No records in selected input set\n");
00545 drms_close_records (ds, DRMS_FREE_RECORD);
00546 return 1;
00547 }
00548 tvec = drms_record_getvector (drms_env, rec_query, trec_key, DRMS_TYPE_DOUBLE,
00549 0, &status);
00550 recct = tvec->axis[1];
00551 if (recct < 2) {
00552 printf ("<2 records in selected input set\n");
00553 drms_free_array (tvec);
00554 drms_close_records (ds, DRMS_FREE_RECORD);
00555 return 0;
00556 }
00557 }
00558 drms_free_array (tvec);
00559
00560 if (verbose) {
00561 sprint_time (ptbuf, tstrt, "TAI", 0);
00562 sprint_time (tbuf, tstop, "TAI", 0);
00563 printf ("checking data from %s - %s\n at cadence of %.1f s\n", ptbuf, tbuf,
00564 tstep);
00565 printf (" %d data records\n", recct);
00566 }
00567
00568
00569
00570
00571
00572 rejects = 0;
00573 if (strcmp (rejectfile, "Not Specified")) {
00574 FILE *rejectfp = fopen (rejectfile, "r");
00575 if (rejectfp) rejects = read_reject_list (rejectfp, &reject_list);
00576 else fprintf (stderr,
00577 "Warning: could not open rejection list %s; ignored\n", rejectfile);
00578 }
00579
00580 found = 0;
00581
00582 valid = 0;
00583 badpkey = badqual = badfill = badtime = badpa = blacklist = 0;
00584 tlast = tstrt - 2 * tstep;
00585 for (nr = 0; nr < recct; nr++) {
00586 quality = drms_getkey_int (irec, qual_key, &status);
00587 if ((quality & qmask) && !status) {
00588
00589 badqual++;
00590 if (verbose) {
00591 drms_keyword_snprintfval (drms_keyword_lookup (irec, trec_key, 1),
00592 keyvalstr, DRMS_DEFVAL_MAXLEN);
00593 printf ("%s: %s = %08x matches %08x\n", keyvalstr, qual_key, quality,
00594 qmask);
00595 }
00596 irec = drms_recordset_fetchnext (drms_env, ds, &status, NULL, NULL);
00597 continue;
00598 }
00599 tobs = drms_getkey_time (irec, tobs_key, &status);
00600 if (time_is_invalid (tobs)) {
00601
00602 badpkey++;
00603 if (verbose) {
00604 drms_keyword_snprintfval (drms_keyword_lookup (irec, trec_key, 1),
00605 keyvalstr, DRMS_DEFVAL_MAXLEN);
00606 printf ("%s: %s invalid\n", keyvalstr, tobs_key);
00607 }
00608 irec = drms_recordset_fetchnext (drms_env, ds, &status, NULL, NULL);
00609 continue;
00610 } else {
00611 if (tobs == tlast) {
00612
00613 badtime++;
00614 if (verbose) {
00615 drms_keyword_snprintfval (drms_keyword_lookup (irec, trec_key, 1),
00616 keyvalstr, DRMS_DEFVAL_MAXLEN);
00617 printf ("%s: %s = ", keyvalstr, tobs_key);
00618 drms_keyword_snprintfval (drms_keyword_lookup (irec, tobs_key, 1),
00619 keyvalstr, DRMS_DEFVAL_MAXLEN);
00620 printf ("%s duplicated\n", keyvalstr);
00621 }
00622 irec = drms_recordset_fetchnext (drms_env, ds, &status, NULL, NULL);
00623 continue;
00624 }
00625 tlast = tobs;
00626 }
00627 blankvals = drms_getkey_int (irec, "MISSVALS", &status);
00628 if ((max_miss >= 0) && (blankvals > max_miss) && !status) {
00629
00630 badfill++;
00631 if (verbose) {
00632 drms_keyword_snprintfval (drms_keyword_lookup (irec, trec_key, 1),
00633 keyvalstr, DRMS_DEFVAL_MAXLEN);
00634 printf ("%s: %s = %d > %d\n", keyvalstr, "MISSVALS", blankvals,
00635 max_miss);
00636 }
00637 irec = drms_recordset_fetchnext (drms_env, ds, &status, NULL, NULL);
00638 continue;
00639 }
00640 if (check_pa) {
00641
00642 pa_rec = drms_getkey_float (irec, pang_key, &status);
00643 if (status) {
00644 fprintf (stderr, "Warning: \"%s\" keyword not found\n", pang_key);
00645 fprintf (stderr, " no limits on rotation angle\n");
00646 check_pa = 0;
00647 dpa_max = 360.0;
00648 }
00649 if (isfinite (pa_rec)) {
00650 dpa = fabs (pa_rec - pa_nom);
00651 while (dpa > 180.0) dpa -= 360.0;
00652 while (dpa < 0.0) dpa += 360.0;
00653 if (dpa > dpa_max) {
00654 badpa++;
00655 if (verbose) {
00656 drms_keyword_snprintfval (drms_keyword_lookup (irec, pang_key, 1),
00657 keyvalstr, DRMS_DEFVAL_MAXLEN);
00658 printf ("%s: |%s - %.2f] = %.2f > %.2f\n", keyvalstr, pang_key,
00659 pa_nom, dpa, dpa_max);
00660 }
00661 irec = drms_recordset_fetchnext (drms_env, ds, &status, NULL, NULL);
00662 continue;
00663 }
00664 }
00665 }
00666
00667 img_lon = drms_getkey_double (irec, clon_key, &status);
00668 img_lat = drms_getkey_double (irec, clat_key, &status);
00669
00670 if (rejects) {
00671 int idrec = drms_getkey_int (irec, "T_REC_index", &status);
00672 int match = 0;
00673 if (status) {
00674 fprintf (stderr, "Warning: \"T_REC_index\" keyword not found\n");
00675 fprintf (stderr, " up to %d bad images could be processed\n",
00676 rejects);
00677 rejects = 0;
00678 }
00679 for (n = 0; n < rejects; n++) {
00680 if (idrec == reject_list[n]) {
00681 match = 1;
00682 break;
00683 }
00684 }
00685 if (match) {
00686 blacklist++;
00687 irec = drms_recordset_fetchnext (drms_env, ds, &status, NULL, NULL);
00688 continue;
00689 }
00690 }
00691
00692 valid++;
00693 irec = drms_recordset_fetchnext (drms_env, ds, &status, NULL, NULL);
00694 }
00695
00696 drms_close_records (ds, DRMS_FREE_RECORD);
00697
00698 coverage = (double)valid / (double)length;
00699 printf ("%d of %d possible input records accepted\n", valid, recct);
00700 printf (" effective coverage = %.3f\n", coverage);
00701 if (badqual)
00702 printf (" %d input records rejected for quality matching %08x\n",
00703 badqual, qmask);
00704 if (badpkey)
00705 printf (" %d input records rejected for invalid values of %s\n",
00706 badpkey, tobs_key);
00707 if (badtime)
00708 printf (" %d input records rejected for duplicate values of %s\n",
00709 badtime, tobs_key);
00710 if (badfill)
00711 printf (" %d input records rejected for missing values exceeding %d\n",
00712 badfill, max_miss);
00713 if (badpa)
00714 printf (" %d input records rejected for PA more than %.2f from %.2f\n",
00715 badpa, dpa_max, pa_nom);
00716 if (blacklist)
00717 printf (" %d input records rejected from rejection list\n", blacklist);
00718 return 0;
00719 }
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754