IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 27, 2018, 3:20:35 PM (8 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/czw_branch/20170908/Ohana
Files:
77 edited
19 copied

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20170908/Ohana

  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/Makefile

    r39591 r40477  
    8282$(SRC)/wcs.$(ARCH).o         \
    8383$(SRC)/imsub.$(ARCH).o             \
     84$(SRC)/jdtolst.$(ARCH).o                   \
    8485$(SRC)/imfit.$(ARCH).o             \
    8586$(SRC)/imfit-fgauss.$(ARCH).o      \
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/cdot.c

    r34088 r40477  
    2222
    2323  /* set point style and errorbar mode (these are NOT sticky) */
    24   graphmode.style = 2;
     24  graphmode.style = KAPA_PLOT_POINTS; /* points */
    2525  graphmode.etype = 0;
    2626
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/cgrid.c

    r34584 r40477  
    9595  }
    9696
     97  int JustifyRA = 5;
     98  double JustifyDEC = 5;
     99  if ((N = get_argument (argc, argv, "-justify-ra"))) {
     100    remove_argument (N, &argc, argv);
     101    JustifyRA = atoi (argv[N]);
     102    remove_argument (N, &argc, argv);
     103  }
     104  if ((N = get_argument (argc, argv, "-justify-dec"))) {
     105    remove_argument (N, &argc, argv);
     106    JustifyDEC = atoi (argv[N]);
     107    remove_argument (N, &argc, argv);
     108  }
     109
     110  double LabelRA = NAN;
     111  double LabelDEC = NAN;
     112  if ((N = get_argument (argc, argv, "-label-ra"))) {
     113    remove_argument (N, &argc, argv);
     114    LabelRA = atof (argv[N]);
     115    remove_argument (N, &argc, argv);
     116  }
     117  if ((N = get_argument (argc, argv, "-label-dec"))) {
     118    remove_argument (N, &argc, argv);
     119    LabelDEC = atof (argv[N]);
     120    remove_argument (N, &argc, argv);
     121  }
     122
     123  int LabelColor = KapaColorByName ("black");
     124  if ((N = get_argument (argc, argv, "-label-color"))) {
     125    remove_argument (N, &argc, argv);
     126    LabelColor = KapaColorByName (argv[N]);
     127    if (LabelColor == -1) return (FALSE);
     128    remove_argument (N, &argc, argv);
     129  }
     130
    97131  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
    98132
     
    196230  if (Labels) {
    197231    char line[16], format[8];
    198     double xt, yt, dx, dy, frac;
    199     dx = +0.01 * (graphmode.xmax - graphmode.xmin);
    200     dy = -0.02 * (graphmode.ymax - graphmode.ymin);
    201 
     232    double xt, yt, frac;
     233    // dx = +0.01 * (graphmode.xmax - graphmode.xmin);
     234    // dy = -0.02 * (graphmode.ymax - graphmode.ymin);
     235
     236    if (isnan(LabelRA)) LabelRA = graphmode.coords.crval1;
     237    if (isnan(LabelDEC)) LabelDEC = graphmode.coords.crval2;
    202238    for (r = firstRA; r <= graphmode.coords.crval1 + 180.0; r += minorRA) {
    203       status = RD_to_XY (&xt, &yt, r, graphmode.coords.crval2, &graphmode.coords);
     239      status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords);
    204240      if (!status) continue;
    205241      if (xt < graphmode.xmin) continue;
     
    212248      }
    213249      if (frac <= 0.0) frac = 0.0;
    214       snprintf (format, 8, "%%.%df", (int) frac);
    215250      if (RAbyHour) {
     251        snprintf (format, 8, "%%.%df^h", (int) frac);
    216252        snprintf (line, 16, format, r / 15.0);
    217253      } else {
     254        snprintf (format, 8, "%%.%df^o", (int) frac);
    218255        snprintf (line, 16, format, r);
    219256      }
    220       KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
     257      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyRA, LabelColor);
    221258    }
    222259    for (r = firstRA; r >= graphmode.coords.crval1 - 180.0; r -= minorRA) {
    223       status = RD_to_XY (&xt, &yt, r, graphmode.coords.crval2, &graphmode.coords);
     260      status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords);
    224261      if (!status) continue;
    225262      if (xt < graphmode.xmin) continue;
     
    232269      }
    233270      if (frac <= 0.0) frac = 0.0;
    234       snprintf (format, 8, "%%.%df", (int) frac);
    235271      if (RAbyHour) {
     272        snprintf (format, 8, "%%.%df^h", (int) frac);
    236273        snprintf (line, 16, format, r / 15.0);
    237274      } else {
     275        snprintf (format, 8, "%%.%df^o", (int) frac);
    238276        snprintf (line, 16, format, r);
    239277      }
    240       KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
     278      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyRA, LabelColor);
    241279    }
    242280    for (d = firstDEC; d <= graphmode.coords.crval2 + 90.0; d += minorDEC) {
    243       status = RD_to_XY (&xt, &yt, graphmode.coords.crval1, d, &graphmode.coords);
     281      status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords);
    244282      if (!status) continue;
    245283      if (xt < graphmode.xmin) continue;
     
    252290      }
    253291      if (frac <= 0.0) frac = 0.0;
    254       snprintf (format, 8, "%%.%df", (int) frac);
     292      snprintf (format, 8, "%%.%df^o", (int) frac);
    255293      snprintf (line, 16, format, d);
    256       KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
     294      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyDEC, LabelColor);
    257295    }
    258296    for (d = firstDEC; d >= graphmode.coords.crval2 - 90.0; d -= minorDEC) {
    259       status = RD_to_XY (&xt, &yt, graphmode.coords.crval1, d, &graphmode.coords);
     297      status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords);
    260298      if (!status) continue;
    261299      if (xt < graphmode.xmin) continue;
     
    268306      }
    269307      if (frac <= 0.0) frac = 0.0;
    270       snprintf (format, 8, "%%.%df", (int) frac);
     308      snprintf (format, 8, "%%.%df^o", (int) frac);
    271309      snprintf (line, 16, format, d);
    272       KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
     310      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyDEC, LabelColor);
    273311    }
    274312  }
     
    276314  /* send the line segments as connect-points */
    277315  Xvec.Nelements = Yvec.Nelements = N;
    278   graphmode.style = 2; /* points */
    279   graphmode.ptype = 100; /* connect a pair */
     316  graphmode.style = KAPA_PLOT_POINTS; /* points */
     317  graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    280318  graphmode.etype = 0;
    281319  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/cline.c

    r34088 r40477  
    2020
    2121  /* set point style and errorbar mode (these are NOT sticky) */
    22   graphmode.style = 0;
     22  graphmode.style = KAPA_PLOT_CONNECT;
    2323  graphmode.etype = 0;
    2424
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/czplot.c

    r35757 r40477  
    111111  Zvec.Nelements = Npts;
    112112
    113   graphmode.style = 2;
     113  graphmode.style = KAPA_PLOT_POINTS; /* points */
    114114  graphmode.size = -1; /* point size determined by Zvec */
    115115  graphmode.etype = 0;
     
    236236  Zvec.Nelements = Npts;
    237237
    238   graphmode.style = 2;
     238  graphmode.style = KAPA_PLOT_POINTS;
    239239  graphmode.color = -1; /* point color determined by Zvec */
    240240  graphmode.etype = 0;
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/fitplx.c

    r39610 r40477  
    7777  double *dD = dDvec->elements.Flt;
    7878
    79   int *mask = NULL;
     79  opihi_int *mask = NULL;
    8080  if (mvec) {
    8181    mask = mvec->elements.Int;
     
    380380}
    381381
    382 int PlxSetMeanEpoch (double *R, double *D, double *T, double *Rmean, double *Dmean, double *Tmean, int *mask, int Ntotal) {
     382int PlxSetMeanEpoch (double *R, double *D, double *T, double *Rmean, double *Dmean, double *Tmean, opihi_int *mask, int Ntotal) {
    383383
    384384  int i;
     
    413413
    414414// generate the fit values (projected X,Y; parallax factors;
    415 int PlxSetEpochPosition (PlxFitData *fitdata, double *R, double *D, double *dR, double *dD, double *T, int *mask, int Ntotal, Coords *coords, double Tmean) {
     415int PlxSetEpochPosition (PlxFitData *fitdata, double *R, double *D, double *dR, double *dD, double *T, opihi_int *mask, int Ntotal, Coords *coords, double Tmean) {
    416416
    417417  int i;
     
    464464# define MAX_REJECT 0.1
    465465
    466 int PlxOutlierClip (PlxFitData *fitdata, int *mask, int Noutlier, float dPsigMax, Vector *dPvec, int VERBOSE) {
     466int PlxOutlierClip (PlxFitData *fitdata, opihi_int *mask, int Noutlier, float dPsigMax, Vector *dPvec, int VERBOSE) {
    467467
    468468  int i, n;
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/fitplx_irls.c

    r39926 r40477  
    1212    if ((mvec = SelectVector (argv[N], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    1313    remove_argument (N, &argc, argv);
    14     CastVector (mvec, OPIHI_INT);
    1514  }
    1615
     
    8180  double *dD = dDvec->elements.Flt;
    8281
    83   int *mask = NULL;
    84   if (mvec) {
    85     mask = mvec->elements.Int;
    86   }
    87 
    8882  // Ntotal : all points supplied by user
    8983  // Nsubset : unmasked points
    9084  int Ntotal = tvec->Nelements; // XXX check other lengths
    91  
     85
     86  if (rvec->Nelements  != Ntotal) ESCAPE ("mis-match in vector lengths (mjd vs ra)  = (%d vs %d)\n", rvec->Nelements, Ntotal);
     87  if (dvec->Nelements  != Ntotal) ESCAPE ("mis-match in vector lengths (mjd vs dec) = (%d vs %d)\n", dvec->Nelements, Ntotal);
     88  if (dRvec->Nelements != Ntotal) ESCAPE ("mis-match in vector lengths (mjd vs dR)  = (%d vs %d)\n", dRvec->Nelements, Ntotal);
     89  if (dDvec->Nelements != Ntotal) ESCAPE ("mis-match in vector lengths (mjd vs dD)  = (%d vs %d)\n", dDvec->Nelements, Ntotal);
     90 
     91  opihi_int *mask = NULL;
     92  if (mvec) {
     93    ResetVector (mvec, OPIHI_INT, Ntotal);
     94    mask = mvec->elements.Int;
     95    for (i = 0; i < Ntotal; i++) { mask[i] = 1; }
     96  }
     97
     98
    9299  double Rmean, Dmean, Tmean;
    93100  PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal);
     
    109116  for (i = 0; (VERBOSE == 2) && (i < fitdata.Npts); i++) {
    110117    int n = fitdata.index[i];
    111     int maskValue = mask ? mask[n] : 1;
    112     fprintf (stderr, "%f %f : %f %d : %f %f %f\n", R[n], D[n], T[n], maskValue, fitdata.t[i], fitdata.X[i], fitdata.Y[i]);
     118    opihi_int maskValue = mask ? mask[n] : 1;
     119    fprintf (stderr, "%f %f : %f "OPIHI_INT_FMT" : %f %f %f\n", R[n], D[n], T[n], maskValue, fitdata.t[i], fitdata.X[i], fitdata.Y[i]);
    113120  }
    114121
     
    135142
    136143  // update the mask based on the input mask and the outlier limits.
    137   double Sum_Wx = 0;
    138   double Sum_Wy = 0;
    139   mask = mvec->elements.Int;
    140   for (i = 0; i < fitdata.Npts; i++) {
    141     Sum_Wx += fitdata.Wx[i];
    142     Sum_Wy += fitdata.Wy[i];
    143   }
    144   for (i = 0; i < fitdata.Npts; i++) {
    145     // fitdata only includes the previously unmasked points
    146     if ((fitdata.Wx[i] < outlier_limit * Sum_Wx / (1.0 * fitdata.Npts))||
    147         (fitdata.Wy[i] < outlier_limit * Sum_Wy / (1.0 * fitdata.Npts))) {
    148       int n = fitdata.index[i];
    149       mask[n] = 0;
     144  if (mask) {
     145    double Sum_Wx = 0;
     146    double Sum_Wy = 0;
     147   
     148    // calculate the total weight
     149    for (i = 0; i < fitdata.Npts; i++) {
     150      Sum_Wx += fitdata.Wx[i];
     151      Sum_Wy += fitdata.Wy[i];
     152    }
     153    for (i = 0; i < fitdata.Npts; i++) {
     154      // fitdata only includes the previously unmasked points
     155      if ((fitdata.Wx[i] < outlier_limit * Sum_Wx / (1.0 * fitdata.Npts))||
     156          (fitdata.Wy[i] < outlier_limit * Sum_Wy / (1.0 * fitdata.Npts))) {
     157        int n = fitdata.index[i];
     158        mask[n] = 0;
    150159     
    151       if (VERBOSE == 2) {
    152           fprintf (stderr, "%f %f : %f %d : %f %f %f : %f %f %f %f\n", R[n], D[n], T[n], mask[n], fitdata.t[i], fitdata.X[i], fitdata.Y[i], fitdata.Wx[i], fitdata.Wy[i], Sum_Wx, Sum_Wy);
    153       }
    154     }
    155   }
    156 
    157   if (Nresample){
    158     // now that the mask has been updated, we need to recalculate mean epoch and positions
    159     // XXX make this conditional on actually masking unmasked points above
    160     // PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal);
    161     // PlxSetEpochPosition (&fitdata, R, D, dR, dD, T, mask, Ntotal, &coords, Tmean);
     160        if (VERBOSE == 2) {
     161          fprintf (stderr, "%f %f : %f "OPIHI_INT_FMT" : %f %f %f : %f %f %f %f\n", R[n], D[n], T[n], mask[n], fitdata.t[i], fitdata.X[i], fitdata.Y[i], fitdata.Wx[i], fitdata.Wy[i], Sum_Wx, Sum_Wy);
     162        }
     163      }
     164    }
     165  }
     166
     167  if (Nresample) {
     168    // if the mask has been updated, we need to recalculate mean epoch and positions
     169    if (mask) {
     170      PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal);
     171      PlxSetEpochPosition (&fitdata, R, D, dR, dD, T, mask, Ntotal, &coords, Tmean);
     172    }
    162173
    163174    PlxFitData sample;
     
    218229  // fprintf (stderr, "%f +/- %f | %f %f\n", fit.p, fit.dp, fit.uR, fit.uD);
    219230
    220   Vector *dRresPMP, *dDresPMP, *dRresPLX, *dDresPLX;
     231  Vector *dRresPOS, *dDresPOS, *dRresPMP, *dDresPMP, *dRresPLX, *dDresPLX;
    221232
    222233  // save fit residuals (with only pm removed, and pm and plx removed)
     234  if ((dRresPOS = SelectVector ("dRresPOS", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dRresPOS");
     235  if ((dDresPOS = SelectVector ("dDresPOS", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dDresPOS");
    223236  if ((dRresPMP = SelectVector ("dRresPMP", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dRresPMP");
    224237  if ((dDresPMP = SelectVector ("dDresPMP", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dDresPMP");
     
    226239  if ((dDresPLX = SelectVector ("dDresPLX", ANYVECTOR, TRUE)) == NULL) ESCAPE ("cannot generate vector %s\n", "dDresPLX");
    227240   
     241  ResetVector (dRresPOS, OPIHI_FLT, Ntotal);
     242  ResetVector (dDresPOS, OPIHI_FLT, Ntotal);
    228243  ResetVector (dRresPMP, OPIHI_FLT, Ntotal);
    229244  ResetVector (dDresPMP, OPIHI_FLT, Ntotal);
     
    246261    double Yplx = fit.Do + fit.uD*t0;
    247262
     263    dRresPOS->elements.Flt[i] = x0;
     264    dDresPOS->elements.Flt[i] = y0;
    248265    dRresPMP->elements.Flt[i] = x0 - Xpmp;
    249266    dDresPMP->elements.Flt[i] = y0 - Ypmp;
     
    538555
    539556    double wx,wy;
     557    double lim_Wx = outlier_limit * Sum_Wx / (1.0 * Npts);
     558    double lim_Wy = outlier_limit * Sum_Wy / (1.0 * Npts);
    540559    for (i = 0; i < Npts; i++) {
    541       if ((Wx[i] > outlier_limit * Sum_Wx / (1.0 * Npts))||
    542           (Wy[i] > outlier_limit * Sum_Wy / (1.0 * Npts))) {
    543        
     560      int skip = (Wx[i] < lim_Wx) || (Wy[i] < lim_Wy);
     561      if (!skip) {
    544562        Xf = fit[0].Ro + fit[0].uR*T[i] + fit[0].p*pR[i];
    545563        Yf = fit[0].Do + fit[0].uD*T[i] + fit[0].p*pD[i];
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/fitpm.c

    r39228 r40477  
    5050  double *dD = dDvec->elements.Flt;
    5151
    52   int *mask = NULL;
     52  opihi_int *mask = NULL;
    5353  if (mvec) {
    5454    mask = mvec->elements.Int;
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/fitpm_irls.c

    r39596 r40477  
    5858  double *dD = dDvec->elements.Flt;
    5959
    60   int *mask = NULL;
     60  opihi_int *mask = NULL;
    6161  if (mvec) {
    6262    mask = mvec->elements.Int;
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/init.c

    r39591 r40477  
    3333int imfit                   PROTO((int, char **));
    3434int imsub                   PROTO((int, char **));
     35int jdtolst                 PROTO((int, char **));
    3536int medianmap               PROTO((int, char **));
    3637int galsectors              PROTO((int, char **));
     
    103104  {1, "imfit",       imfit,        "fit function"},
    104105  {1, "imsub",       imsub,        "subtract function"},
     106  {1, "jdtolst",     jdtolst,      "JD to LST conversion"},
    105107  {1, "medianmap",   medianmap,    "small median image"},
    106108  {1, "mkgauss",     mkgauss,      "generate a 2-D gaussian centered in image"},
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.astro/star.c

    r36679 r40477  
    33int star (int argc, char **argv) {
    44
    5   int x, y, N, dx, Nborder;
     5  int x, y, N, Nborder;
    66  double max;
    77  Buffer *buf;
     
    3333  }
    3434 
     35  int dx = 11;
     36  int dy = 11;
     37  int BOX = FALSE;
     38  if ((N = get_argument (argc, argv, "-box"))) {
     39    remove_argument (N, &argc, argv);
     40    dx  = atoi(argv[N]);
     41    remove_argument (N, &argc, argv);
     42    dy  = atoi(argv[N]);
     43    remove_argument (N, &argc, argv);
     44    BOX = TRUE;
     45  }
     46
    3547  if ((argc != 4) && (argc != 5)) {
    36     gprint (GP_ERR, "USAGE: star (buffer) x y [dx] [-border N] [-sat cnts]\n");
     48    gprint (GP_ERR, "USAGE: star (buffer) x y [dx] [-border N] [-sat cnts] [-box dx dy]\n");
    3749    gprint (GP_ERR, " dx is the aperture diameter, but is adjusted up to the next odd number\n");
    3850    return (FALSE);
     
    4052  if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE);
    4153
    42   dx = 11;
    4354  x = atof (argv[2]);
    4455  y = atof (argv[3]);
     
    4758  }
    4859
    49   get_aperture_stats (&buf[0].matrix, x, y, dx, Nborder, max, VERBOSE);
     60  if (BOX) {
     61    get_box_stats (&buf[0].matrix, x, y, dx, dy, Nborder, max, VERBOSE);
     62  } else {
     63    get_aperture_stats (&buf[0].matrix, x, y, dx, Nborder, max, VERBOSE);
     64  }
    5065 
    5166  return (TRUE);
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/Makefile

    r40007 r40477  
    6666$(SRC)/hermitian1d.$(ARCH).o    \
    6767$(SRC)/hermitian2d.$(ARCH).o    \
     68$(SRC)/idxread.$(ARCH).o                \
    6869$(SRC)/imcut.$(ARCH).o          \
    6970$(SRC)/imhist.$(ARCH).o \
     
    99100$(SRC)/medimage_commands.$(ARCH).o \
    100101$(SRC)/mset.$(ARCH).o           \
    101 $(SRC)/needles.$(ARCH).o                \
     102$(SRC)/needles.$(ARCH).o        \
     103$(SRC)/nnet.$(ARCH).o           \
     104$(SRC)/nnet_commands.$(ARCH).o  \
     105$(SRC)/nnet_train.$(ARCH).o     \
     106$(SRC)/nnet_apply.$(ARCH).o     \
    102107$(SRC)/peak.$(ARCH).o           \
    103108$(SRC)/periodogram.$(ARCH).o    \
     109$(SRC)/periodogram-fm.$(ARCH).o \
    104110$(SRC)/plot.$(ARCH).o           \
    105111$(SRC)/dot.$(ARCH).o            \
     
    154160$(SRC)/type.$(ARCH).o              \
    155161$(SRC)/uniq.$(ARCH).o              \
     162$(SRC)/uniqpair.$(ARCH).o                  \
    156163$(SRC)/unsign.$(ARCH).o            \
    157164$(SRC)/vbin.$(ARCH).o              \
     
    159166$(SRC)/vclip.$(ARCH).o             \
    160167$(SRC)/vgauss.$(ARCH).o            \
     168$(SRC)/vlorentz.$(ARCH).o          \
    161169$(SRC)/vellipse.$(ARCH).o          \
    162170$(SRC)/vmaxwell.$(ARCH).o          \
     
    171179$(SRC)/vstats.$(ARCH).o            \
    172180$(SRC)/xsection.$(ARCH).o          \
    173 $(SRC)/vsh.$(ARCH).o       \
     181$(SRC)/vsh.$(ARCH).o               \
    174182$(SRC)/vshfit.$(ARCH).o    \
    175183$(SRC)/shterms.$(ARCH).o           \
     
    187195$(INC)/external.h \
    188196$(INC)/shell.h \
     197$(INC)/data.h \
    189198$(INC)/dvomath.h \
    190199$(INC)/display.h
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/dot.c

    r33963 r40477  
    2929
    3030  /* set point style and errorbar mode (these are NOT sticky) */
    31   graphmode.style = 2;
     31  graphmode.style = KAPA_PLOT_POINTS;
    3232  graphmode.etype = 0;
    3333
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/grid.c

    r34584 r40477  
    175175
    176176  Xvec.Nelements = Yvec.Nelements = N;
    177   graphmode.style = 2; /* points */
    178   graphmode.ptype = 100; /* connect a pair */
     177  graphmode.style = KAPA_PLOT_POINTS; /* points */
     178  graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    179179  graphmode.etype = 0;
    180180  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/impeaks.c

    r36679 r40477  
    100100  int Npeaks = 0;
    101101  for (ix = 1; ix < Nx - 1; ix++) {
     102    if (!isfinite(row[ix])) continue; // ignore NAN values
    102103    if (row[ix] <  threshold) continue;   // only accept pixels above threshold
    103104    if (row[ix] <  row[ix - 1]) continue; // peak pixel must be at least preceeding pixel
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/init.c

    r40007 r40477  
    5555int hermitian1d      PROTO((int, char **));
    5656int hermitian2d      PROTO((int, char **));
     57int idxread          PROTO((int, char **));
    5758int imcut            PROTO((int, char **));
    5859int imhist           PROTO((int, char **));
     
    8990int mset             PROTO((int, char **));
    9091int needles          PROTO((int, char **));
     92int nnet_command     PROTO((int, char **));
    9193int peak             PROTO((int, char **));
    9294int periodogram      PROTO((int, char **));
     95int periodogram_fm   PROTO((int, char **));
    9396int plot             PROTO((int, char **));
    9497int dot              PROTO((int, char **));
     
    140143int tvcontour        PROTO((int, char **));
    141144int tvgrid           PROTO((int, char **));
    142 int opihi_type             PROTO((int, char **));
     145int opihi_type       PROTO((int, char **));
    143146int uniq             PROTO((int, char **));
     147int uniqpair         PROTO((int, char **));
    144148int unsign           PROTO((int, char **));
    145149int vbin             PROTO((int, char **));
     
    149153int vgrid            PROTO((int, char **));
    150154int vgauss           PROTO((int, char **));
     155int vlorentz         PROTO((int, char **));
    151156int vellipse         PROTO((int, char **));
    152157int vmaxwell         PROTO((int, char **));
     
    232237  {1, "hermitian1d",  hermitian1d,      "generate 1-D Hermitian Polynomial"},
    233238  {1, "hermitian2d",  hermitian2d,      "generate 2-D Hermitian Polynomial"},
     239  {1, "idxread",      idxread,          "read vector or image data from an IDX file"},
    234240  {1, "imbin",        rebin,            "rebin image data by factor of N"},
    235241  {1, "imclip",       imclip,           "clip values in an image to be within a range"},
     
    268274  {1, "imset",        mset,             "insert a vector in an image"},
    269275  {1, "needles",      needles,          "plot vectors needles"},
     276  {1, "nnet",         nnet_command,     "Neural Network commands"},
    270277  {1, "parity",       parity,           "set image parity"},
    271278  {1, "peak",         peak,             "find vector peak in range"},
    272   {1, "periodogram",  periodogram,      "measure periods in unevenly sampled data"},
     279  {1, "periodogram",    periodogram,    "measure periods in unevenly sampled data (Lomb-Scargle)"},
     280  {1, "periodogram_fm", periodogram_fm, "measure periods in unevenly sampled data (generalized Lomb-Scargle; floating mean)"},
    273281  {1, "plot",         plot,             "plot a pair of vectors"},
    274282  {1, "png",          jpeg,             "convert display graphic to PNG"},
     
    323331  {1, "ungridify",    ungridify,        "convert image region to vector triplet"},
    324332  {1, "uniq",         uniq,             "create a uniq vector subset from a vector"},
     333  {1, "uniqpair",     uniqpair,         "create a uniq vector subset from a pair of vectors, saving duplicates if desired"},
    325334  {1, "unsign",       unsign,           "toggle the UNSIGN status"},
    326335  {1, "vbin",         vbin,             "rebin vector data by a factor of N"},
     
    330339  {1, "vtype",        vtype,            "return the vector type (FLT or INT)"},
    331340  {1, "vgauss",       vgauss,           "fit a Gaussian to a vector"},
     341  {1, "vlorentz",     vlorentz,         "fit a Lorentzian to a vector"},
    332342  {1, "vellipse",     vellipse,         "fit a Ellipse to a vector pair"},
    333343  {1, "vgrid",        vgrid,            "generate an image from a triplet of vectors"},
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/limits.c

    r31160 r40477  
    33int limits (int argc, char **argv) {
    44
    5   int N, APPLY, dX, dY;
     5  int N, dX, dY;
    66  int kapa;
    7   char *name;
    87  Graphdata graphmode;
    98  Vector *xvec, *yvec;
     
    1110  xvec = yvec = NULL;
    1211
    13   APPLY = FALSE;
     12  float minLimitX = NAN;
     13  float minLimitY = NAN;
     14  float maxLimitX = NAN;
     15  float maxLimitY = NAN;
     16  float delLimitX = NAN;
     17  float delLimitY = NAN;
     18
     19  if ((N = get_argument (argc, argv, "-minX"))) {
     20    remove_argument (N, &argc, argv);
     21    minLimitX = atof (argv[N]);
     22    remove_argument (N, &argc, argv);
     23  }
     24  if ((N = get_argument (argc, argv, "-maxX"))) {
     25    remove_argument (N, &argc, argv);
     26    maxLimitX = atof (argv[N]);
     27    remove_argument (N, &argc, argv);
     28  }
     29  if ((N = get_argument (argc, argv, "-delX"))) {
     30    if (!isnan(minLimitX) || !isnan(maxLimitX)) {
     31      gprint (GP_ERR, "-minX & -maxX cannot be mixed with -delX\n");
     32      return (FALSE);
     33    }
     34    remove_argument (N, &argc, argv);
     35    delLimitX = atof (argv[N]);
     36    remove_argument (N, &argc, argv);
     37  }
     38  if ((N = get_argument (argc, argv, "-minY"))) {
     39    remove_argument (N, &argc, argv);
     40    minLimitY = atof (argv[N]);
     41    remove_argument (N, &argc, argv);
     42  }
     43  if ((N = get_argument (argc, argv, "-maxY"))) {
     44    remove_argument (N, &argc, argv);
     45    maxLimitY = atof (argv[N]);
     46    remove_argument (N, &argc, argv);
     47  }
     48  if ((N = get_argument (argc, argv, "-delY"))) {
     49    if (!isnan(minLimitY) || !isnan(maxLimitY)) {
     50      gprint (GP_ERR, "-minY & -maxY cannot be mixed with -delY\n");
     51      return (FALSE);
     52    }
     53    remove_argument (N, &argc, argv);
     54    delLimitY = atof (argv[N]);
     55    remove_argument (N, &argc, argv);
     56  }
     57
     58  int APPLY = FALSE;
    1459  if ((N = get_argument (argc, argv, "-a"))) {
    1560    remove_argument (N, &argc, argv);
    1661    APPLY = TRUE;
    1762  }
    18   name = NULL;
     63  char *name = NULL;
    1964  if ((N = get_argument (argc, argv, "-n"))) {
    2065    remove_argument (N, &argc, argv);
     
    2267    remove_argument (N, &argc, argv);
    2368  }
     69
    2470  if (!GetGraph (&graphmode, &kapa, name)) return (FALSE);
    2571  FREE (name);
     
    97143 success:
    98144  SetLimits (xvec, yvec, &graphmode);
     145
     146  if (!isnan(minLimitX)) graphmode.xmin = MIN (minLimitX, graphmode.xmin);
     147  if (!isnan(maxLimitX)) graphmode.xmax = MAX (maxLimitX, graphmode.xmax);
     148  if (!isnan(minLimitY)) graphmode.ymin = MIN (minLimitY, graphmode.ymin);
     149  if (!isnan(maxLimitY)) graphmode.ymax = MAX (maxLimitY, graphmode.ymax);
     150
     151  if (!isnan(delLimitX)) {
     152    float delta = graphmode.xmax - graphmode.xmin;
     153    if (fabs(delLimitX) > fabs(delta)) {
     154      float midpt = 0.5*(graphmode.xmax + graphmode.xmin);
     155      graphmode.xmax = midpt + 0.5*delLimitX;
     156      graphmode.xmin = midpt - 0.5*delLimitX;
     157    }
     158  }
     159  if (!isnan(delLimitY)) {
     160    float delta = graphmode.ymax - graphmode.ymin;
     161    if (fabs(delLimitY) > fabs(delta)) {
     162      float midpt = 0.5*(graphmode.ymax + graphmode.ymin);
     163      graphmode.ymax = midpt + 0.5*delLimitY;
     164      graphmode.ymin = midpt - 0.5*delLimitY;
     165    }
     166  }
     167
    99168  if (APPLY) KapaSetLimits (kapa, &graphmode);
    100169  return (TRUE);
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/line.c

    r33662 r40477  
    3333
    3434  /* set point style and errorbar mode (these are NOT sticky) */
    35   graphmode.style = 0;
     35  graphmode.style = KAPA_PLOT_CONNECT;
    3636  graphmode.etype = 0;
    3737
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/mslice.c

    r39233 r40477  
    33int mslice (int argc, char **argv) {
    44 
    5   int i;
     5  int N;
    66  Buffer *in, *out;
    77
     8  int Dir = 0;
     9  if ((N = get_argument (argc, argv, "-x"))) {
     10    remove_argument (N, &argc, argv);
     11    Dir = 1;   
     12  }
     13  if ((N = get_argument (argc, argv, "-y"))) {
     14    remove_argument (N, &argc, argv);
     15    if (Dir) {
     16      gprint (GP_ERR, "ERROR: multiple -x,-y,-z options are not allowed\n");
     17      return FALSE;
     18    }
     19    Dir = 2;   
     20  }
     21  if ((N = get_argument (argc, argv, "-z"))) {
     22    remove_argument (N, &argc, argv);
     23    if (Dir) {
     24      gprint (GP_ERR, "ERROR: multiple -x,-y,-z options are not allowed\n");
     25      return FALSE;
     26    }
     27    Dir = 3;   
     28  }
     29  if (!Dir) Dir = 3;
     30
    831  if (argc != 4) {
    9     gprint (GP_ERR, "USAGE: mget <input> <output> plane\n");
     32    gprint (GP_ERR, "USAGE: mslice <input> <output> plane [-x,-y,-z]\n");
     33    gprint (GP_ERR, "  -z is default\n");
    1034    return (FALSE);
    1135  }
     
    2448  int Nz = in[0].matrix.Naxis[2];
    2549
     50  int NplaneMax = 0;
     51  int Nout1 = 0;
     52  int Nout2 = 0;
     53  switch (Dir) {
     54    case 1: NplaneMax = Nx; Nout1 = Ny; Nout2 = Nz; break;
     55    case 2: NplaneMax = Ny; Nout1 = Nx; Nout2 = Nz; break;
     56    case 3: NplaneMax = Nz; Nout1 = Nx; Nout2 = Ny; break;
     57    default: myAbort ("impossible");
     58  }
     59
    2660  int invalid = FALSE;
    2761  invalid = invalid || (plane < 0);
    28   invalid = invalid || (plane >= Nz);
     62  invalid = invalid || (plane >= NplaneMax);
    2963  if (invalid) {
    30     gprint (GP_ERR, "plane %d out of range\n", plane);
     64    gprint (GP_ERR, "plane %d out of range (max = %d)\n", plane, NplaneMax);
    3165    return (FALSE);
    3266  }
    3367
    3468  /* I should encapsulate this in a create_default_buffer */
     69 
    3570  gfits_free_matrix (&out[0].matrix);
    3671  gfits_free_header (&out[0].header);
    37   if (!CreateBuffer (out, Nx, Ny, -32, 1.0, 0.0)) return FALSE;
     72  if (!CreateBuffer (out, Nout1, Nout2, -32, 1.0, 0.0)) return FALSE;
    3873
    39   float *inF  = (float *) in[0].matrix.buffer + plane*Nx*Ny;
    40   float *outF = (float *) out[0].matrix.buffer;
     74  // pixel (ix, iy, iz) : in[0].matrix.buffer + ix + iy*Nx + iz*Nx*Ny
    4175
    42   for (i = 0; i < Nx*Ny; i++, inF ++, outF++) {
    43     *outF = *inF;
     76  switch (Dir) {
     77    case 1: {
     78      float *outF = (float *) out[0].matrix.buffer;
     79     
     80      // pixel (ix, iy, iz) : in[0].matrix.buffer + ix + iy*Nx + iz*Nx*Ny
     81
     82      for (int iz = 0; iz < Nz; iz++) {
     83        float *inF  = (float *) in[0].matrix.buffer + plane + iz*Nx*Ny;
     84        for (int iy = 0; iy < Ny; iy++, inF += Nx, outF++) {
     85          *outF = *inF;
     86        }
     87      }
     88      break;
     89    }
     90    case 2: {
     91
     92      float *outF = (float *) out[0].matrix.buffer;
     93
     94      for (int iz = 0; iz < Nz; iz++) {
     95        float *inF  = (float *) in[0].matrix.buffer + plane*Nx + iz*Nx*Ny;
     96        for (int ix = 0; ix < Nx; ix++, inF++, outF++) {
     97          *outF = *inF;
     98        }
     99      }
     100      break;
     101    }
     102    case 3: {
     103      float *inF  = (float *) in[0].matrix.buffer + plane*Nx*Ny;
     104      float *outF = (float *) out[0].matrix.buffer;
     105     
     106      for (int i = 0; i < Nx*Ny; i++, inF ++, outF++) {
     107        *outF = *inF;
     108      }
     109      break;
     110    }
     111    default: myAbort ("impossible");
    44112  }
    45113  return (TRUE);
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/print_vectors.c

    r37049 r40477  
    44
    55  Vector **vec;
    6   int i, j;
     6  int i, j, N;
     7
     8  int START_VALUE = 0;
     9  if ((N = get_argument (argc, argv, "-s"))) {
     10    remove_argument (N, &argc, argv);
     11    START_VALUE = atoi (argv[N]);
     12    remove_argument (N, &argc, argv);
     13  }
     14
     15  int END_VALUE = -1;
     16  if ((N = get_argument (argc, argv, "-e"))) {
     17    remove_argument (N, &argc, argv);
     18    END_VALUE = atoi (argv[N]);
     19    remove_argument (N, &argc, argv);
     20  }
    721
    822  if (argc < 2) {
     
    2741  }
    2842
    29   for (j = 0; j < MaxLen; j++) {
     43  // start and end may be 0 - N (truncated to N) or may be negative, in which case it refers to
     44  // distance from the end (just like vector[-5])
     45  START_VALUE = (START_VALUE < 0) ? MaxLen + START_VALUE + 1 : MIN (START_VALUE, MaxLen);
     46  START_VALUE = MAX (0, START_VALUE);
     47
     48  END_VALUE = (END_VALUE < 0) ? MaxLen + END_VALUE + 1 : MIN (END_VALUE, MaxLen);
     49  END_VALUE = MAX (0, END_VALUE);
     50
     51  for (j = START_VALUE; j < END_VALUE; j++) {
    3052    for (i = 0; i < Nvec; i++) {
    3153      if (j >= vec[i][0].Nelements) {
     
    3557          gprint (GP_LOG, "%f ", vec[i][0].elements.Flt[j]);
    3658        } else {
    37           gprint (GP_LOG, "%d ", vec[i][0].elements.Int[j]);
     59          gprint (GP_LOG, OPIHI_INT_FMT" ", vec[i][0].elements.Int[j]);
    3860        }
    3961      }
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/read_vectors.c

    r40012 r40477  
    1919  }
    2020 
     21  if (strlen(argv[1]) >= 2048) {
     22    gprint (GP_ERR, "filename %s is too long\n", argv[1]);
     23    return (FALSE);
     24  }
     25
    2126  strcpy (filename, argv[1]);
    2227  if (f != (FILE *) NULL) { fclose (f); }
    2328  f = fopen (filename, "r");
    2429  if (f == (FILE *) NULL) {
    25     gprint (GP_ERR, "failed to open file %s\n", argv[1]);
     30    gprint (GP_ERR, "failed to open file %s\n", filename);
    2631    return (FALSE);
    2732  }
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/reindex.c

    r39227 r40477  
    4747        continue;
    4848      }
    49       if (*vx > Nmax) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i);
     49      if (*vx > Nmax) ESCAPE("unexpected value in index: "OPIHI_INT_FMT" (%d)\n", *vx, i);
    5050      ovec[0].elements.Flt[Npts] = vi[*vx];
    5151      Npts++;
     
    6767        continue;
    6868      }
    69       if (*vx > Nmax) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i);
     69      if (*vx > Nmax) ESCAPE("unexpected value in index: "OPIHI_INT_FMT" (%d)\n", *vx, i);
    7070      ovec[0].elements.Int[Npts] = vi[*vx];
    7171      Npts++;
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/sort.c

    r20936 r40477  
    77  itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp; \
    88}
    9 # define COMPARE(A,B)(X[A] < X[B])
     9
     10// # define COMPARE(A,B)(X[A] < X[B])
     11# define COMPARE(A,B)((!isfinite(X[A]) && isfinite(X[B])) || (X[A] < X[B]))
    1012
    1113  OHANA_SORT (N, COMPARE, SWAPFUNC);
     
    2224  itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp; \
    2325}
     26
    2427# define COMPARE(A,B)(X[A] < X[B])
     28// # define COMPARE(A,B)((!isfinite(X[A]) && isfinite(X[B])) || (X[A] < X[B]))
    2529
    2630  OHANA_SORT (N, COMPARE, SWAPFUNC);
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/test/periodogram.sh

    r27435 r40477  
     1
     2if (not($?PLOT)) set PLOT = 0
    13
    24list tests
     
    2830   echo "OFFSET: {$peakpos - $P}"
    2931 end
     32
     33 if ($PLOT)
     34  lim period power; clear; box; line -c red70 -lw 3 $P 0 to $P $peakval; plot period power -x line
     35 end
    3036end
    3137
     
    107113 if (abs ($peakpos - $P) > 0.05)
    108114   $PASS = 0
     115 end
     116end
     117
     118# test using random samples, offset start, non-zero DC
     119macro test5
     120 $PASS = 1
     121 break -auto off
     122
     123 local P PI
     124 $PI = 3.14159265359
     125 $P  = 15.0
     126
     127 delete -q x t f period power
     128
     129 create x 500 800
     130 set t = 300 * rnd(x) + 500
     131 set f = sin(2*$PI*t/$P) + 0.5
     132
     133 periodogram t f 2 30 period power
     134
     135#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     136#  lim -n 1 period power; clear; box; plot period power
     137
     138 peak -q period power
     139
     140 if (abs ($peakpos - $P) > 0.05)
     141   $PASS = 0
     142 end
     143end
     144
     145# test using random samples, offset start, non-zero DC, some noise
     146macro test6
     147 $PASS = 1
     148 break -auto off
     149
     150 local P PI
     151 $PI = 3.14159265359
     152 $P  = 15.0
     153
     154 delete -q x t f period power
     155
     156 create x 500 800
     157 set t = 300 * rnd(x) + 500
     158 set fraw = sin(2*$PI*t/$P) + 0.5
     159
     160 # 0.05 : peakpos = 14.95
     161 # 0.10 : peakpos = 15.04 (
     162 gaussdev df t[] 0.0 0.25
     163 set f = fraw + df
     164
     165 periodogram t f 2 30 period power
     166
     167#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     168#  lim -n 1 period power; clear; box; plot period power
     169
     170 peak -q period power
     171
     172 if (abs ($peakpos - $P) > 0.05)
     173   $PASS = 0
     174 end
     175end
     176
     177# test using fewer random samples, offset start, non-zero DC, some noise
     178macro test7
     179 $PASS = 1
     180 break -auto off
     181
     182 local P PI
     183 $PI = 3.14159265359
     184 $P  = 15.0
     185
     186 delete -q x t f period power
     187
     188 create x 0 100
     189 set t = 100 * rnd(x)
     190 set fraw = sin(2*$PI*t/$P) + 0.5
     191
     192 # 0.05 : peakpos = 14.95
     193 # 0.10 : peakpos = 15.04 (
     194 gaussdev df t[] 0.0 0.25
     195 set f = fraw + df
     196
     197 periodogram t f 2 30 period power
     198
     199#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     200#  lim -n 1 period power; clear; box; plot period power
     201
     202 peak -q period power
     203
     204 if (abs ($peakpos - $P) > 0.05)
     205   $PASS = 0
     206 end
     207end
     208
     209# test using fewer random samples, high frequency, non-zero DC, some noise
     210macro test8
     211 if ($0 != 4)
     212   echo "USAGE: test8: Period Ndays df"
     213   break
     214 end
     215 
     216 local Ndays
     217 $P = $1
     218 $Ndays = $2
     219 $dM = $3
     220
     221 $PASS = 1
     222 break -auto off
     223
     224 local PI
     225 $PI = 3.14159265359
     226 $trueP = $P
     227
     228 delete -q x t f period power
     229
     230 create x 0 $Ndays
     231
     232 # t is a time in days, but we always have 4 within 1 hour:
     233 set tday = int(100 * rnd(x)); # choose Ndays random days between 0 and 100
     234 set dtx = (3/24) * rnd(x);  # choose a starting time within that night
     235 set t0 = tday + dtx
     236
     237 set dt1 = (15.0 / 1440) * rnd(x) + ( 0 + 7.5) / 1440
     238 set dt2 = (15.0 / 1440) * rnd(x) + (15 + 7.5) / 1440
     239 set dt3 = (15.0 / 1440) * rnd(x) + (30 + 7.5) / 1440
     240
     241 delete -q t
     242 concat t0 t
     243 set tmp = t0 + dt1; concat tmp t
     244 set tmp = t0 + dt2; concat tmp t
     245 set tmp = t0 + dt3; concat tmp t
     246
     247 set fraw = 0.75*sin(2*$PI*t/$P)
     248
     249 # 0.05 : peakpos = 14.95
     250 # 0.10 : peakpos = 15.04 (
     251 gaussdev df t[] 0.0 $dM
     252 set f = fraw + df
     253
     254 periodogram t f 0.1 2.0 period power
     255
     256#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     257#  lim -n 1 period power; clear; box; plot period power
     258
     259 peak -q period power
     260
     261 if (abs ($peakpos - $P) > 0.05)
     262   $PASS = 0
     263 end
     264 if ($PLOT)
     265  lim period power; clear; box; line -c red70 -lw 3 $P 0 to $P $peakval; plot period power -x line
    109266 end
    110267end
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/textline.c

    r13479 r40477  
    66  char name[64];
    77  double x, y, angle;
    8   int kapa;
    98  Graphdata graphmode;
    109
    11   if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
     10  // if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
     11
     12  // Using only these style_args options
     13  char *kapaName = NULL;
     14  int kapa = -1;
     15  if ((N = get_argument (argc, argv, "-n"))) {
     16    remove_argument (N, &argc, argv);
     17    kapaName = strcreate (argv[N]);
     18    remove_argument (N, &argc, argv);
     19  }
     20  if (!GetGraph (&graphmode, &kapa, kapaName)) return (FALSE);
     21  FREE (kapaName);
     22
     23  int color = KapaColorByName ("black");
     24  if ((N = get_argument (argc, argv, "-c"))) {
     25    remove_argument (N, &argc, argv);
     26    color = KapaColorByName (argv[N]);
     27    if (color == -1) return (FALSE);
     28    remove_argument (N, &argc, argv);
     29  }
    1230
    1331  if ((N = get_argument (argc, argv, "-fn"))) {
     
    3452  }
    3553
     54  int justify = 5; // default
     55  if ((N = get_argument (argc, argv, "-justify"))) {
     56    remove_argument (N, &argc, argv);
     57    justify = atoi (argv[N]);
     58    remove_argument (N, &argc, argv);
     59  }
     60
    3661  if (argc != 4) {
    37     gprint (GP_ERR, "USAGE: text x y (line) [-fn (font) size] [-rot angle]\n");
     62    gprint (GP_ERR, "USAGE: text x y (line) [-fn (font) size] [-rot angle] [-justify N]\n");
    3863    return (FALSE);
    3964  }
     
    5277  }   
    5378
    54   KapaSendTextline (kapa, argv[3], x, y, angle);
     79  KapaSendTextline (kapa, argv[3], x, y, angle, justify, color);
    5580  return (TRUE);
    5681}
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/uniq.c

    r39457 r40477  
    8080    memcpy (indata, ivec->elements.Int, ivec[0].Nelements*sizeof(opihi_int));
    8181
    82     isort (indata, ivec->Nelements);
     82    llsort (indata, ivec->Nelements);
    8383
    8484    Nnew = 0;
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/write_vectors.c

    r39360 r40477  
    165165        } else {
    166166          if (CSV) {
    167             fprintf (f, "%d,", vec[j][0].elements.Int[i]);
     167            fprintf (f, OPIHI_INT_FMT",", vec[j][0].elements.Int[i]);
    168168          } else {
    169             fprintf (f, "%d ", vec[j][0].elements.Int[i]);
     169            fprintf (f, OPIHI_INT_FMT" ", vec[j][0].elements.Int[i]);
    170170          }
    171171        }
  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/zplot.c

    r38062 r40477  
    117117
    118118  /* point size determined by Zvec */
    119   graphmode.style = 2; /* plot points */
     119  graphmode.style = KAPA_PLOT_POINTS; /* points */
    120120  graphmode.size = -1; /* point size determined by Zvec */
    121121  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode);
     
    226226
    227227  /* point size determined by Zvec */
    228   graphmode.style = 2; /* plot points */
     228  graphmode.style = KAPA_PLOT_POINTS; /* plot points */
    229229  graphmode.color = -1; /* point color determined by Zvec */
    230230  graphmode.etype = 0; /* no errorbars */
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/Makefile

    r39602 r40477  
    2727$(SRC)/mySequence.$(ARCH).o             \
    2828$(SRC)/photcode_ops.$(ARCH).o           \
     29$(SRC)/PeriodogramOps.$(ARCH).o         \
    2930$(SRC)/find_matches.$(ARCH).o           
    3031
     
    4546$(SRC)/avextract.$(ARCH).o              \
    4647$(SRC)/avmatch.$(ARCH).o                \
     48$(SRC)/avperiodogram.$(ARCH).o          \
     49$(SRC)/avperiodomatch.$(ARCH).o         \
    4750$(SRC)/badimages.$(ARCH).o              \
    4851$(SRC)/catdir.$(ARCH).o                 \
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/catalog.c

    r38471 r40477  
    390390    REALLOCATE (Zvec.elements, float, MAX (Zvec.Nelements, 1));
    391391   
    392     graphmode.style = 2; /* set style to points */
     392    graphmode.style = KAPA_PLOT_POINTS; /* points */
    393393    graphmode.size = -1; /* point size determined by Zvec */
    394394    graphmode.etype = 0; /* no errorbars */
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/dmt.c

    r39457 r40477  
    150150    vec5[0].Nelements = Dvec.Nelements;
    151151  } else {
    152     graphmode.style = 2; /* set style to points */
     152    graphmode.style = KAPA_PLOT_POINTS; /* points */
    153153    PlotVector (kapa, N, Xvec.elements, Yvec.elements, &graphmode);
    154154
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/dvo_host_utils.c

    r39524 r40477  
    212212        continue;
    213213      }
    214       free (table->hosts[i].results);
    215       table->hosts[i].results = NULL;
     214      // free (table->hosts[i].results);
     215      // table->hosts[i].results = NULL;
    216216      set_int_variable (name, 1); // result file has been read
    217217
     
    225225        FreeVectorArray (invec, Ninvec);
    226226      }
     227    } else {
     228      // free (table->hosts[i].results);
     229      // table->hosts[i].results = NULL;
    227230    }
    228231  }
     
    242245  free (vec);
    243246
    244   free (table);
     247  FreeHostTable (table);
    245248  return TRUE;
    246249}
     
    284287    // XXX a bit of a waste (but only 1024 * 60 bytes or so
    285288    ALLOCATE (table->hosts[i].results, char, DVO_MAX_PATH);
    286     snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer);
     289    snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.%04d.fits", table->hosts[i].pathname, uniquer, table->hosts[i].hostID);
    287290
    288291    int    Ninvec = 0;
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/fitcolors.c

    r39457 r40477  
    4848  if (!SetPhotSelections (&argc, argv, 4)) goto usage;
    4949
     50  int textcolor = KapaColorByName ("black");
     51
    5052  // range for valid data points (exclude extreme outliers)
    5153  minDelta = -0.2;
     
    9294    graphdata.ymin = minDelta;
    9395    graphdata.ymax = maxDelta;
    94     graphdata.style = 2;
    95     graphdata.ptype = 2;
     96    graphmode.style = KAPA_PLOT_POINTS; /* points */
     97    graphmode.ptype = KAPA_POINT_CIRCLE_SOLID; /* connect pairs of points */
    9698    KapaClearSections (kapa);
    9799    KapaSetFont (kapa, "helvetica", 14);
     
    192194    graphdata.ymin = minDelta;
    193195    graphdata.ymax = maxDelta;
    194     graphdata.style = 2;
    195     graphdata.ptype = 2;
     196    graphmode.style = KAPA_PLOT_POINTS; /* points */
     197    graphmode.ptype = KAPA_POINT_CIRCLE_SOLID; /* connect pairs of points */
    196198  }
    197199
     
    315317          deltaFit[i] = C0 + C1*colorFit[i];
    316318        }
    317         graphdata.style = 0;
     319        graphmode.style = KAPA_PLOT_CONNECT; /* lines */
    318320        graphdata.color = KapaColorByName ("red");
    319321
     
    324326        KapaSetFont (kapa, "helvetica", 8);
    325327        sprintf (label, "%s", code[0][0].name);
    326         KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.8*maxDelta + 0.2*minDelta, 0.0);
     328        KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.8*maxDelta + 0.2*minDelta, 0.0, textcolor);
    327329        sprintf (label, "%s", code[1][0].name);
    328         KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.2*maxDelta + 0.8*minDelta, 0.0);
     330        KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.2*maxDelta + 0.8*minDelta, 0.0, textcolor);
    329331        KapaSetFont (kapa, "helvetica", 14);
    330332
    331         graphdata.style = 2;
     333        graphmode.style = KAPA_PLOT_POINTS; /* points */
    332334        graphdata.color = KapaColorByName ("black");
    333335
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/fitsed.c

    r39457 r40477  
    157157    if (!GetGraph (&graphdata, &kapa, NULL)) return (FALSE);
    158158    SetLimitsRaw (wavecode, NULL, Nfilter, &graphdata);
    159     graphdata.style = 2;
    160     graphdata.ptype = 2;
     159    graphdata.style = KAPA_PLOT_POINTS; /* points */
     160    graphdata.ptype = KAPA_POINT_CIRCLE_SOLID;
    161161    KapaClearSections (kapa);
    162162    magSection.name = strcreate ("mag");
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/gimages.c

    r39347 r40477  
    214214    if (PixelCoords) {
    215215      gprint (GP_LOG, "%3d %5d %s %6.1f %6.1f %20s %5d %2d %4.2f %6.3f %5.3f %5.3f %4x %7d\n",
    216               Nfound, (int) i, image[i].name, X, Y, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal, image[i].exptime, image[i].flags, image[i].imageID);
     216              Nfound, (int) i, image[i].name, X, Y, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].McalPSF, image[i].dMcal, image[i].exptime, image[i].flags, image[i].imageID);
    217217    } else {
    218218      XY_to_RD (&ra, &dec, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords);
    219219      gprint (GP_LOG, "%3d %5d %s %8.4f %8.4f %20s %5d %2d %4.2f %6.3f %5.3f %5.3f %4x %7d\n",
    220               Nfound, (int) i, image[i].name, ra, dec, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal, image[i].exptime, image[i].flags, image[i].imageID);
     220              Nfound, (int) i, image[i].name, ra, dec, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].McalPSF, image[i].dMcal, image[i].exptime, image[i].flags, image[i].imageID);
    221221    }
    222222    sprintf (name, "IMAGEx:%d", Nfound);
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/gstar.c

    r39634 r40477  
    760760
    761761            if (FULL_OUTPUT) {
    762               gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mcal);
     762              gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].McalPSF);
     763              gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].McalAPER);
    763764              gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mflat);
    764               gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Map);
    765               gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mkron);
     765              Mrel = PhotRel (&catalog.measure[Nv], &catalog.average[k], &catalog.secfilt[k*Nsecfilt], MAG_CLASS_APER);
     766              gprint (GP_LOG, "%6.3f ", Mrel);
     767              Mrel = PhotRel (&catalog.measure[Nv], &catalog.average[k], &catalog.secfilt[k*Nsecfilt], MAG_CLASS_KRON);
     768              gprint (GP_LOG, "%6.3f ", Mrel);
    766769              gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].dMkron);
    767770              gprint (GP_LOG, "%5.1f ", pow(10.0, 0.4*catalog.measure[Nv].dt));
     
    960963        print_double (NAN);
    961964      } else {
    962         print_double_exp (secfilt[seq].Mstdev);
     965        print_double_exp (secfilt[seq].sMpsfChp);
    963966      }
    964967      break;
     
    10231026        print_double (NAN);
    10241027      } else {
    1025         print_double (secfilt[seq].M);
     1028        print_double (secfilt[seq].MpsfChp);
    10261029      }
    10271030      break;
     
    10311034        print_double (NAN);
    10321035      } else {
    1033         print_double (secfilt[seq].dM);
     1036        print_double (secfilt[seq].dMpsfChp);
    10341037      }
    10351038      break;
     
    10391042        print_double (NAN);
    10401043      } else {
    1041         print_double (secfilt[seq].Map);
     1044        print_double (secfilt[seq].MapChp);
    10421045      }
    10431046      break;
     
    10471050        print_double (NAN);
    10481051      } else {
    1049         print_double (secfilt[seq].dMap);
     1052        print_double (secfilt[seq].dMapChp);
    10501053      }
    10511054      break;
     
    10551058        print_double (NAN);
    10561059      } else {
    1057         print_double_exp (secfilt[seq].sMap);
     1060        print_double_exp (secfilt[seq].sMapChp);
    10581061      }
    10591062      break;
     
    10631066        print_double (NAN);
    10641067      } else {
    1065         print_double_exp (secfilt[seq].dMap);
     1068        print_double_exp (secfilt[seq].dMapChp);
    10661069      }
    10671070      break;
     
    10711074        print_double (NAN);
    10721075      } else {
    1073         print_double (secfilt[seq].Mkron);
     1076        print_double (secfilt[seq].MkronChp);
    10741077      }
    10751078      break;
     
    10791082        print_double (NAN);
    10801083      } else {
    1081         print_double (secfilt[seq].dMkron);
     1084        print_double (secfilt[seq].dMkronChp);
    10821085      }
    10831086      break;
     
    10871090        print_double (NAN);
    10881091      } else {
    1089         print_double_exp (secfilt[seq].sMkron);
     1092        print_double_exp (secfilt[seq].sMkronChp);
    10901093      }
    10911094      break;
     
    10951098        print_double (NAN);
    10961099      } else {
    1097         print_double_exp (secfilt[seq].dMkron);
     1100        print_double_exp (secfilt[seq].dMkronChp);
    10981101      }
    10991102      break;
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/images.c

    r37807 r40477  
    352352  Xvec.Nelements = Yvec.Nelements = N;
    353353  if (N > 0) {
    354     graphmode.style = 2; /* points */
    355     graphmode.ptype = 100; /* connect pairs of points */
     354    graphmode.style = KAPA_PLOT_POINTS; /* points */
     355    graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    356356    graphmode.etype = 0;
    357357    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/imbox.c

    r39926 r40477  
    156156  Xvec.Nelements = Yvec.Nelements = Npts;
    157157  if (Npts > 0) {
    158     graphmode.style = 2; /* points */
    159     graphmode.ptype = 100; /* connect pairs of points */
     158    graphmode.style = KAPA_PLOT_POINTS; /* points */
     159    graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    160160    graphmode.etype = 0;
    161161    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/imdata.c

    r39457 r40477  
    183183        for (i = 0; i < catalog.Nmeasure; i++) {
    184184          if ((catalog.measure[i].t < start) || (catalog.measure[i].t > stop)) continue;
    185           vec[0].elements.Flt[N] = catalog.measure[i].Mcal;
     185          vec[0].elements.Flt[N] = catalog.measure[i].McalPSF;
    186186          N++;
    187187          CHECK_REALLOCATE (vec[0].elements.Flt, opihi_flt, NPTS, N, 1000);
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/imdense.c

    r39926 r40477  
    5959  Xvec.Nelements = Yvec.Nelements = N;
    6060  if (N > 0) {
    61     graphmode.style = 2; /* points */
     61    graphmode.style = KAPA_PLOT_POINTS; /* points */
    6262    graphmode.etype = 0;
    6363    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/imlist.c

    r39310 r40477  
    141141    if (VERBOSE) {
    142142      gprint (GP_LOG, "%3lld %s %8lld %8.4f %8.4f %f %5d %2d %4.2f %5.3f %5.3f",
    143                          (long long) i, image[i].name, (long long) image[i].imageID, r, d, t, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal);
     143                         (long long) i, image[i].name, (long long) image[i].imageID, r, d, t, image[i].nstar, image[i].photcode, image[i].secz, image[i].McalPSF, image[i].dMcal);
    144144
    145145      if (showUR) {
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/imphot.c

    r39233 r40477  
    6464      for (x = 0; x < 100; x+=1.0, p++) {
    6565        // *p = applyMcal (&image[subset[0]], (fx*x), (fy*y));
    66         *p = image[subset[0]].Mcal;
     66        *p = image[subset[0]].McalPSF;
    6767      }
    6868    }
     
    7171  for (j = 0; j < Nsubset; j++) {
    7272    i = subset[j];
    73     gprint (GP_ERR, "%s: %f\n", image[i].name, image[i].Mcal);
     73    gprint (GP_ERR, "%s: %f\n", image[i].name, image[i].McalPSF);
    7474
    7575// XXX old code when we had the option of a 2D zero point model
     
    7777    switch (image[i].order) {
    7878    case 0:
    79       gprint (GP_ERR, "%s: %d - %f\n", image[i].name, image[i].order, image[i].Mcal);
     79      gprint (GP_ERR, "%s: %d - %f\n", image[i].name, image[i].order, image[i].McalPSF);
    8080      break;
    8181    case 1:
    82       gprint (GP_ERR, "%s: %d - %f, %d %d\n", image[i].name, image[i].order, image[i].Mcal, image[i].Mx, image[i].My);
     82      gprint (GP_ERR, "%s: %d - %f, %d %d\n", image[i].name, image[i].order, image[i].McalPSF, image[i].Mx, image[i].My);
    8383      break;
    8484    case 2:
    85       gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d\n", image[i].name, image[i].order, image[i].Mcal, image[i].Mx, image[i].My, image[i].Mxx, image[i].Mxy, image[i].Myy);
     85      gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d\n", image[i].name, image[i].order, image[i].McalPSF, image[i].Mx, image[i].My, image[i].Mxx, image[i].Mxy, image[i].Myy);
    8686      break;
    8787    case 3:
    88       gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d, %d %d %d %d\n", image[i].name, image[i].order, image[i].Mcal, image[i].Mx, image[i].My,
     88      gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d, %d %d %d %d\n", image[i].name, image[i].order, image[i].McalPSF, image[i].Mx, image[i].My,
    8989               image[i].Mxx, image[i].Mxy, image[i].Myy, image[i].Mxxx, image[i].Mxxy, image[i].Mxyy, image[i].Myyy);
    9090      break;
    9191    case 4:
    92       gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d, %d %d %d %d, %d %d %d %d %d\n", image[i].name, image[i].order, image[i].Mcal, image[i].Mx, image[i].My,
     92      gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d, %d %d %d %d, %d %d %d %d %d\n", image[i].name, image[i].order, image[i].McalPSF, image[i].Mx, image[i].My,
    9393               image[i].Mxx, image[i].Mxy, image[i].Myy, image[i].Mxxx, image[i].Mxxy, image[i].Mxyy, image[i].Myyy,
    9494               image[i].Mxxxx, image[i].Mxxxy, image[i].Mxxyy, image[i].Mxyyy, image[i].Myyyy);
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/imstats.c

    r37807 r40477  
    4141    Xvec.elements.Flt[i] = image[i].secz;
    4242    if (Mcal)
    43       Yvec.elements.Flt[i] = image[i].Mcal;
     43      Yvec.elements.Flt[i] = image[i].McalPSF;
    4444    else
    4545      Yvec.elements.Flt[i] = image[i].dMcal;
     
    4747    gprint (GP_ERR, "%d %8.4f %8.4f %10d %6d  %5.3f %6.3f %6.3f\n",
    4848             i, r, d, image[i].tzero, image[i].nstar, Xvec.elements.Flt[i],
    49              image[i].Mcal, image[i].dMcal);
     49             image[i].McalPSF, image[i].dMcal);
    5050  }
    5151  if (AutoLimits) SetLimits (&Xvec, &Yvec, &graphmode);
    5252
    53   graphmode.style = 2;
     53  graphmode.style = KAPA_PLOT_POINTS; /* points */
    5454  graphmode.etype = 0;
    5555  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/init.c

    r39602 r40477  
    33int avextract       PROTO((int, char **));
    44int avmatch         PROTO((int, char **));
     5int avperiodogram   PROTO((int, char **));
     6int avperiodomatch  PROTO((int, char **));
    57int badimages       PROTO((int, char **));
    68int calextract      PROTO((int, char **));
     
    6769  {1, "avextract",   avextract,    "extract average data values"},
    6870  {1, "avmatch",     avmatch,      "extract average data values matched to RA,DEC points"},
     71  {1, "avperiodogram",  avperiodogram, "perform periodogram on objects based on restrictions"},
     72  {1, "avperiodomatch", avperiodomatch, "perform periodogram on objects based on ra,dec list"},
    6973  {1, "badimages",   badimages,    "look for images with anomalous astrometry"},
    7074//  {1, "calextract",  calextract,   "extract photometry calibration"},
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/objectcoverage.c

    r39457 r40477  
    203203        if (catalog.secfilt[j*Nsecfilt+Nsec].Ncode < 2) { continue; }
    204204
    205         invalid = ((catalog.secfilt[j*Nsecfilt + Nsec].M < 1.0) || (isnan(catalog.secfilt[j*Nsecfilt + Nsec].M)));
     205        invalid = ((catalog.secfilt[j*Nsecfilt + Nsec].MpsfChp < 1.0) || (isnan(catalog.secfilt[j*Nsecfilt + Nsec].MpsfChp)));
    206206        if (invalid) continue;
    207207       
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/paverage.c

    r39457 r40477  
    8181    return (FALSE);
    8282  }
    83   graphmode.style = 2; /* set style to points */
     83  graphmode.style = KAPA_PLOT_POINTS; /* points */
    8484  graphmode.size = -1; /* point size determined by Zvec */
    8585  graphmode.etype = 0; /* no errorbars */
     
    125125      while (average[i].R > Rmax) average[i].R -= 360.0;
    126126
    127       mag = secfilt[i*Nsecfilt+Nsec].M;
     127      mag = secfilt[i*Nsecfilt+Nsec].MpsfChp;
    128128      Zvec[Npts] = MIN (1.0, MAX (0.01, (mag - Mz) / Mr));
    129129      if (LimExclude && (Zvec[Npts] > 0.99)) continue;
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/pmeasure.c

    r39457 r40477  
    154154    return (FALSE);
    155155  }
    156   graphmode.style = 2; /* set style to points */
     156  graphmode.style = KAPA_PLOT_POINTS; /* points */
    157157  graphmode.size = -1; /* point size determined by Zvec */
    158158  graphmode.etype = 0; /* no errorbars */
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/procks.c

    r39457 r40477  
    111111  Yvec.Nelements = Xvec.Nelements = N;
    112112 
    113   graphmode.style = 2; /* set style to points */
     113  graphmode.style = KAPA_PLOT_POINTS; /* points */
    114114  graphmode.etype = 0; /* no errorbars */
    115115  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
     
    142142  Yvec.Nelements = Xvec.Nelements = N;
    143143 
    144   graphmode.style = 2; /* set style to points */
    145   graphmode.ptype = 100; /* connect pairs */
     144  graphmode.style = KAPA_PLOT_POINTS; /* points */
     145  graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    146146  graphmode.etype = 0; /* no errorbars */
    147147
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/region_list.c

    r33662 r40477  
    181181  SkyList *skylist;
    182182
     183  // the list of regions comes directly from a file
     184  if (selection->list != NULL) {
     185    skylist = SkyListLoadFile (selection->list);
     186    return (skylist);
     187  }
     188
     189  // all other options require sky to be set
     190  if (!sky) {
     191    gprint (GP_ERR, "CATDIR not set\n");
     192    return NULL;
     193  }
     194
    183195  /* determine region-file names */
    184196  if (selection->name != NULL) {
     
    186198    return (skylist);
    187199  }
    188 
    189   if (selection->list != NULL) {
    190     skylist = SkyListLoadFile (selection->list);
    191     return (skylist);
    192   }
    193200
    194201  if (selection->useDisplay) {
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/remote.c

    r39283 r40477  
    2727    gprint (GP_ERR, "  -skip-result : do not try to read from the result file\n");
    2828    gprint (GP_ERR, "OR:    remote -reload (uniquer)\n");
     29    gprint (GP_ERR, "       (reloads the remote host results into vectors as if a parallel command were run)\n");
    2930    gprint (GP_ERR, "OR:    remote -get-results (uniquer)\n");
     31    gprint (GP_ERR, "       (generates the list of remote result filenames and status variables)\n");
     32    gprint (GP_ERR, "       (RESULT_FILE:i is the filenme, RESULT_STATUS:i is the dvo_client exit status)\n");
    3033    return FALSE;
    3134  }
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/showtile.c

    r39457 r40477  
    7878  Xvec.Nelements = Yvec.Nelements = N;
    7979  if (N > 0) {
    80     graphmode.style = 2; /* points */
    81     graphmode.ptype = 100; /* connect pairs of points */
     80    graphmode.style = KAPA_PLOT_POINTS; /* points */
     81    graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    8282    graphmode.etype = 0;
    8383    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/simage.c

    r37807 r40477  
    118118  }
    119119
    120   graphmode.style = 2;
     120  graphmode.style = KAPA_PLOT_POINTS;
    121121  graphmode.size = -1;
    122122  graphmode.etype = 0;
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/skycat.c

    r39926 r40477  
    121121  Xvec.Nelements = Yvec.Nelements = Npts;
    122122  if (Npts > 0) {
    123     graphmode.style = 2; /* points */
    124     graphmode.ptype = 100; /* connect pairs of points */
     123    graphmode.style = KAPA_PLOT_POINTS; /* points */
     124    graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    125125    graphmode.etype = 0;
    126126    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • branches/czw_branch/20170908/Ohana/src/opihi/dvo/skycoverage.c

    r39233 r40477  
    330330              break;
    331331            case MIN_MCAL:
    332               V[ys*Nx + xs] = MIN(V[ys*Nx + xs], image[i].Mcal);
     332              V[ys*Nx + xs] = MIN(V[ys*Nx + xs], image[i].McalPSF);
    333333              break;
    334334            case MAX_MCAL:
    335               V[ys*Nx + xs] = MAX(V[ys*Nx + xs], image[i].Mcal);
     335              V[ys*Nx + xs] = MAX(V[ys*Nx + xs], image[i].McalPSF);
    336336              break;
    337337            case MIN_TIME: {
  • branches/czw_branch/20170908/Ohana/src/opihi/include/astro.h

    r39610 r40477  
    4747double VectorFractionInterpolate (double *values, float fraction, int Npts);
    4848
    49 int PlxSetMeanEpoch (double *R, double *D, double *T, double *Rmean, double *Dmean, double *Tmean, int *mask, int Ntotal);
    50 int PlxSetEpochPosition (PlxFitData *fitdata, double *R, double *D, double *dR, double *dD, double *T, int *mask, int Ntotal, Coords *coords, double Tmean);
    51 int PlxOutlierClip (PlxFitData *fitdata, int *mask, int Noutlier, float dPsigMax, Vector *dPvec, int VERBOSE);
     49int PlxSetMeanEpoch (double *R, double *D, double *T, double *Rmean, double *Dmean, double *Tmean, opihi_int *mask, int Ntotal);
     50int PlxSetEpochPosition (PlxFitData *fitdata, double *R, double *D, double *dR, double *dD, double *T, opihi_int *mask, int Ntotal, Coords *coords, double Tmean);
     51int PlxOutlierClip (PlxFitData *fitdata, opihi_int *mask, int Noutlier, float dPsigMax, Vector *dPvec, int VERBOSE);
    5252
    5353int PlxFitDataAlloc (PlxFitData *data, int N);
  • branches/czw_branch/20170908/Ohana/src/opihi/include/data.h

    r37807 r40477  
    5050  float **buffers;
    5151} MedImageType;
     52
     53/*** typedef structs used by the Neural Network functions (nnet_*) ***/
     54typedef struct {
     55  char *name;
     56  int Nlayer; // Nlayers = input layer + output layer + hidden layers
     57  int *Nnodes; // number of nodes per layer
     58  float **weight; // a matrix between each layer
     59  float **biases; // a vector for each layer
     60
     61  float **zvalue; // a vector of z values for each layer (= w*input + b)
     62  float **svalue; // a vector of s values for each layer (= sigmoid(z))
     63  float **sprime; //
     64  float **delta;  //
     65
     66  float ** Nabla_b; // a vector of Nabla_b values for each layer
     67  float **dNabla_b; // a vector of Nabla_b values for each layer
     68
     69  float ** Nabla_w; // a matrix of Nabla_w values for each layer
     70  float **dNabla_w; // a matrix of Nabla_w values for each layer
     71} Nnet;
    5272
    5373void InitData (void);
     
    162182/* starfuncs.c */
    163183double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max, int VERBOSE);
     184double get_box_stats (Matrix *matrix, int X, int Y, int dX, int dY, int Nborder, double max, int VERBOSE);
     185
    164186int set_rough_radii (double Ra, double Ri, double Ro);
    165187int get_rough_star (float *data, int Nx, int Ny, int x, int y, opihi_flt *xc, opihi_flt *yc, opihi_flt *sx, opihi_flt *sy, opihi_flt *sxy, opihi_flt *zs, opihi_flt *zp, opihi_flt *sk);
     
    227249int GetKapaChannelFromString (char *string);
    228250
     251/*** Neural Network functions (nnet_*) ***/
     252
     253// in lib.data/nnet.c:
     254void InitNnets ();
     255void InitNnetData (Nnet *nnet, char *name, int Nlayer);
     256
     257void FreeNnets ();
     258void FreeNnetData (Nnet *nnet);
     259
     260Nnet *GetNnet (int where);
     261Nnet *FindNnet (char *name);
     262Nnet *CreateNnet (char *name, int Nlayer);
     263void CreateNnetData (Nnet *nnet, int LargeWeightInit);
     264
     265void PrintNnet (Nnet *nnet);
     266int  DeleteNnet (Nnet *nnet);
     267void ListNnets ();
     268
     269// in cmd.data/nnet.c:
     270int nnet_command (int argc, char **argv);
     271
     272// in cmd.data/nnet_commands.c:
     273int nnet_init (int argc, char **argv);
     274int nnet_list (int argc, char **argv);
     275int nnet_delete (int argc, char **argv);
     276int nnet_create (int argc, char **argv);
     277int nnet_set (int argc, char **argv);
     278int nnet_get (int argc, char **argv);
     279int nnet_read (int argc, char **argv);
     280int nnet_write (int argc, char **argv);
     281int nnet_print (int argc, char **argv);
     282
     283// in cmd.data/nnet_train.c:
     284int nnet_train (int argc, char **argv);
     285void nnet_feedforward (Nnet *nnet);
     286
     287// in cmd.data/nnet_apply.c:
     288int nnet_apply (int argc, char **argv);
     289
    229290# endif
  • branches/czw_branch/20170908/Ohana/src/opihi/include/dvoshell.h

    r39569 r40477  
    4141char *HOSTDIR;
    4242char *RESULT_FILE;
     43
     44typedef struct {
     45  int Nmeasure;
     46  int Nperiods;
     47  opihi_flt *period;
     48  opihi_flt *power;
     49  double P50;
     50  double R50;
     51  double R90;
     52} PeriodogramResult;
     53
     54/*** Periodogram functions (avperiodogram and avperiodomatch) ***/
     55void PeriodogramResultFree (PeriodogramResult *result);
     56void PeriodogramResultSave (PeriodogramResult *result, char *extname, FILE *foutput, Average *average);
     57void PeriodogramSetOptions (float minimumPeriod, float maximumPeriod);
     58PeriodogramResult *PeriodogramRawFloatingMean (opihi_flt *time, opihi_flt *flux, opihi_flt *dflux, int Npts);
    4359
    4460/*** dvo prototypes ***/
  • branches/czw_branch/20170908/Ohana/src/opihi/include/pantasks.h

    r36623 r40477  
    88
    99# define DEBUG 0
     10
     11typedef int IDtype;
    1012
    1113typedef enum {
     
    133135 
    134136typedef struct {
    135   int JobID;                            /* internal ID for job */
     137  IDtype JobID;                         /* internal ID for job */
    136138  int pid;                              /* external ID for job */
    137139
     
    204206void UpdateTaskTimerStats (Task *task, int mode, double dtime);
    205207
    206 int NextJobID (void);
     208IDtype NextJobID (void);
    207209void InitJobIDs (void);
    208210void FreeJobIDs (void);
    209 int FreeJobID (int ID);
    210211
    211212void InitJobs (void);
     
    213214
    214215Job *NextJob (void);
    215 Job *FindJob (int JobID);
     216Job *FindJob (IDtype JobID);
    216217void ListJobs (void);
    217218Job *CreateJob (Task *task);
     
    234235int SubmitControllerJob (Job *job);
    235236int DeleteControllerJob (Job *job);
    236 Job *FindControllerJob (int JobID);
     237Job *FindControllerJob (IDtype JobID);
    237238int StartController (void);
    238239int ControllerCommand (char *command, char *response, IOBuffer *buffer);
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.data/Makefile

    r39242 r40477  
    2020$(SDIR)/fft.$(ARCH).o                   \
    2121$(SDIR)/svdcmp.$(ARCH).o                \
    22 $(SDIR)/svdcmp_bond_new.$(ARCH).o               \
     22$(SDIR)/svdcmp_bond_new.$(ARCH).o       \
    2323$(SDIR)/bracket.$(ARCH).o               \
    2424$(SDIR)/spline.$(ARCH).o                \
     
    2727$(SDIR)/mrqmin.$(ARCH).o                \
    2828$(SDIR)/mrq2dmin.$(ARCH).o              \
     29$(SDIR)/nnet.$(ARCH).o                  \
    2930$(SDIR)/precess.$(ARCH).o               \
    3031$(SDIR)/starfuncs.$(ARCH).o             \
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.data/gaussian.c

    r38986 r40477  
    2626  if (Ngaussint == Nbin) return;
    2727
    28   long A = time(NULL);
    29   srand48(A);
     28  // long A = time(NULL);
     29  // srand48() is called by startup
    3030 
    3131  Ngaussint = Nbin;
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.data/graphtools.c

    r38153 r40477  
    1010  if (xvec != NULL) {
    1111    if (xvec->type == OPIHI_FLT) {
    12       maxX = DBL_MIN;
     12      maxX = -DBL_MAX;
    1313      minX = DBL_MAX;
    1414      for (i = 0; i < xvec[0].Nelements; i++) {
     
    3333  if (yvec != NULL) {
    3434    if (yvec->type == OPIHI_FLT) {
    35       maxY = DBL_MIN;
     35      maxY = -DBL_MAX;
    3636      minY = DBL_MAX;
    3737      for (i = 0; i < yvec[0].Nelements; i++) {
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.data/starfuncs.c

    r36679 r40477  
    101101}
    102102
     103double get_box_stats (Matrix *matrix, int X, int Y, int dX, int dY, int Nborder, double max, int VERBOSE) {
     104
     105  double *ring;
     106  double x, y, x2, y2, xy, I, sky, FWHMx, FWHMy, value, mag, Sxy;
     107  int i, j, n, Nring, Nmax;
     108  double Npts, gain, dsky2, dmag, peak, offset;
     109  char *string;
     110 
     111  string = get_variable ("GAIN");
     112  if (string == (char *) NULL) {
     113    gprint (GP_ERR, "assuming a value of 1.0\n");
     114    gain = 1.0;
     115  } else {
     116    gain = atof (string);
     117  }
     118  Nborder = MAX (1, Nborder);
     119  Nborder = MIN (1000, Nborder);
     120 
     121  int dX2 = (int)(0.5*dX);
     122  int dY2 = (int)(0.5*dY);
     123  dX = 2 * dX2 + 1;
     124  dY = 2 * dY2 + 1;
     125
     126  Nring = 2*Nborder*(dX + 2*Nborder) + 2*Nborder*(dY + 2*Nborder);
     127  ALLOCATE (ring, double, Nring);
     128  bzero (ring, sizeof(double)*Nring);
     129
     130  // get the pixels in the border regions:
     131  // XXX gfits_get_matrix_value returns 0 for out-of-bounds pixels, but should return NAN
     132  // and they should be skipped
     133  n = 0; 
     134  for (j = 0; j < Nborder; j++) {
     135    for (i = X - dX2 - Nborder; i < X + dX2 + Nborder + 1; i++) {
     136      value = gfits_get_matrix_value (matrix, i, (int)(Y - dY2 - j));
     137      if (isfinite(value)) { ring[n] = value; n++; }
     138      value = gfits_get_matrix_value (matrix, i, (int)(Y + dY2 + j));
     139      if (isfinite(value)) { ring[n] = value; n++; }
     140    }
     141    for (i = Y - dY2; i < Y + dY2 + 1; i++) {
     142      value = gfits_get_matrix_value (matrix, (int)(X - dX2 - j), i);
     143      if (isfinite(value)) { ring[n] = value; n++; }
     144      value = gfits_get_matrix_value (matrix, (int)(X + dX2 + j), i);
     145      if (isfinite(value)) { ring[n] = value; n++; }
     146    }
     147  }
     148  Nring = n;
     149  dsort (ring, Nring);
     150  for (Npts = sky = dsky2 = 0, i = 0.25*Nring; i < 0.75*Nring; i++, Npts += 1.0) {
     151    sky += ring[i];
     152    dsky2 += ring[i]*ring[i];
     153  }
     154  sky = sky / Npts;
     155  dsky2 = dsky2 / Npts - sky*sky;
     156  free (ring);
     157
     158  float dx, dy;
     159
     160  peak = 0;
     161  Npts = Nmax = 0;
     162  x = y = x2 = y2 = xy = I = 0;
     163  for (i = X - dX2; i < X + dX2 + 1; i++) {
     164    for (j = Y - dY2; j < Y + dY2 + 1; j++) {
     165      value = gfits_get_matrix_value (matrix, i, j);
     166      if (!isfinite(value)) continue;
     167      offset = value - sky;
     168      dx = i - X;
     169      dy = j - Y;
     170      x  += dx*offset;
     171      y  += dy*offset;
     172      x2 += dx*dx*offset;
     173      y2 += dy*dy*offset;
     174      xy += dx*dy*offset;
     175      I  += offset;
     176      Npts ++;
     177      if (value > max) {
     178        Nmax ++;
     179      }
     180      if (value > peak) peak = value;
     181    }
     182  }
     183
     184  x = x / I;
     185  y = y / I;
     186  FWHMx = 2.355*sqrt (fabs(x2 / I - x*x));
     187  FWHMy = 2.355*sqrt (fabs(y2 / I - y*y));
     188  Sxy   = xy / I - x*y;
     189  mag = -2.5*log10(I);
     190
     191  // flux_error = sqrt( I + Npts*dsky2 )
     192  // dmag = 1.086 * flux_error / flux
     193  dmag = 1.086 * sqrt (fabs(I + Npts*dsky2)) / (gain * I);
     194  x = x + X;
     195  y = y + Y;
     196 
     197  set_variable ("Xg", x);
     198  set_variable ("Yg", y);
     199  set_variable ("SXg", FWHMx);
     200  set_variable ("SYg", FWHMy);
     201  set_variable ("SXYg", Sxy);
     202  set_variable ("Sg", sky);
     203  set_variable ("dSg", sqrt (fabs (dsky2)));
     204  set_variable ("Zg", mag);
     205  set_variable ("dZg", dmag);
     206  set_variable ("Zcg", I);
     207  set_variable ("Zpk", peak);
     208  set_int_variable ("Nsat", Nmax);
     209  set_int_variable ("Npts", Npts);
     210 
     211  if (VERBOSE) gprint (GP_LOG, "%f %f %f %f %f %f %f %f\n", x, y, FWHMx, FWHMy, sky, I, mag, dmag);
     212
     213  return (mag);
     214
     215}
     216
    103217static double Raper  =  5;
    104218static double Rinner = 10;
     
    171285    off = j*Nx;
    172286    for (i = Xs; i < Xe; i++) {
     287      if (!isfinite(data[i+off])) continue;
    173288      sky[Nsky] = data[i+off];
    174289      Nsky ++;
     
    180295    off = j*Nx;
    181296    for (i = Xs; i < Xe; i++) {
     297      if (!isfinite(data[i+off])) continue;
    182298      sky[Nsky] = data[i+off];
    183299      Nsky ++;
     
    191307    off = j*Nx;
    192308    for (i = Xs; i < Xe; i++) {
     309      if (!isfinite(data[i+off])) continue;
    193310      sky[Nsky] = data[i+off];
    194311      Nsky ++;
     
    200317    off = j*Nx;
    201318    for (i = Xs; i < Xe; i++) {
     319      if (!isfinite(data[i+off])) continue;
    202320      sky[Nsky] = data[i+off];
    203321      Nsky ++;
     
    227345      rad2 = SQ(Xc) + SQ(Yc);
    228346      if (rad2 > Ro2) continue;
     347      // if (!isfinite(data[i+off])) continue;
    229348      value = data[i+off] - fsky;
    230349      Sx  += Xc*value;
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.shell/VectorIO.c

    r39457 r40477  
    4141    for (j = 0; j < Nvec; j++) {
    4242      // if the format is not defined, just use the native byte-widths
    43       tformat[2*j + 0] = (vec[j][0].type == OPIHI_FLT) ? 'D' : 'J';
     43      tformat[2*j + 0] = (vec[j][0].type == OPIHI_FLT) ? 'D' : 'K'; // this depends on opihi_int == int64_t for Int
    4444      tformat[2*j + 1] = 0;
    4545    }
     
    6060  for (j = 0; j < Nvec; j++) {
    6161    if (vec[j][0].type == OPIHI_FLT) {
    62       gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "double", vec[j][0].elements.Flt, vec[j][0].Nelements, nativeOrder);
     62      gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "double",  vec[j][0].elements.Flt, vec[j][0].Nelements, nativeOrder);
    6363    } else {
    64       gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int", vec[j][0].elements.Int, vec[j][0].Nelements, nativeOrder);
     64//    gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int",     vec[j][0].elements.Int, vec[j][0].Nelements, nativeOrder);
     65      gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int64_t", vec[j][0].elements.Int, vec[j][0].Nelements, nativeOrder);
    6566    }
    6667  }
     
    328329  ASSIGN_DATA(short,   short,   Int);
    329330  ASSIGN_DATA(int,     int,     Int);
    330   ASSIGN_DATA(int64_t, int64_t, Flt); // int64_t has a problem: Int is too small, Flt is wrong precision
     331  ASSIGN_DATA(int64_t, int64_t, Int); // XXX this works if opihi_int is assigned to int64_t
     332//ASSIGN_DATA(int64_t, int64_t, Flt); // int64_t has a problem: Int is too small, Flt is wrong precision
    331333  ASSIGN_DATA(float,   float,   Flt);
    332334  ASSIGN_DATA(double,  double,  Flt);
     
    353355  ASSIGN_DATA_TRANSPOSE(short,   short,   Int);
    354356  ASSIGN_DATA_TRANSPOSE(int,     int,     Int);
    355   ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Flt);
     357  ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Int);
     358//ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Flt); // see above comment
    356359  ASSIGN_DATA_TRANSPOSE(float,   float,   Flt);
    357360  ASSIGN_DATA_TRANSPOSE(double,  double,  Flt);
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.shell/check_stack.c

    r38062 r40477  
    4848          Nz = stack[i].buffer[0].matrix.Naxis[2];
    4949        }
    50         if ((Nx != stack[i].buffer[0].matrix.Naxis[0]) &&
    51             (Ny != stack[i].buffer[0].matrix.Naxis[1]) &&
     50        if ((Nx != stack[i].buffer[0].matrix.Naxis[0]) ||
     51            (Ny != stack[i].buffer[0].matrix.Naxis[1]) |
    5252            (Nz != stack[i].buffer[0].matrix.Naxis[2])) {
    5353          push_error ("dimensions don't match");
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.shell/convert_to_RPN.c

    r39558 r40477  
    120120        Nop_stack ++;
    121121        break;
    122       case ST_UNARY:
    123122      case ST_BINARY:
    124123      case ST_TRINARY:
     
    139138        Nop_stack ++;
    140139        break;
     140      case ST_UNARY:
    141141      case ST_LEFT: 
    142142        /* push operator on OP stack */
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.shell/dvomath.c

    r39457 r40477  
    2929  unsigned int Ncstack;
    3030  cstack = isolate_elements (argc, argv, &Ncstack);
     31
     32  // for (i = 0; i < Ncstack; i++) {
     33  //   fprintf (stderr, "%d : %s\n", i, cstack[i]);
     34  // }
    3135
    3236  /* generate RPN stack from cstack arguments */
     
    8286      } else {
    8387        if (stack[0].type == ST_SCALAR_INT) {
    84           sprintf (outname, "%d", stack[0].IntValue);
     88          sprintf (outname, OPIHI_INT_FMT, stack[0].IntValue);
    8589        } else {
    8690          sprintf (outname, "%.12g", stack[0].FltValue);
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.shell/evaluate_stack.c

    r40207 r40477  
    8989      }
    9090      if (tmp_stack.type == ST_SCALAR_INT) {
    91         gprint (GP_ERR, "---> %d ", tmp_stack.IntValue);
     91        gprint (GP_ERR, "---> "OPIHI_INT_FMT" ", tmp_stack.IntValue);
    9292      }
    9393      if (tmp_stack.type == ST_SCALAR_FLT) {
     
    110110
    111111        if (i < 3) {  /* need two variables to operate on */
    112           snprintf (line, 512, "syntax error: trinary operator without three operands: %s\n", stack[i].name);
     112          snprintf (line, 512, "syntax error: trinary operator without three operands: %s\n(Note that the : in a trinary operation must be protected by spaces", stack[i].name);
    113113          push_error (line);
    114114          clear_stack (&tmp_stack);
     
    124124
    125125        /* there are no valid unary string operators */
    126         snprintf (line, 512, "invalid operands for trinary operator %s (mismatch types?)", stack[i].name);
     126        snprintf (line, 512, "invalid operands for trinary operator %s (mismatch types?)\n(Note that the : in a trinary operation must be protected by spaces)", stack[i].name);
    127127        push_error (line);
    128128        clear_stack (&tmp_stack);
     
    131131      got_three_op:
    132132        if (!status) {
    133           snprintf (line, 512, "syntax error: invalid operand for trinary operation: %s or %s or %s\n", stack[i-1].name, stack[i-2].name, stack[i-3].name);
     133          snprintf (line, 512, "syntax error: invalid operand for trinary operation: %s or %s or %s\n(Note that the : in a trinary operation must be protected by spaces)", stack[i-1].name, stack[i-2].name, stack[i-3].name);
    134134          push_error (line);
    135135          clear_stack (&tmp_stack);
     
    186186      got_two_op:
    187187        if (!status) {
    188           snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s\n", stack[i-1].name, stack[i-2].name);
     188          // we are guaranteed to have stack[i-1] and stack[i-2] since i >= 2 (above)
     189          char tmpvector[] = "Temporary Vector";
     190          char tmpmatrix[] = "Temporary Matrix";
     191         
     192          char *name1 = NULL;
     193          if (stack[i-1].name) {
     194            name1 = stack[i-1].name;
     195          } else {
     196            if (stack[i-1].type == ST_VECTOR_TMP) name1 = tmpvector;
     197            if (stack[i-1].type == ST_MATRIX_TMP) name1 = tmpmatrix;
     198          }
     199          char *name2 = NULL;
     200          if (stack[i-2].name) {
     201            name2 = stack[i-2].name;
     202          } else {
     203            if (stack[i-2].type == ST_VECTOR_TMP) name2 = tmpvector;
     204            if (stack[i-2].type == ST_MATRIX_TMP) name2 = tmpmatrix;
     205          }
     206
     207          snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s\n", name1, name2);
    189208          push_error (line);
     209
    190210          int isTrinary = TRUE;
    191211          isTrinary = isTrinary && (i >= 2);
     
    199219            push_error (line);
    200220          }
     221
    201222          clear_stack (&tmp_stack);
    202223          return (FALSE);
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.shell/parse.c

    r33662 r40477  
    145145    /* simple variable assignment */
    146146    /* dvomath returns a new string, or NULL, with the result of the expression */
     147    /* if dvomath returns NULL, the expression was not a math operation: treat as a string */
    147148    val = dvomath (1, &V1, &size, 0);
    148149    if (val == NULL) {
    149150      while (OHANA_WHITESPACE (*V1)) V1++;
    150151      val = strcreate (V1);
     152      init_error ();
    151153    }
    152154    // save the result
     
    245247        vec[0].elements.Flt[Nx] = atof (val);
    246248      } else {
    247         vec[0].elements.Int[Nx] = atol (val);
     249        vec[0].elements.Int[Nx] = atoll (val);
    248250      }
    249251    }
  • branches/czw_branch/20170908/Ohana/src/opihi/lib.shell/stack_math.c

    r40019 r40477  
    599599}
    600600
    601 // the vector is applied to each column (currently only valid for 2D matrix)
     601// the vector is applied to each ROW (currently only valid for 2D matrix), e.g.: M[20,10] * X[20] -> M'[20,10] where M'[2,1] = M[2,1] * X[2]
    602602int MV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
    603603
     
    607607  Nx = V1[0].buffer[0].matrix.Naxis[0];
    608608  Ny = V1[0].buffer[0].matrix.Naxis[1];
    609   if (Ny != V2[0].vector[0].Nelements) {
    610     push_error ("dimension mismatch");
     609  if (Nx != V2[0].vector[0].Nelements) {
     610    snprintf (line, 512, "error: matrix OP vector matrix dimensions do not match: (%d x %d) OP %d", Nx, Ny, V2[0].vector[0].Nelements);
     611    push_error (line);
    611612    return (FALSE);
    612613  }
     
    628629# define MV_FUNC(OP) {                                  \
    629630    if (V2->vector->type == OPIHI_FLT) {                \
    630       opihi_flt *M2  =  V2[0].vector[0].elements.Flt;   \
    631       for (i = 0; i < Ny; i++, M2++) {                  \
    632         for (j = 0; j < Nx; j++, out++, M1++) {         \
     631      for (i = 0; i < Ny; i++) {                        \
     632        opihi_flt *M2  =  V2[0].vector[0].elements.Flt; \
     633        for (j = 0; j < Nx; j++, out++, M1++, M2++) {   \
    633634          *out = OP;                                    \
    634635        }                                               \
     
    637638    }                                                   \
    638639    if (V2->vector->type != OPIHI_FLT) {                \
    639       opihi_int *M2  =  V2[0].vector[0].elements.Int;   \
    640       for (i = 0; i < Ny; i++, M2++) {                  \
    641         for (j = 0; j < Nx; j++, out++, M1++) {         \
     640      for (i = 0; i < Ny; i++) {                        \
     641        opihi_int *M2  =  V2[0].vector[0].elements.Int; \
     642        for (j = 0; j < Nx; j++, out++, M1++, M2++) {   \
    642643          *out = OP;                                    \
    643644        }                                               \
     
    695696}
    696697
    697 // the vector is applied to each row (currently only valid for 2D matrix)
     698// the vector is applied to each COLUMN (currently only valid for 2D matrix)
     699// e.g.: X[10] * M[20,10] -> M'[20,10] where M'[2,1] = X[1] * M[2,1]
    698700int VM_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
    699701
     
    703705  Nx = V2[0].buffer[0].matrix.Naxis[0];
    704706  Ny = V2[0].buffer[0].matrix.Naxis[1];
    705   if (Nx != V1[0].vector[0].Nelements) {
     707  if (Ny != V1[0].vector[0].Nelements) {
     708    snprintf (line, 512, "error: vector OP matrix dimensions do not match: %d OP (%d x %d)", V1[0].vector[0].Nelements, Nx, Ny);
     709    push_error (line);
    706710    return (FALSE);
    707711  }
     
    722726# define VM_FUNC(OP) {                                  \
    723727    if (V1->vector->type == OPIHI_FLT) {                \
    724       for (i = 0; i < Ny; i++) {                        \
    725         opihi_flt *M1  = V1[0].vector[0].elements.Flt;  \
    726         for (j = 0; j < Nx; j++, out++, M1++, M2++) {   \
     728      opihi_flt *M1  = V1[0].vector[0].elements.Flt;    \
     729      for (i = 0; i < Ny; i++, M1++) {                  \
     730        for (j = 0; j < Nx; j++, out++, M2++) { \
    727731          *out = OP;                                    \
    728732        }                                               \
     
    731735    }                                                   \
    732736    if (V1->vector->type != OPIHI_FLT) {                \
    733       for (i = 0; i < Ny; i++) {                        \
    734         opihi_int *M1  =  V1[0].vector[0].elements.Int; \
    735         for (j = 0; j < Nx; j++, out++, M1++, M2++) {   \
     737      opihi_int *M1  =  V1[0].vector[0].elements.Int;   \
     738      for (i = 0; i < Ny; i++, M1++) {                  \
     739        for (j = 0; j < Nx; j++, out++, M2++) { \
    736740          *out = OP;                                    \
    737741        }                                               \
  • branches/czw_branch/20170908/Ohana/src/opihi/mana/findrowpeaks.c

    r2938 r40477  
    2323
    2424  for (i = 1; i < Nrow - 1; i++) {
     25    if (!isfinite(row[i])) continue; // ignore NAN values
    2526    if (row[i] < threshold) continue;
    2627    if (row[i] < row[i-1]) continue;
  • branches/czw_branch/20170908/Ohana/src/opihi/pantasks/CheckController.c

    r39476 r40477  
    77
    88  char *p, *q;
    9   int i, Njobs, status, JobID;
     9  int i, Njobs, status;
     10  IDtype JobID;
    1011  Job *job;
    1112  IOBuffer buffer;
  • branches/czw_branch/20170908/Ohana/src/opihi/pantasks/JobIDOps.c

    r23557 r40477  
    11# include "pantasks.h"
    22
    3 # define MAX_N_JOBS 10000
    4 static char *JobIDList;
    5 static int   JobIDPtr;
     3# define MAX_N_JOBS 0x80000000
     4
     5static IDtype JobIDMax = 0;
    66
    77void InitJobIDs () {
    8 
    9   JobIDPtr = 0;
    10   ALLOCATE (JobIDList, char, MAX_N_JOBS);
    11   bzero (JobIDList, MAX_N_JOBS*sizeof(char));
     8  JobIDMax = 0;
    129
    1310
    14 void FreeJobIDs () {
    15   free (JobIDList);
     11void FreeJobIDs () { }
     12
     13/* return next unique ID, recycle every MAX_N_JOBS */
     14IDtype NextJobID () {
     15
     16  JobIDMax ++;
     17  if (JobIDMax >= MAX_N_JOBS) {
     18    gprint (GP_ERR, "ERROR: too many jobs spawned: %d, aborting\n", JobIDMax);
     19    abort();
     20  }
     21
     22  return (JobIDMax);
    1623}
    1724
    18 /* return next unique ID, recycle every MAX_N_JOBS */
    19 int NextJobID () {
    20 
    21   int Ntry;
    22 
    23   JobIDPtr ++;
    24   if (JobIDPtr >= MAX_N_JOBS) JobIDPtr = 0;
    25 
    26   Ntry = 0;
    27   while (JobIDList[JobIDPtr]) {
    28     Ntry ++;
    29     JobIDPtr ++;
    30     if (JobIDPtr >= MAX_N_JOBS) JobIDPtr = 0;
    31     if (Ntry == MAX_N_JOBS) return (-1);
    32   }
    33   JobIDList[JobIDPtr] = TRUE;
    34   return (JobIDPtr);
    35 }
    36 
    37 int FreeJobID (int JobID) {
    38 
    39   if (JobID < 0) return (FALSE);
    40   if (JobID >= MAX_N_JOBS) return (FALSE);
    41 
    42   JobIDList[JobID] = FALSE;
    43   return (TRUE);
    44 }
     25/* I am going to rework the jobID so that it just grows.  no need to ever free them
     26   as an int, that allows 2^31 jobs (2e9 jobs) */
  • branches/czw_branch/20170908/Ohana/src/opihi/pantasks/JobOps.c

    r38559 r40477  
    4141
    4242/* return job with given ID */
    43 Job *FindJob (int JobID) {
     43Job *FindJob (IDtype JobID) {
    4444
    4545  int i;
     
    5555
    5656/* return job with given controller Job ID */
    57 Job *FindControllerJob (int JobID) {
     57Job *FindControllerJob (IDtype JobID) {
    5858
    5959  int i;
     
    8282  gprint (GP_LOG, " Jobs in Pantasks Queue\n");
    8383  for (i = 0; i < Njobs; i++) {
    84     gprint (GP_LOG, " %4d  %6d: %-25s %10s %20s\n", Njobs, jobs[i][0].JobID, jobs[i][0].task[0].name, JobStateToString(jobs[i][0].state), jobs[i][0].argv[0]);
     84    gprint (GP_LOG, " %4d  %8d: %-25s %10s %20s\n", Njobs, jobs[i][0].JobID, jobs[i][0].task[0].name, JobStateToString(jobs[i][0].state), jobs[i][0].argv[0]);
    8585  }
    8686
     
    9797
    9898  job[0].JobID = NextJobID ();
     99
     100  // this should not happen; abort?
    99101  if (job[0].JobID < 0) {
    100102    free (job);
     
    165167  if (job == NULL) return;
    166168 
    167   FreeJobID (job[0].JobID);
    168 
    169169  for (i = 0; i < job[0].argc; i++) {
    170170    free (job[0].argv[i]);
  • branches/czw_branch/20170908/Ohana/src/opihi/pantasks/delete.c

    r23530 r40477  
    44
    55  Job *job;
    6   int JobID;
     6  IDtype JobID;
    77
    88  if (argc != 3) goto usage;
  • branches/czw_branch/20170908/Ohana/src/opihi/pantasks/kill.c

    r23530 r40477  
    44
    55  Job *job;
    6   int JobID;
     6  IDtype JobID;
    77
    88  if (argc < 2) {
     
    1010    return (FALSE);
    1111  }
    12   JobID = atoi (argv[1]);
     12  JobID = atoll (argv[1]);
    1313
    1414  JobTaskLock();
  • branches/czw_branch/20170908/Ohana/src/opihi/pantasks/test/nice_remote.sh

    r32632 r40477  
    1010  periods      -timeout 20
    1111  active       true
    12   npending 5
     12  npending 50
    1313 
    1414  stdout tmp.txt
     
    4444  periods      -timeout 20
    4545  active       true
    46   npending 5
     46  npending 50
    4747 
    4848  stdout tmp.txt
Note: See TracChangeset for help on using the changeset viewer.