IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 30, 2012, 1:46:12 PM (14 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20120405

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana/src/opihi/cmd.data/write_vectors.c

    r33662 r33963  
    2121  FITS = NULL;
    2222  if ((N = get_argument (argc, argv, "-fits"))) {
     23    if (format) {
     24      gprint (GP_ERR, "ERROR: do not mix -fits and -format\n");
     25      free (format);
     26      return (FALSE);
     27    }
    2328    remove_argument (N, &argc, argv);
    2429    FITS = strcreate (argv[N]);
    2530    remove_argument (N, &argc, argv);
     31  }
     32
     33  /* option generate a FITS output table */
     34  int CSV = FALSE;
     35  if ((N = get_argument (argc, argv, "-csv"))) {
     36    if (format) {
     37      gprint (GP_ERR, "ERROR: do not mix -csv and -format\n");
     38      free (format);
     39      return (FALSE);
     40    }
     41    if (FITS) {
     42      gprint (GP_ERR, "ERROR: do not mix -csv and -fits\n");
     43      free (FITS);
     44      return (FALSE);
     45    }
     46    remove_argument (N, &argc, argv);
     47    CSV = TRUE;
    2648  }
    2749
     
    3052    remove_argument (N, &argc, argv);
    3153    append = TRUE;
     54  }
     55
     56  int ADD_HEADER = FALSE;
     57  if ((N = get_argument (argc, argv, "-header"))) {
     58    remove_argument (N, &argc, argv);
     59    ADD_HEADER = TRUE;
    3260  }
    3361
     
    83111
    84112  /* default output format */
     113  if (ADD_HEADER) {
     114    for (j = 0; j < Nvec; j++) {
     115      if (CSV) {
     116        fprintf (f, "%s,", vec[j][0].name);
     117      } else {
     118        if (j == 0) fprintf (f, "# ");
     119        fprintf (f, "%s ", vec[j][0].name);
     120      }
     121    }
     122    fprintf (f, "\n");
     123  }
     124
     125  /* default output format */
    85126  if (format == (char *) NULL) {
    86127    for (i = 0; i < vec[0][0].Nelements; i++) {
    87128      for (j = 0; j < Nvec; j++) {
    88129        if (vec[j][0].type == OPIHI_FLT) {
    89           fprintf (f, "%.12g ", vec[j][0].elements.Flt[i]);
     130          if (CSV) {
     131            fprintf (f, "%.12g,", vec[j][0].elements.Flt[i]);
     132          } else {
     133            fprintf (f, "%.12g ", vec[j][0].elements.Flt[i]);
     134          }
    90135        } else {
    91           fprintf (f, "%d ", vec[j][0].elements.Int[i]);
     136          if (CSV) {
     137            fprintf (f, "%d,", vec[j][0].elements.Int[i]);
     138          } else {
     139            fprintf (f, "%d ", vec[j][0].elements.Int[i]);
     140          }
    92141        }
    93142      }
Note: See TracChangeset for help on using the changeset viewer.