IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 22, 2011, 12:40:23 AM (15 years ago)
Author:
eugene
Message:

merge from trunk: various details, see eam/ipp-20110505

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/zplot.c

    r20936 r31667  
    5858}
    5959
     60int zcplot (int argc, char **argv) {
     61 
     62  int i, kapa;
     63  opihi_flt *out;
     64  double min, range;
     65  Graphdata graphmode;
     66  Vector *xvec, *yvec, *zvec, Zvec;
    6067
     68  if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
     69
     70  if (argc != 6) {
     71    gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n");
     72    return (FALSE);
     73  }
     74
     75  min = atof(argv[4]);
     76  range = atof(argv[5]) - min;
     77
     78  /* find vectors */
     79  if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     80  if ((yvec = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     81  if ((zvec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     82  if (xvec[0].Nelements != yvec[0].Nelements) {
     83    gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[2]);
     84    return (FALSE);
     85  }
     86  if (xvec[0].Nelements != zvec[0].Nelements) {
     87    gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]);
     88    return (FALSE);
     89  }
     90  SetVector (&Zvec, OPIHI_FLT, zvec[0].Nelements);
     91  out = Zvec.elements.Flt;
     92 
     93  if (zvec[0].type == OPIHI_FLT) {
     94    opihi_flt *in = zvec[0].elements.Flt;
     95    for (i = 0; i < Zvec.Nelements; i++, in++, out++) {
     96      *out = MIN (1.0, MAX (0.01, (*in - min) / range));
     97    }
     98  } else {
     99    opihi_int *in = zvec[0].elements.Int;
     100    for (i = 0; i < Zvec.Nelements; i++, in++, out++) {
     101      *out = MIN (1.0, MAX (0.01, (*in - min) / range));
     102    }
     103  }
     104
     105  /* point size determined by Zvec */
     106  graphmode.style = 2; /* plot points */
     107  graphmode.color = -1; /* point color determined by Zvec */
     108  graphmode.etype = 0; /* no errorbars */
     109  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);
     110
     111  free (Zvec.elements.Ptr);
     112
     113  return (TRUE);
     114
     115}
     116
     117
Note: See TracChangeset for help on using the changeset viewer.