IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 16, 2012, 4:27:16 PM (14 years ago)
Author:
eugene
Message:

add -incl option to for loops (include end point if appropriate; eg 0 1 2 3 [4], but not 0 2 4 [5]); add -frac option to dot command; add -csv output option to write; add -header option to text and csv output modes

Location:
branches/eam_branches/ipp-20120405/Ohana/src/opihi/cmd.data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120405/Ohana/src/opihi/cmd.data/dot.c

    r14181 r33882  
    33int dot (int argc, char **argv) {
    44 
    5   int kapa;
     5  int kapa, N;
    66  Graphdata graphmode;
    77  float x, y;
    88
    99  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
     10
     11  /* FracPositions uses coordinates of 0-1 relative to axis range */
     12  int FracPositions = FALSE;
     13  if ((N = get_argument (argc, argv, "-frac"))) {
     14    remove_argument (N, &argc, argv);
     15    FracPositions = TRUE;
     16  }
    1017
    1118  if (argc != 3) {
     
    1522  x = atof(argv[1]);
    1623  y = atof(argv[2]);
     24
     25  if (FracPositions) {
     26    x =  x * (graphmode.xmax - graphmode.xmin) + graphmode.xmin;
     27    y =  y * (graphmode.ymax - graphmode.ymin) + graphmode.ymin;
     28  }   
    1729
    1830  /* set point style and errorbar mode (these are NOT sticky) */
  • branches/eam_branches/ipp-20120405/Ohana/src/opihi/cmd.data/write_vectors.c

    r33662 r33882  
    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.