Beispiel #1
0
/**
 * Main function for command-line filter utility.
 */
int main(int argc, char *argv[]) 
{
#ifndef HAVE_G_OPTION_GROUP
  printf("Need GLib >= 2.6\n");
#else

  GError *error;
  GOptionContext *context;
  char inFilename[FLEN_FILENAME], outFilename[FLEN_FILENAME];
  oi_fits inData, outData;
  int status;

  /* Parse command-line */
  error = NULL;
  context =
    g_option_context_new("INFILE OUTFILE - write filtered dataset to new file");
  g_option_context_set_main_group(context, get_oi_filter_option_group());
  g_option_context_parse(context, &argc, &argv, &error);
  if(error != NULL) {
    printf("Error parsing command-line options: %s\n", error->message);
    g_error_free(error);
    exit(2); /* standard unix behaviour */
  }
  if(argc != 3) {
    printf("Wrong number of command-line arguments\n"
	   "Enter '%s --help' for usage information\n", argv[0]);
    exit(2);
  }
  g_strlcpy(inFilename, argv[1], FLEN_FILENAME);
  g_strlcpy(outFilename, argv[2], FLEN_FILENAME);

  /* Read FITS file */
  status = 0;
  read_oi_fits(inFilename, &inData, &status);
  if(status) goto except;

  /* Display summary info */
  printf("=== INPUT DATA: ===\n");
  print_oi_fits_summary(&inData);
  printf("=== Applying filter: ===\n");
  print_oi_filter(get_user_oi_filter());

  /* Apply filter */
  apply_user_oi_filter(&inData, &outData);
  printf("--> OUTPUT DATA: ===\n");
  print_oi_fits_summary(&outData);

  /* Write out filtered data */
  write_oi_fits(outFilename, outData, &status);
  if(status) goto except;

  free_oi_fits(&inData);
  free_oi_fits(&outData);
  g_option_context_free(context);
  exit(EXIT_SUCCESS);

 except:
  exit(EXIT_FAILURE);
#endif /* #ifndef HAVE_G_OPTION_GROUP */
}
Beispiel #2
0
/**
 * Main function for command-line check utility
 */
int main(int argc, char *argv[])
{
  /** Checking functions to call */
  check_func checks[] = {
    check_tables,
    check_header,
    check_keywords,
    check_visrefmap,
    check_unique_targets,
    check_targets_present,
    check_arrname,
    check_elements_present,
    check_corr_present,
    check_flagging,
    check_t3amp,
    check_waveorder,
    check_time,
    check_flux,
    NULL
  };
  oi_fits oi;
  oi_check_result result;
  oi_breach_level worst;
  char filename[FLEN_FILENAME];
  int status, i;

  /* Parse command-line */
  if (argc != 2) {
    printf("Usage:\n%s FILE\n", argv[0]);
    exit(2); /* standard unix behaviour */
  }
  (void)g_strlcpy(filename, argv[1], FLEN_FILENAME);

  /* Read FITS file */
  status = 0;
  read_oi_fits(filename, &oi, &status);
  if (status) goto except;

  /* Display summary info */
  print_oi_fits_summary(&oi);

  /* Run checks */
  worst = OI_BREACH_NONE;
  i = 0;
  while (checks[i] != NULL) {
    if ((*checks[i++])(&oi, &result) != OI_BREACH_NONE) {
      print_check_result(&result);
      if (result.level > worst) worst = result.level;
    }
    free_check_result(&result);
  }

  if (worst == OI_BREACH_NONE)
    printf("All checks passed\n");

  free_oi_fits(&oi);
  exit(EXIT_SUCCESS);

except:
  exit(EXIT_FAILURE);
}