IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33662


Ignore:
Timestamp:
Apr 1, 2012, 3:24:39 PM (14 years ago)
Author:
eugene
Message:

support for parallel dvo in mextract, avextract, avmerge, gstar, gcat; remove some if-def-ed out code already moved to libdvo; list -vectors and -buffers options (store names of vectors and buffers in lists); list -copy give error if missing source; catlist, hosts & remote functions to support parallel dvos; skyregion -save option; new skycoverage modes (-min-ubercal; -min-dmag-sys; -min-mcal; -max-mcal); gstar output formatting cleanups; add more average info to gstar output; functions for spectral similarity analysis; coords returns nans for projections off the sphere; fix cumulative function; add name:type option to opihi/read function (eg read a:float 2 b:time 3 c:int 4); line -frac option; vtype function to get vector types; threshold function; write -fits option; code for unfinished mtype function (matching vtype)

Location:
trunk/Ohana/src/opihi
Files:
2 deleted
44 edited
21 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/Makefile

    r31496 r33662  
    99dimm:            lib.data lib.shell cmd.basic cmd.data cmd.astro
    1010dvo:             lib.data lib.shell cmd.basic cmd.data cmd.astro
     11dvo_client:      lib.data lib.shell cmd.basic cmd.data cmd.astro
    1112pantasks:        lib.data lib.shell cmd.basic cmd.data cmd.astro
    1213pantasks_server: lib.data lib.shell cmd.basic cmd.data cmd.astro
     
    1819
    1920PROGRAM = mana dvo pantasks pclient pcontrol
    20 SPECIAL = pantasks_client pantasks_server
     21SPECIAL = pantasks_client pantasks_server dvo_client
    2122
    2223EXTRAS = dimm
     
    2425all:
    2526        for i in $(PROGRAM) $(SPECIAL); do $(MAKE) $$i || exit; done
    26         $(MAKE) pantasks_client
    27         $(MAKE) pantasks_server
    2827
    2928libs:
     
    3534install:
    3635        for i in $(PROGRAM) $(SPECIAL); do $(MAKE) $$i.install || exit; done
    37         $(MAKE) pantasks_client.install
    38         $(MAKE) pantasks_server.install
    3936
    4037extras-install:
     
    6360        if [ -d pantasks ]; then (cd pantasks && $(MAKE) $@); fi
    6461
     62dvo_client:
     63        if [ -d dvo ]; then (cd dvo && $(MAKE) $@); fi
     64
     65dvo_client.install: dvo_client
     66        if [ -d dvo ]; then (cd dvo && $(MAKE) $@); fi
     67
    6568$(PROGRAM) $(LIBS) $(EXTRAS):
    6669        if [ -d "$@" ]; then (cd $@ && $(MAKE)); fi
  • trunk/Ohana/src/opihi/cmd.astro/Makefile

    r32632 r33662  
    3232$(SRC)/fixwrap.$(ARCH).o           \
    3333$(SRC)/fixcols.$(ARCH).o           \
     34$(SRC)/fiximage.$(ARCH).o          \
    3435$(SRC)/gauss.$(ARCH).o             \
    35 $(SRC)/getvel.$(ARCH).o    \
    36 $(SRC)/getlst.$(ARCH).o    \
     36$(SRC)/getvel.$(ARCH).o            \
     37$(SRC)/getlst.$(ARCH).o            \
    3738$(SRC)/medianmap.$(ARCH).o         \
    3839$(SRC)/mkgauss.$(ARCH).o           \
     
    5152$(SRC)/precess.$(ARCH).o           \
    5253$(SRC)/profile.$(ARCH).o           \
    53 $(SRC)/radec.$(ARCH).o     \
    54 $(SRC)/region.$(ARCH).o    \
     54$(SRC)/radec.$(ARCH).o             \
     55$(SRC)/region.$(ARCH).o            \
    5556$(SRC)/rotcurve.$(ARCH).o          \
    5657$(SRC)/scale.$(ARCH).o             \
    5758$(SRC)/sexigesimal.$(ARCH).o       \
    5859$(SRC)/spec.$(ARCH).o              \
     60$(SRC)/specpairfit.$(ARCH).o       \
     61$(SRC)/spexseq.$(ARCH).o           \
     62$(SRC)/spex1dgas.$(ARCH).o         \
     63$(SRC)/spex2dgas.$(ARCH).o         \
     64$(SRC)/mkclusters.$(ARCH).o        \
    5965$(SRC)/star.$(ARCH).o              \
    60 $(SRC)/transform.$(ARCH).o        \
     66$(SRC)/transform.$(ARCH).o         \
    6167$(SRC)/imsub.$(ARCH).o             \
    6268$(SRC)/imfit.$(ARCH).o             \
  • trunk/Ohana/src/opihi/cmd.astro/coords.c

    r29540 r33662  
    8383    }
    8484    if (mode == PIXEL) {
     85      Xin = ohana_normalize_angle_to_midpoint (Xin, coords.crval1);
    8586      RD_to_XY (&Xout, &Yout, Xin, Yin, &coords);
    8687      if (!Quiet) gprint (GP_LOG, "%7.2f %7.2f\n", Xout, Yout);
     
    9293  if (mode == SKY) {
    9394    for (i = 0; i < xvec[0].Nelements; i++) {
    94       XY_to_RD (&xvec[0].elements.Flt[i], &yvec[0].elements.Flt[i], xvec[0].elements.Flt[i], yvec[0].elements.Flt[i], &coords);
     95      double Xin = xvec[0].elements.Flt[i];
     96      double Yin = yvec[0].elements.Flt[i];
     97      xvec[0].elements.Flt[i] = NAN;
     98      yvec[0].elements.Flt[i] = NAN;
     99      XY_to_RD (&xvec[0].elements.Flt[i], &yvec[0].elements.Flt[i], Xin, Yin, &coords);
    95100    }
    96101    return (TRUE);
     
    98103  if (mode == PIXEL) {
    99104    for (i = 0; i < xvec[0].Nelements; i++) {
    100       RD_to_XY (&xvec[0].elements.Flt[i], &yvec[0].elements.Flt[i], xvec[0].elements.Flt[i], yvec[0].elements.Flt[i], &coords);
     105      double Xin = xvec[0].elements.Flt[i];
     106      double Yin = yvec[0].elements.Flt[i];
     107      xvec[0].elements.Flt[i] = NAN;
     108      yvec[0].elements.Flt[i] = NAN;
     109      Xin = ohana_normalize_angle_to_midpoint (Xin, coords.crval1);
     110      RD_to_XY (&xvec[0].elements.Flt[i], &yvec[0].elements.Flt[i], Xin, Yin, &coords);
    101111    }
    102112    return (TRUE);
  • trunk/Ohana/src/opihi/cmd.astro/init.c

    r32632 r33662  
    1515int flux                    PROTO((int, char **));
    1616int fixwrap                 PROTO((int, char **));
     17int fiximage                PROTO((int, char **));
    1718int fixcols                 PROTO((int, char **));
    1819int fixrows                 PROTO((int, char **));
     
    4546int sexigesimal             PROTO((int, char **));
    4647int spec                    PROTO((int, char **));
     48int specpairfit             PROTO((int, char **));
     49int spexseq                 PROTO((int, char **));
     50int spex1dgas               PROTO((int, char **));
     51int spex2dgas               PROTO((int, char **));
     52int mkclusters              PROTO((int, char **));
    4753int star                    PROTO((int, char **));
    4854int times                   PROTO((int, char **));
     
    6470  {1, "flux",        flux,         "flux in a convex contour"},
    6571  {1, "fixwrap",     fixwrap,      "fix megacam over-wrapped pixels"},
     72  {1, "fiximage",    fiximage,     "fix pixels in an image by interpolation"},
    6673  {1, "fixcols",     fixcols,      "fix bad columns by comparing with others"},
    6774  {1, "fixrows",     fixrows,      "fix bad rows by comparing with others"},
     
    93100  {1, "sexigesimal", sexigesimal,  "convert to/from sexigesimal/decimal"},
    94101  {1, "spec",        spec,         "extract a spectrum"},
     102  {1, "specpairfit", specpairfit,  "fit spectrum to another spectrum"},
     103  {1, "spexseq",     spexseq,      "generate the spectral sequence"},
     104  {1, "spex1dgas",   spex1dgas,    "minimize distances in 1D"},
     105  {1, "spex2dgas",   spex2dgas,    "minimize distances in 2D"},
     106  {1, "mkclusters",  mkclusters,   "group spectra by distance"},
    95107  {1, "star",        star,         "star stats at rough coords"},
    96108  {1, "transform",   transform,    "geometric transformation of image"},
  • trunk/Ohana/src/opihi/cmd.basic/list.c

    r31667 r33662  
    1919    remove_argument (N, &argc, argv);
    2020    RunCommand = TRUE;
     21  }
     22
     23  if ((N = get_argument (argc, argv, "-vectors"))) {
     24    remove_argument (N, &argc, argv);
     25    if (argc != 2) {
     26      gprint (GP_ERR, "USAGE: list (root) -vectors\n");
     27      return (FALSE);
     28    }
     29    ListVectorsToList (argv[1]);
     30    return TRUE;
     31  }
     32
     33  if ((N = get_argument (argc, argv, "-buffers"))) {
     34    remove_argument (N, &argc, argv);
     35    if (argc != 2) {
     36      gprint (GP_ERR, "USAGE: list (root) -buffers\n");
     37      return (FALSE);
     38    }
     39    ListBuffersToList (argv[1]);
     40    return TRUE;
    2141  }
    2242
     
    85105    }
    86106   
     107    // old list must exist, or give an error
    87108    sprintf (line, "%s:n", argv[3]);
    88109    N = get_int_variable (line, &found);
     110    if (!found) {
     111      gprint (GP_ERR, "USAGE: list (newlist) -copy (oldlist) ...\n");
     112      gprint (GP_ERR, "ERROR: missing input list\n");
     113      return (FALSE);
     114    }
     115     
     116
    89117    sprintf (line, "%s:n", argv[1]);
    90118    set_int_variable (line, N);
     
    118146
    119147  // remove the single named entry from the list (finds entry with given name, reduces list length by one)
    120   // return an error if -add is given with no other args
    121148  if ((argc > 2) && (!strcmp (argv[2], "-del"))) {
    122149    if (argc != 4) {
     
    155182
    156183  if (argc != 2) {
    157     gprint (GP_ERR, "USAGE: list (root)                : supply list data, terminate with 'END'\n");
    158     gprint (GP_ERR, "USAGE: list (root) -x (command)   : create list from shell output\n");
    159     gprint (GP_ERR, "USAGE: list (root) -split (words) : create list from words\n");
    160     gprint (GP_ERR, "USAGE: list (root) -add (words)   : extend a list\n");
     184    gprint (GP_ERR, "USAGE: list (root)                                        : supply list data, terminate with 'END'\n");
     185    gprint (GP_ERR, "USAGE: list (root) -x (command)                           : create list from shell output\n");
     186    gprint (GP_ERR, "USAGE: list (root) -vectors                               : create list from vector names\n");
     187    gprint (GP_ERR, "USAGE: list (root) -buffers                               : create list from buffer names\n");
     188    gprint (GP_ERR, "USAGE: list (root) -split (words)                         : create list from words\n");
     189    gprint (GP_ERR, "USAGE: list (root) -splitbychar (char) (word) [(words)..] : create list from words\n");
     190    gprint (GP_ERR, "USAGE: list (root) -add (words)                           : extend a list\n");   
     191    gprint (GP_ERR, "USAGE: list (root) -copy (list)                           : copy a list to a new name\n");
     192    gprint (GP_ERR, "USAGE: list (root) -del (word)                            : delete the entry by value\n");
    161193    return (FALSE);
    162194  }
  • trunk/Ohana/src/opihi/cmd.basic/shell.c

    r16895 r33662  
    1313  int exit_status;
    1414  int wait_status;
    15   int result, length;
     15  int result;
    1616  char **args, *shell;
    1717  struct timeval start, now;
     
    3333  args[0] = shell;
    3434  args[1] = cmdflag;
    35 
    36   length = 0;
    37   for (i = 1; i < argc; i++) {
    38     length += strlen(argv[i]) + 1;
    39   }
    40  
    41   ALLOCATE (args[2], char, length);
    42   args[2][0] = 0;
    43   for (i = 1; i < argc; i++) {
    44     strcat (args[2], argv[i]);
    45     if (i < argc - 1) strcat (args[2], " ");
    46   }
     35  args[2] = paste_args (argc - 1, &argv[1]);
    4736  args[3] = NULL;
    4837
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r31635 r33662  
    123123$(SRC)/swapbytes.$(ARCH).o         \
    124124$(SRC)/textline.$(ARCH).o          \
     125$(SRC)/threshold.$(ARCH).o              \
    125126$(SRC)/tv.$(ARCH).o                \
    126127$(SRC)/tvchannel.$(ARCH).o         \
  • trunk/Ohana/src/opihi/cmd.data/cumulative.c

    r20936 r33662  
    2323    opihi_flt *Vi = ivec[0].elements.Flt;
    2424    *Vo = *Vi;
     25    Vi++;
     26    Vo++;
    2527    for (i = 1; i < ivec[0].Nelements; i++, Vi++, Vo++) {
    2628      *Vo = Vo[-1] + *Vi;
     
    2931    opihi_int *Vi = ivec[0].elements.Int;
    3032    *Vo = *Vi;
     33    Vi++;
     34    Vo++;
    3135    for (i = 1; i < ivec[0].Nelements; i++, Vi++, Vo++) {
    3236      *Vo = Vo[-1] + *Vi;
  • trunk/Ohana/src/opihi/cmd.data/cursor.c

    r31635 r33662  
    44
    55  char string[20], key[20], *name;
    6   int i, N, kapa;
     6  int i, N, kapa, VERBOSE;
    77  double X, Y, R, D, Z;
    88  void *oldsignal;
     
    1313  // if ((N = get_argument (argc, argv, "-g"))) {
    1414  // if ((N = get_argument (argc, argv, "-i"))) {
     15
     16  VERBOSE = TRUE;
     17  if ((N = get_argument (argc, argv, "-a"))) {
     18    VERBOSE = FALSE;
     19  }
    1520
    1621  name = NULL;
     
    5358    set_str_variable ("KEY", key);
    5459   
    55     gprint (GP_LOG, "%s %f %f %f %f %f\n", key, X, Y, Z, R, D);
     60    if (VERBOSE) gprint (GP_LOG, "%s %f %f %f %f %f\n", key, X, Y, Z, R, D);
    5661
    5762    if (!strcasecmp (key, "Q")) break;
  • trunk/Ohana/src/opihi/cmd.data/cut.c

    r20936 r33662  
    4848  case 'X':
    4949    /* create output vectors */
    50     ResetVector (xvec, OPIHI_FLT, MAX (nx, 1));
    51     ResetVector (yvec, OPIHI_FLT, MAX (nx, 1));
     50    ResetVector (xvec, OPIHI_FLT, nx);
     51    ResetVector (yvec, OPIHI_FLT, nx);
    5252    bzero (yvec[0].elements.Flt, nx*sizeof(opihi_flt));
    5353    for (i = 0; i < nx; i++) {
     
    8080  case 'y':
    8181  case 'Y':
    82     ResetVector (xvec, OPIHI_FLT, MAX (ny, 1));
    83     ResetVector (yvec, OPIHI_FLT, MAX (ny, 1));
     82    ResetVector (xvec, OPIHI_FLT, ny);
     83    ResetVector (yvec, OPIHI_FLT, ny);
    8484    bzero (yvec[0].elements.Flt, ny*sizeof(opihi_flt));
    8585    for (i = 0; i < ny; i++) {
  • trunk/Ohana/src/opihi/cmd.data/imcut.c

    r20936 r33662  
    3737  dY = dY / L;
    3838
    39   ResetVector (xvec, OPIHI_FLT, MAX (L, 1));
    40   ResetVector (yvec, OPIHI_FLT, MAX (L, 1));
     39  ResetVector (xvec, OPIHI_FLT, L);
     40  ResetVector (yvec, OPIHI_FLT, L);
    4141
    4242  V = (float *)buf[0].matrix.buffer;
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r31667 r33662  
    6161int header           PROTO((int, char **));
    6262int list_vectors     PROTO((int, char **));
     63int vtype            PROTO((int, char **));
    6364int load             PROTO((int, char **));
    6465int lookup           PROTO((int, char **));
     
    111112int swapbytes        PROTO((int, char **));
    112113int textline         PROTO((int, char **));
     114int threshold        PROTO((int, char **));
    113115int tv               PROTO((int, char **));
    114116int tvchannel        PROTO((int, char **));
     
    138140int zplot            PROTO((int, char **));
    139141int zcplot            PROTO((int, char **));
     142
     143// ???
     144// int mtype            PROTO((int, char **));
     145//  {1, "mtype",        mtype,            "return the type of the defined buffer"},
    140146
    141147static Command cmds[] = { 
     
    257263  {1, "swapbytes",    swapbytes,        "byte swap thing"},
    258264  {1, "textline",     textline,         "write text line on graph"},
     265  {1, "threshold",    threshold,        "find (interpolate) location of transition"},
    259266  {1, "tv",           tv,               "display an image on the Kii window"},
    260267  {1, "tvchannel",    tvchannel,        "set the current tv channel"},
     
    269276  {1, "vclip",        vclip,            "clip values in a vector to be within a range"},
    270277  {1, "vectors",      list_vectors,     "list vectors"},
     278  {1, "vtype",        vtype,            "return the vector type (FLT or INT)"},
    271279  {1, "vgauss",       vgauss,           "fit a Gaussian to a vector"},
    272280  {1, "vellipse",     vellipse,         "fit a Ellipse to a vector pair"},
  • trunk/Ohana/src/opihi/cmd.data/line.c

    r13479 r33662  
    33int line (int argc, char **argv) {
    44 
    5   int kapa;
     5  int kapa, N;
    66  Graphdata graphmode;
    77  float x[2], y[2];
     8
     9  /* FracPositions uses coordinates of 0-1 relative to axis range */
     10  int FracPositions = FALSE;
     11  if ((N = get_argument (argc, argv, "-frac"))) {
     12    remove_argument (N, &argc, argv);
     13    FracPositions = TRUE;
     14  }
    815
    916  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
     
    1825  y[1] = atof(argv[5]);
    1926
     27  if (FracPositions) {
     28    x[0] =  x[0] * (graphmode.xmax - graphmode.xmin) + graphmode.xmin;
     29    y[0] =  y[0] * (graphmode.ymax - graphmode.ymin) + graphmode.ymin;
     30    x[1] =  x[1] * (graphmode.xmax - graphmode.xmin) + graphmode.xmin;
     31    y[1] =  y[1] * (graphmode.ymax - graphmode.ymin) + graphmode.ymin;
     32  }   
     33
    2034  /* set point style and errorbar mode (these are NOT sticky) */
    2135  graphmode.style = 0;
  • trunk/Ohana/src/opihi/cmd.data/list_buffers.c

    r2598 r33662  
    99
    1010}
     11
     12# if (0)
     13int mtype (int argc, char **argv) {
     14
     15  Variable = (char *) NULL;
     16  if ((N = get_argument (argc, argv, "-var"))) {
     17    remove_argument (N, &argc, argv);
     18    Variable = strcreate (argv[N]);
     19    remove_argument (N, &argc, argv);
     20  }
     21
     22  if (argc != 2) {
     23    gprint (GP_ERR, "USAGE: mtype (buffer) [-var out]\n");
     24    return (FALSE);
     25  }
     26
     27  Buffer *buf = SelectBuffer (argv[1], OLDBUFFER, FALSE);
     28  if (!buf) {
     29    gprint (GP_ERR, "unknown buffer %s\n", argv[1]);
     30    free (Variable);
     31    return FALSE;
     32  }
     33
     34  if (buf->type == OPIHI_FLT) {
     35    if (Variable) {
     36      set_str_variable (Variable, "FLT");
     37    } else {
     38      gprint (GP_LOG, "%s : FLT\n", argv[1]);
     39    }
     40  } else {
     41    if (Variable) {
     42      set_str_variable (Variable, "INT");
     43    } else {
     44      gprint (GP_LOG, "%s : INT\n", argv[1]);
     45    }
     46  }
     47  if (Variable) free (Variable);
     48
     49  return (TRUE);
     50}
     51# endif
  • trunk/Ohana/src/opihi/cmd.data/list_vectors.c

    r2598 r33662  
    77}
    88
     9int vtype (int argc, char **argv) {
     10
     11  int N;
     12
     13  char *Variable = (char *) NULL;
     14  if ((N = get_argument (argc, argv, "-var"))) {
     15    remove_argument (N, &argc, argv);
     16    Variable = strcreate (argv[N]);
     17    remove_argument (N, &argc, argv);
     18  }
     19
     20  if (argc != 2) {
     21    gprint (GP_ERR, "USAGE: vtype (vector) [-var out]\n");
     22    return (FALSE);
     23  }
     24
     25  Vector *vec = SelectVector (argv[1], OLDVECTOR, FALSE);
     26  if (!vec) {
     27    gprint (GP_ERR, "unknown vector %s\n", argv[1]);
     28    free (Variable);
     29    return FALSE;
     30  }
     31
     32  if (vec->type == OPIHI_FLT) {
     33    if (Variable) {
     34      set_str_variable (Variable, "FLT");
     35    } else {
     36      gprint (GP_LOG, "%s : FLT\n", argv[1]);
     37    }
     38  } else {
     39    if (Variable) {
     40      set_str_variable (Variable, "INT");
     41    } else {
     42      gprint (GP_LOG, "%s : INT\n", argv[1]);
     43    }
     44  }
     45  if (Variable) free (Variable);
     46
     47  return (TRUE);
     48}
     49
  • trunk/Ohana/src/opihi/cmd.data/read_vectors.c

    r32632 r33662  
    2121}
    2222
     23// vector types
     24enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME};
     25
    2326int read_vectors (int argc, char **argv) {
    2427 
    25     int i, j, Nskip, Nvec, *col, done, status, IsCSV, VERBOSE;
    26   int Nbytes, nbytes, Nstart, NELEM, N, nread;
     28  int TimeFormat;
     29  time_t TimeReference;
     30  int i, j, Nskip, Narg, Nvec, *col, IsCSV, VERBOSE;
     31  int Nbytes, Nstart, NELEM, Nelem, nread, *coltype;
    2732  char *colstr, *c0, *c1, *buffer, *extname;
    28   double value;
    2933  Vector **vec;
    3034
    3135  /* auto-sense table type */
    32   if ((N = get_argument (argc, argv, "-fits"))) {
    33     remove_argument (N, &argc, argv);
    34     extname = strcreate (argv[N]);
     36  if ((Narg = get_argument (argc, argv, "-fits"))) {
     37    remove_argument (Narg, &argc, argv);
     38    extname = strcreate (argv[Narg]);
    3539    if (extname == (char *) NULL) return (FALSE);
    36     remove_argument (N, &argc, argv);
    37     status = read_table_vectors (argc, argv, extname);
     40    remove_argument (Narg, &argc, argv);
     41    int status = read_table_vectors (argc, argv, extname);
    3842    free (extname);
    3943    return (status);
     
    4145
    4246  Nskip = 0;
    43   if ((N = get_argument (argc, argv, "-skip"))) {
    44     remove_argument (N, &argc, argv);
    45     Nskip = atof (argv[N]);
    46     remove_argument (N, &argc, argv);
     47  if ((Narg = get_argument (argc, argv, "-skip"))) {
     48    remove_argument (Narg, &argc, argv);
     49    Nskip = atof (argv[Narg]);
     50    remove_argument (Narg, &argc, argv);
    4751  }
    4852
    4953  IsCSV = FALSE;
    50   if ((N = get_argument (argc, argv, "-csv"))) {
    51     remove_argument (N, &argc, argv);
     54  if ((Narg = get_argument (argc, argv, "-csv"))) {
     55    remove_argument (Narg, &argc, argv);
    5256    IsCSV = TRUE;
    5357  }
    5458
    5559  VERBOSE = FALSE;
    56   if ((N = get_argument (argc, argv, "-v"))) {
    57     remove_argument (N, &argc, argv);
     60  if ((Narg = get_argument (argc, argv, "-v"))) {
     61    remove_argument (Narg, &argc, argv);
    5862    VERBOSE = TRUE;
    5963  }
     
    6569  /* read name N name N  */
    6670
     71  // do this only optionally?
     72  GetTimeFormat (&TimeReference, &TimeFormat);
     73
    6774  if (f == (FILE *) NULL) {
    6875    gprint (GP_ERR, "no open file for read\n");
     
    7178  fseeko (f, 0LL, SEEK_SET);
    7279
    73 //  if (IsCSV) {
    74 //    status = read_vectors_csv (argc, argv, Nskip, f);
    75 //    return status;
    76 //  }
    77 
    7880  Nvec = (argc - 1) / 2;
    7981  ALLOCATE (vec, Vector *, Nvec);
    8082  ALLOCATE (col, int, Nvec);
     83  ALLOCATE (coltype, int, Nvec);
    8184
    8285  for (i = 0; i < Nvec; i++) {
     86
     87    // interpret the column names including type flags
     88    // XXX review the grammar before releasing this : is foo:type best, or is something else needed?
     89    // Note the conflict wrt list entries
     90    // the name may be of the form foo:type, where type may be one of : int, float, time
     91   
     92    coltype[i] = COLTYPE_FLT;
     93    char *colname = argv[2*i + 1];
     94    char *ptr = strchr (colname, ':');
     95    if (ptr) {
     96      // split out colname and type
     97      *ptr = 0;
     98      ptr ++;
     99      if (!ptr) goto bad_colname;
     100      coltype[i] = COLTYPE_NONE;
     101      if (!strcasecmp(ptr, "float")) { coltype[i] = COLTYPE_FLT; }
     102      if (!strcasecmp(ptr, "int"))   { coltype[i] = COLTYPE_INT; }
     103      if (!strcasecmp(ptr, "time"))  { coltype[i] = COLTYPE_TIME; }
     104      if (!coltype[i]) goto bad_colname;
     105    }
     106
    83107    if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) {
    84108      gprint (GP_ERR, "USAGE: read name N name N ...\n");
     
    87111      return (FALSE);   
    88112    }
    89     // XXX we could allow flags (eg, N.i) to specify INT vs FLT types vectors...
     113
    90114    colstr = argv[2*i+2];
    91115    for (j = 0; j < strlen (colstr); j++) {
     
    119143  NELEM = 1000;
    120144  for (i = 0; i < Nvec; i++) {
    121     ResetVector (vec[i], OPIHI_FLT, NELEM);
     145    if (coltype[i] == COLTYPE_INT) {
     146      ResetVector (vec[i], OPIHI_INT, NELEM);
     147    } else {
     148      // note that COLTYPE_TIME is a type of float
     149      ResetVector (vec[i], OPIHI_FLT, NELEM);
     150    }
    122151  }
    123152 
     
    128157  }
    129158
    130   Nstart = 0;
    131   N = 0;
    132   done = FALSE;
    133   while (!done) {
     159  // we have a working buffer read from the file. we parse the lines in the working buffer
     160  // until we reach the last chunk without an EOL char.  at that point, we shift the start
     161  // of the last (partial) line to the start of the buffer and re-fill.
     162
     163  Nstart = 0; // location of the last valid byte in the buffer (start filling here)
     164  Nelem = 0; // number of valid rows read (vector elements)
     165  while (TRUE) {
    134166    Nbytes = 0x10000 - Nstart;
    135167    bzero (&buffer[Nstart], Nbytes);
     
    139171      break;
    140172    }
    141     if (nread == 0) break;
    142     nbytes = nread + Nstart;
     173    if (nread == 0) break; // end of the file
     174    // nbytes = nread + Nstart;
    143175   
    144     status = TRUE;
    145     c0 = buffer;
    146     while (status) {
    147       c1 = strchr (c0, '\n');
     176    int bufferStatus = TRUE;
     177    c0 = buffer; // c0 always marks the start of a line
     178    while (bufferStatus) {
     179      c1 = strchr (c0, '\n'); // find the end of this current line
    148180      if (c1 == (char *) NULL) {
    149181        Nstart = strlen (c0);
    150182        memmove (buffer, c0, Nstart);
    151         status = FALSE;
    152       } else {
    153         *c1 = 0;
    154       }     
    155       if ((*c0 != '#') && (*c0 != '!')) {
    156         for (i = 0; (i < Nvec) && status; i++) {
     183        bufferStatus = FALSE;
     184        continue;
     185      }
     186      *c1 = 0; // mark the end of the line
     187
     188      if (*c0 == '#') { c0 = c1 + 1; continue; }
     189      if (*c0 == '!') { c0 = c1 + 1; continue; }
     190
     191      // parse the vectors in this line.  this code is a bit inefficient: each column
     192      // requires a separate pass through the line.
     193
     194      int lineStatus = TRUE;
     195      for (i = 0; i < Nvec; i++) {
     196        int ivalue;
     197        double dvalue;
     198        time_t tvalue;
     199        int readStatus = FALSE;
     200        // need to make the if cases for coltype[i]
     201        switch (coltype[i]) {
     202          case COLTYPE_INT:
     203            readStatus = IsCSV ? iparse_csv (&ivalue, col[i], c0) : iparse (&ivalue, col[i], c0);
     204            vec[i][0].elements.Int[Nelem] = readStatus ? ivalue : 0;
     205            break;
     206          case COLTYPE_FLT:
     207            readStatus = IsCSV ? dparse_csv (&dvalue, col[i], c0) : dparse (&dvalue, col[i], c0);
     208            vec[i][0].elements.Flt[Nelem] = readStatus ? dvalue : NAN;
     209            break;
     210          case COLTYPE_TIME:
     211            readStatus = IsCSV ? tparse_csv (&tvalue, col[i], c0) : tparse (&tvalue, col[i], c0);
     212            dvalue = TimeValue (tvalue, TimeReference, TimeFormat);
     213            vec[i][0].elements.Flt[Nelem] = readStatus ? dvalue : NAN;
     214            break;
     215        }
     216        if (!readStatus && VERBOSE) {
    157217          if (IsCSV) {
    158             status = dparse_csv (&value, col[i], c0);
     218            gprint (GP_ERR, "suspect field: %d (%s) in %s\n", col[i], argv[2*i+2], c0);
    159219          } else {
    160             status = dparse (&value, col[i], c0);
     220            gprint (GP_ERR, "suspect field: %d in %s\n", col[i], c0);
    161221          }
    162           if (status) {
    163               vec[i][0].elements.Flt[N] = value;
    164           } else {
    165               vec[i][0].elements.Flt[N] = NAN;
    166               if (VERBOSE) {
    167                   if (IsCSV) {
    168                       gprint (GP_ERR, "suspect field: %d (%s) in %s\n", col[i], argv[2*i+2], c0);
    169                   } else {
    170                       gprint (GP_ERR, "suspect field: %d in %s\n", col[i], c0);
    171                   }
    172               }
    173           }
    174         }
    175         if (status) {
    176             N++;
    177         } else {
    178             if (VERBOSE && FALSE) {
    179                 char temp[32];
    180                 strncpy (temp, c0, 32);
    181                 temp[31] = 0;
    182                 gprint (GP_ERR, "skip line %s\n\n", temp);
    183             }
    184         }
    185       }
    186       c0 = c1 + 1;
    187       if (N == NELEM) {
     222        }
     223        lineStatus &= readStatus;
     224      }
     225      if (!lineStatus && VERBOSE) {
     226        char temp[32];
     227        strncpy (temp, c0, 32);
     228        temp[31] = 0;
     229        gprint (GP_ERR, "skip line %s\n\n", temp);
     230      }
     231      Nelem ++;
     232      if (Nelem == NELEM) {
    188233        NELEM += 1000;
    189234        for (i = 0; i < Nvec; i++) {
    190           REALLOCATE (vec[i][0].elements.Flt, opihi_flt, NELEM);
    191         }
    192       }
     235          if (coltype[i] == COLTYPE_INT) {
     236            REALLOCATE (vec[i][0].elements.Int, opihi_int, NELEM);
     237          } else {
     238            REALLOCATE (vec[i][0].elements.Flt, opihi_flt, NELEM);
     239          }
     240        }
     241      }
     242      c0 = c1 + 1;
    193243    }
    194244  }
    195245  for (i = 0; i < Nvec; i++) {
    196     REALLOCATE (vec[i][0].elements.Flt, opihi_flt, MAX (N,1));
    197     vec[i][0].Nelements = N;
     246    if (coltype[i] == COLTYPE_INT) {
     247      REALLOCATE (vec[i][0].elements.Int, opihi_int, MAX (Nelem,1));
     248    } else {
     249      REALLOCATE (vec[i][0].elements.Flt, opihi_flt, MAX (Nelem,1));
     250    }
     251    vec[i][0].Nelements = Nelem;
    198252  }
    199253 
     
    242296    Nextend = atoi (extname);
    243297  }
     298
     299  // XXX ReadAll needs: deal with Extnum vs Extname, save vectors, etc
     300  // ReadAll = FALSE;
     301  // if ((N = get_argument (argc, argv, "-all"))) {
     302  //   remove_argument (N, &argc, argv);
     303  //   ReadAll = atoi (extname);
     304  //   if (argc != 1) ESCAPE ("-all option cannot be mixed with selected field");
     305  // }
    244306
    245307  if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ...");
     
    314376  for (i = 1; i < argc; i++) {
    315377    void   *data;
    316     char   *Pc;
    317     short  *Ps;
    318     int    *Pi;
    319     float  *Pf;
    320     double *Pd;
    321378    int Nval;
    322379    char name[80];
     
    345402        sprintf (name, "%s:%d", argv[i], j);
    346403      if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
    347       ResetVector (vec[j], vecType, MAX (Ny,1));
    348     }
    349 
     404      ResetVector (vec[j], vecType, Ny);
     405    }
     406
     407    if (!strcmp (type, "char")) {
     408      char *Ptr = data;
     409      for (j = 0; j < Ny; j++) {
     410        for (k = 0; k < Nval; k++, Ptr++) {
     411          vec[k][0].elements.Int[j] = *Ptr;
     412        }
     413      }
     414    }
     415    if (!strcmp (type, "short")) {
     416      short *Ptr = data;
     417      for (j = 0; j < Ny; j++) {
     418        for (k = 0; k < Nval; k++, Ptr++) {
     419          vec[k][0].elements.Int[j] = *Ptr;
     420        }
     421      }
     422    }
     423    if (!strcmp (type, "int")) {
     424      int *Ptr = data;
     425      for (j = 0; j < Ny; j++) {
     426        for (k = 0; k < Nval; k++, Ptr++) {
     427          vec[k][0].elements.Int[j] = *Ptr;
     428        }
     429      }
     430    }
     431    if (!strcmp (type, "int64_t")) {
     432      int64_t *Ptr = data;
     433      for (j = 0; j < Ny; j++) {
     434        for (k = 0; k < Nval; k++, Ptr++) {
     435          vec[k][0].elements.Int[j] = *Ptr;
     436        }
     437      }
     438    }
     439    if (!strcmp (type, "float")) {
     440      float *Ptr = data;
     441      for (j = 0; j < Ny; j++) {
     442        for (k = 0; k < Nval; k++, Ptr++) {
     443          vec[k][0].elements.Flt[j] = *Ptr;
     444        }
     445      }
     446    }
    350447    if (!strcmp (type, "double")) {
    351       Pd = (double *) data;
    352       for (j = 0; j < Ny; j++) {
    353         for (k = 0; k < Nval; k++, Pd++) {
    354           vec[k][0].elements.Flt[j] = *Pd;
    355         }
    356       }
    357     }
    358     if (!strcmp (type, "float")) {
    359       Pf = (float *) data;
    360       for (j = 0; j < Ny; j++) {
    361         for (k = 0; k < Nval; k++, Pf++) {
    362           vec[k][0].elements.Flt[j] = *Pf;
    363         }
    364       }
    365     }
    366     if (!strcmp (type, "int")) {
    367       Pi = (int *) data;
    368       for (j = 0; j < Ny; j++) {
    369         for (k = 0; k < Nval; k++, Pi++) {
    370           vec[k][0].elements.Int[j] = *Pi;
    371         }
    372       }
    373     }
    374     if (!strcmp (type, "short")) {
    375       Ps = (short *) data;
    376       for (j = 0; j < Ny; j++) {
    377         for (k = 0; k < Nval; k++, Ps++) {
    378           vec[k][0].elements.Int[j] = *Ps;
    379         }
    380       }
    381     }
    382     if (!strcmp (type, "char")) {
    383       Pc = (char *) data;
    384       for (j = 0; j < Ny; j++) {
    385         for (k = 0; k < Nval; k++, Pc++) {
    386           vec[k][0].elements.Int[j] = *Pc;
     448      double *Ptr = data;
     449      for (j = 0; j < Ny; j++) {
     450        for (k = 0; k < Nval; k++, Ptr++) {
     451          vec[k][0].elements.Flt[j] = *Ptr;
    387452        }
    388453      }
     
    396461  return (TRUE);
    397462}
    398 
    399 # if (0)
    400 int read_vectors_csv (int argc, char **argv, int Nskip, FILE *f) {
    401  
    402   int i, j, Nvec, *col, done, status;
    403   int Nbytes, nbytes, Nstart, NELEM, N, nread;
    404   char *colstr, *c0, *c1, *buffer, *extname;
    405   double value;
    406   Vector **vec;
    407 
    408   Nvec = (argc - 1) / 2;
    409   ALLOCATE (vec, Vector *, Nvec);
    410   ALLOCATE (col, int, Nvec);
    411 
    412   for (i = 0; i < Nvec; i++) {
    413     if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) {
    414       gprint (GP_ERR, "USAGE: read name N name N ...\n");
    415       free (vec);
    416       free (col);
    417       return (FALSE);   
    418     }
    419     // XXX we could allow flags (eg, N.i) to specify INT vs FLT types vectors...
    420     colstr = argv[2*i+2];
    421     for (j = 0; j < strlen (colstr); j++) {
    422       if (!isdigit(colstr[j])) {
    423         gprint (GP_ERR, "USAGE: read name N name N ...\n");
    424         free (vec);
    425         free (col);
    426         return (FALSE);   
    427       }
    428     }
    429     col[i] = atof (colstr);
    430   }
    431 
    432   // currently, all read vectors are forced to be type FLT
    433   NELEM = 1000;
    434   for (i = 0; i < Nvec; i++) {
    435     ResetVector (vec[i], OPIHI_FLT, NELEM);
    436   }
    437  
    438   ALLOCATE (buffer, char, 0x10001);
    439   bzero (buffer, 0x10001);
    440   for (i = 0; i < Nskip; i++) {
    441     scan_line (f, buffer);
    442   }
    443 
    444   Nstart = 0;
    445   N = 0;
    446   done = FALSE;
    447   while (!done) {
    448     Nbytes = 0x10000 - Nstart;
    449     bzero (&buffer[Nstart], Nbytes);
    450     nread = fread (&buffer[Nstart], 1, Nbytes, f);
    451     if (ferror (f)) {
    452       perror ("error reading data file");
    453       break;
    454     }
    455     if (nread == 0) break;
    456     nbytes = nread + Nstart;
    457    
    458     status = TRUE;
    459     c0 = buffer;
    460     while (status) {
    461       c1 = strchr (c0, '\n');
    462       if (c1 == (char *) NULL) {
    463         Nstart = strlen (c0);
    464         memmove (buffer, c0, Nstart);
    465         status = FALSE;
    466       } else {
    467         *c1 = 0;
    468       }     
    469       if ((*c0 != '#') && (*c0 != '!')) {
    470         for (i = 0; (i < Nvec) && status; i++) {
    471           status = dparse_csv (&value, col[i], c0);
    472           vec[i][0].elements.Flt[N] = value;
    473           if (!status) vec[i][0].elements.Flt[N] = NAN;
    474         }
    475         if (status) N++;
    476       }
    477       c0 = c1 + 1;
    478       if (N == NELEM) {
    479         NELEM += 1000;
    480         for (i = 0; i < Nvec; i++) {
    481           REALLOCATE (vec[i][0].elements.Flt, opihi_flt, NELEM);
    482         }
    483       }
    484        
    485     }
    486   }
    487   for (i = 0; i < Nvec; i++) {
    488     REALLOCATE (vec[i][0].elements.Flt, opihi_flt, MAX (N,1));
    489     vec[i][0].Nelements = N;
    490   }
    491  
    492   free (vec);
    493   free (col);
    494   free (buffer);
    495   return (TRUE);
    496 
    497 }
    498 
    499 # endif
  • trunk/Ohana/src/opihi/cmd.data/reindex.c

    r30610 r33662  
    2222
    2323  // ovec matches ivec in type and xvec in size (xvec need not have all ivec elements, and may have duplicates
    24   ResetVector (ovec, ivec->type, MAX (xvec[0].Nelements, 1));
     24  ResetVector (ovec, ivec->type, xvec[0].Nelements);
    2525
    2626  Nmax = ivec[0].Nelements - 1;
     
    5151
    5252  // free up unused memory
    53   ResetVector (ovec, ivec->type, MAX (Npts, 1));
     53  ResetVector (ovec, ivec->type, Npts);
    5454  return (TRUE);
    5555
  • trunk/Ohana/src/opihi/cmd.data/select.c

    r20936 r33662  
    2828
    2929  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_INT)) {
    30     ResetVector (ovec, OPIHI_INT, MAX (tvec[0].Nelements, 1));
     30    ResetVector (ovec, OPIHI_INT, tvec[0].Nelements);
    3131  } else {
    32     ResetVector (ovec, OPIHI_FLT, MAX (tvec[0].Nelements, 1));
     32    ResetVector (ovec, OPIHI_FLT, tvec[0].Nelements);
    3333  }
    3434
  • trunk/Ohana/src/opihi/cmd.data/write_vectors.c

    r30610 r33662  
    77  FILE *f;
    88  char **fmtlist, *fmttype;
    9   char *p0, *p1, *p2, *format;
     9  char *p0, *p1, *p2, *format, *FITS;
    1010  Vector **vec;
    1111
     
    1515    remove_argument (N, &argc, argv);
    1616    format = strcreate (argv[N]);
     17    remove_argument (N, &argc, argv);
     18  }
     19
     20  /* option generate a FITS output table */
     21  FITS = NULL;
     22  if ((N = get_argument (argc, argv, "-fits"))) {
     23    remove_argument (N, &argc, argv);
     24    FITS = strcreate (argv[N]);
    1725    remove_argument (N, &argc, argv);
    1826  }
     
    2937  }
    3038
    31   /* open file for outuput */
    32   if (append) {
    33       f = fopen (argv[1], "a");
    34   } else {
    35       f = fopen (argv[1], "w");
    36   }
    37   if (f == (FILE *) NULL) {
    38     gprint (GP_ERR, "can't open file for write\n");
    39     return (FALSE);
    40   }
    41 
    4239  /* find number of output vectors */
    4340  Nvec = (argc - 2);
    4441  if (Nvec < 1) {
    45       gprint (GP_ERR, "USAGE: write (file) vector vector ...\n");
    46       fclose (f);
    47   fflush (f);
    48       return (FALSE);
     42    gprint (GP_ERR, "USAGE: write (file) vector vector ...\n");
     43    return (FALSE);
    4944  }
    5045  ALLOCATE (vec, Vector *, Nvec);
     
    5651      gprint (GP_ERR, "USAGE: write (file) vector vector ...\n");
    5752      free (vec);
    58       fclose (f);
    59   fflush (f);
    6053      return (FALSE);   
    6154    }
     
    6861      gprint (GP_ERR, "error: vectors must all be the same size\n");
    6962      free (vec);
    70       fclose (f);
    71   fflush (f);
    7263      return (FALSE);   
    7364    }
     65  }
     66
     67  if (FITS) {
     68    int status = WriteVectorTableFITS (argv[1], FITS, vec, Nvec, append, format);
     69    free (vec);
     70    return status;
     71  }
     72
     73  /* open file for outuput */
     74  if (append) {
     75    f = fopen (argv[1], "a");
     76  } else {
     77    f = fopen (argv[1], "w");
     78  }
     79  if (f == (FILE *) NULL) {
     80    gprint (GP_ERR, "can't open file for write\n");
     81    return (FALSE);
    7482  }
    7583
     
    8896    fclose (f);
    8997    free (vec);
    90   fflush (f);
     98    fflush (f);
    9199    return (TRUE);
    92100  }
     
    111119      free (format);
    112120      fclose (f);
    113   fflush (f);
     121      fflush (f);
    114122      return (FALSE);
    115123    }
  • trunk/Ohana/src/opihi/dvo/Makefile

    r31635 r33662  
    2323$(SRC)/compare.$(ARCH).o                \
    2424$(SRC)/dvomisc.$(ARCH).o                \
     25$(SRC)/dvo_host_utils.$(ARCH).o         \
    2526$(SRC)/region_list.$(ARCH).o            \
    2627$(SRC)/find_matches.$(ARCH).o           \
    27 $(SRC)/photometry.$(ARCH).o             \
    28 $(SRC)/dvo.$(ARCH).o
     28$(SRC)/photometry.$(ARCH).o             
    2929
    3030cmds = \
     
    5050$(SRC)/fitsed.$(ARCH).o                \
    5151$(SRC)/gcat.$(ARCH).o                   \
     52$(SRC)/catlist.$(ARCH).o                        \
    5253$(SRC)/gimages.$(ARCH).o                \
    5354$(SRC)/gstar.$(ARCH).o                  \
     55$(SRC)/hosts.$(ARCH).o          \
    5456$(SRC)/images.$(ARCH).o         \
    5557$(SRC)/imbox.$(ARCH).o                  \
     
    7173$(SRC)/paverage.$(ARCH).o               \
    7274$(SRC)/procks.$(ARCH).o         \
     75$(SRC)/remote.$(ARCH).o         \
    7376$(SRC)/skycat.$(ARCH).o         \
    7477$(SRC)/skycoverage.$(ARCH).o            \
     
    8891dvo: $(BIN)/dvo.$(ARCH)
    8992$(SRC)/dvo.$(ARCH).o : $(libs)
    90 $(BIN)/dvo.$(ARCH)   : $(funcs) $(cmds)
     93$(BIN)/dvo.$(ARCH)   : $(funcs) $(cmds) $(SRC)/dvo.$(ARCH).o
     94
     95dvo_client: $(BIN)/dvo_client.$(ARCH)
     96$(SRC)/dvo_client.$(ARCH).o : $(libs)
     97$(BIN)/dvo_client.$(ARCH)   : $(funcs) $(cmds) $(SRC)/dvo_client.$(ARCH).o
     98
     99dvo.install: $(DESTBIN)/dvo
     100dvo_client.install: $(DESTBIN)/dvo_client
    91101
    92102install: $(DESTBIN)/dvo help modules
     
    98108modules: dvo.modules
    99109
    100 .PHONY: dvo
     110.PHONY: dvo dvo_client
    101111
    102112# deprecated functions: verify & delete
  • trunk/Ohana/src/opihi/dvo/avextract.c

    r31450 r33662  
    3737  }
    3838
     39  int PARALLEL = FALSE;
     40  if ((N = get_argument (argc, argv, "-parallel"))) {
     41    remove_argument (N, &argc, argv);
     42    PARALLEL = TRUE;
     43  }
     44
     45  // use remote tables, but not dvo_client..
     46  int PARALLEL_LOCAL = FALSE;
     47  HostTable *table = NULL;
     48  if ((N = get_argument (argc, argv, "-parallel-local"))) {
     49    remove_argument (N, &argc, argv);
     50    PARALLEL_LOCAL = TRUE;
     51
     52    char *CATDIR = GetCATDIR();
     53    if (!CATDIR) {
     54      gprint (GP_ERR, "CATDIR is not set\n");
     55      return FALSE;
     56    }
     57    SkyTable *sky = GetSkyTable();
     58    if (!sky) {
     59      gprint (GP_ERR, "failed to load sky table for database\n");
     60      return FALSE;
     61    }
     62    table = HostTableLoad (CATDIR, sky->hosts);
     63    if (!table) {
     64      gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
     65      return FALSE;
     66    }   
     67  }
     68
    3969  dvo_catalog_init (&catalog, TRUE);
    4070
     
    4373  Nsecfilt = GetPhotcodeNsecfilt ();
    4474
    45   // parse skyregion options
     75  // parse skyregion options.  NOTE: this is stripped off in parallel operation and always
     76  // defined for the client via the -skyregion option.  The dvo_client parses this
     77  // argument in the main program, before it is passed to the command (like mextract)
    4678  if ((selection = SetRegionSelection (&argc, argv)) == NULL) {
    4779    print_error();
     
    85117  /* load region corresponding to selection above */
    86118  if ((skylist = SelectRegions (selection)) == NULL) goto escape;
     119
     120  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
     121  if (PARALLEL && !HOST_ID) {
     122    int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
     123
     124    dbFreeFields (fields, Nfields);
     125    dbFreeStack (stack, Nstack);
     126    free (stack);
     127    FreeSkyRegionSelection (selection);
     128    dvo_catalog_free (&catalog);
     129
     130    return status;
     131  }
    87132
    88133  /* create output storage vectors */
     
    114159  interrupt = FALSE;
    115160  for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
     161
     162    // does this host ID match the desired location for the table?
     163    if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue;
     164
    116165    /* lock, load, unlock catalog */
    117     catalog.filename = skylist[0].filename[i];
     166    char hostfile[1024];
     167    if (PARALLEL_LOCAL) {
     168      int hostID = (skylist[0].regions[i]->hostFlags & DATA_USE_BCK) ? skylist[0].regions[i]->backupID : skylist[0].regions[i]->hostID;
     169      int seq = table->index[hostID];
     170      HOSTDIR = table->hosts[seq].pathname;
     171    }
     172    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
     173    catalog.filename = (HOST_ID || PARALLEL_LOCAL) ? hostfile : skylist[0].filename[i];
    118174    catalog.catflags = LOAD_AVES | LOAD_SECF;
    119175    if (needMeasures) {
     
    169225  interrupt = FALSE;
    170226  for (n = 0; n < Nreturn; n++) {
    171     vec[n][0].Nelements = Npts;
    172     if (vec[n][0].type == OPIHI_FLT) {
    173       REALLOCATE (vec[n][0].elements.Flt, opihi_flt, MAX(1,Npts));
    174     } else {
    175       REALLOCATE (vec[n][0].elements.Int, opihi_int, MAX(1,Npts));
    176     }
    177   }
    178 
     227    ResetVector (vec[n], fields[n].type, Npts);
     228  }
     229
     230  // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)
     231  if (RESULT_FILE) {
     232    int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL);
     233    if (!status) goto escape;
     234  }
     235
     236  if (table) free (table);
    179237  if (vec) free (vec);
    180238  if (values) free (values);
     
    187245
    188246 escape:
     247  if (table) free (table);
    189248  if (vec) free (vec);
    190249  if (values) free (values);
  • trunk/Ohana/src/opihi/dvo/avmatch.c

    r28241 r33662  
    1414 
    1515  off_t i, j, n, m, *index;
    16   int N, Ncat, Npts, NPTS, last, Nfields, Nsecfilt;
     16  int N, Ncat, Npts, NPTS, last, Nfields, Nsecfilt, Ninvec;
    1717  int VERBOSE;
    18   char name[1024];
     18  char name[1024], *found;
    1919  void *Signal;
    2020  float RADIUS;
     
    2222  Catalog catalog;
    2323
    24   Vector **vec, *RAvec, *DECvec;
     24  Vector **vec, **invec, *RAvec, *DECvec;
    2525  dbField *fields;
    2626  dbValue *values;
     
    2929  /* defaults */
    3030  vec = NULL;
     31  invec = NULL;
    3132  fields = NULL;
    3233  values = NULL;
    3334  skylist = NULL;
     35  Ninvec = 0;
    3436
    3537  if ((N = get_argument (argc, argv, "-h"))) goto help;
    3638  if ((N = get_argument (argc, argv, "--help"))) goto help;
    37   if (argc < 5) goto help;
    3839
    3940  VERBOSE = FALSE;
     
    4344  }
    4445
     46  int PARALLEL = FALSE;
     47  if ((N = get_argument (argc, argv, "-parallel"))) {
     48    remove_argument (N, &argc, argv);
     49    PARALLEL = TRUE;
     50  }
     51
     52  // dump results directly to fits file (esp for parallel dvo)
     53  char *CoordsFile = NULL;
     54  if ((N = get_argument (argc, argv, "-coords"))) {
     55    remove_argument (N, &argc, argv);
     56    CoordsFile = strcreate(argv[N]);
     57    remove_argument (N, &argc, argv);
     58  }
     59
     60  if (!CoordsFile && (argc < 5)) goto help;
     61  if ( CoordsFile && (argc < 3)) goto help;
     62
    4563  dvo_catalog_init (&catalog, TRUE);
    4664
     
    4967  Nsecfilt = GetPhotcodeNsecfilt ();
    5068
     69  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
     70  RAvec  = NULL;
     71  DECvec = NULL;
     72  if (PARALLEL && !HOST_ID) {
     73    if (!CoordsFile) {
     74      // get vectors corresponding to coordinates of interest
     75      if ((RAvec  = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help;
     76      if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help;
     77     
     78      ALLOCATE (vec, Vector *, 2);
     79      vec[0] = RAvec;
     80      vec[1] = DECvec;
     81
     82      CoordsFile = abspath("coords.fits", 1024);
     83      int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);
     84      if (!status) goto escape;
     85    }
     86
     87    char *targv1 = argv[1];
     88    char *targv2 = argv[2];
     89    argv[1] = strcreate ("-coords");
     90    argv[2] = strcreate (CoordsFile);
     91    free (CoordsFile);
     92
     93    // I need to pass the RA & DEC vectors to the remote clients...
     94    int status = HostTableParallelOps (argc, argv, RESULT_FILE, RAvec->Nelements, VERBOSE);
     95    if (vec) free (vec);
     96   
     97    free (argv[1]);
     98    free (argv[2]);
     99    argv[1] = targv1;
     100    argv[2] = targv2;
     101
     102    return status;
     103  }
     104
    51105  // get vectors corresponding to coordinates of interest
    52   if ((RAvec  = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help;
    53   if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help;
    54   RADIUS = atof (argv[3]);
    55 
    56   // strip off RA, DEC, RADIUS arguments
    57   remove_argument (1, &argc, argv);
    58   remove_argument (1, &argc, argv);
     106  if (CoordsFile) {
     107    // read RAvec, DECvec from coords file (1st 2 fields?)
     108    Ninvec = 0;
     109    invec = ReadVectorTableFITS (CoordsFile, "COORDS", &Ninvec);
     110    RAvec = invec[0];
     111    DECvec = invec[1];
     112  } else {
     113    if ((RAvec  = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help;
     114    if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help;
     115    // strip off RA & DEC
     116    remove_argument (1, &argc, argv);
     117    remove_argument (1, &argc, argv);
     118  }
     119  RADIUS = atof (argv[1]);
    59120  remove_argument (1, &argc, argv);
    60121
     
    92153  }
    93154  ALLOCATE (index, off_t, NPTS);
     155  ALLOCATE (found, char, NPTS);
     156  memset (found, 0, NPTS*sizeof(char));
    94157
    95158  // grab data from all selected sky regions
     
    97160  interrupt = FALSE;
    98161  for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
     162
     163    // does this host ID match the desired location for the table?
     164    if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue;
     165
    99166    /* lock, load, unlock catalog */
    100     catalog.filename = skylist[0].filename[i];
     167    char hostfile[1024];
     168    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
     169    catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i];
    101170    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    102171    catalog.Nsecfilt = 0;
     
    124193      if (Ncat == -2) continue;
    125194
    126       // XXX set a 'found' vector to double check we catch everything?
    127195      m = catalog.average[Ncat].measureOffset;
    128196
     
    141209        }
    142210      }
     211      found[Npts] = TRUE;
    143212    }
    144213    dvo_catalog_free (&catalog);
     
    147216  interrupt = FALSE;
    148217
     218  // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)
     219  // only write the fields which were in a valid catalog
     220  if (RESULT_FILE) {
     221    // extend the array by one to hold index array
     222    REALLOCATE (vec, Vector *, Nfields + 1);
     223    vec[Nfields] = InitVector();
     224    strcpy (vec[Nfields]->name, "index");
     225    ResetVector (vec[Nfields], OPIHI_INT, NPTS);
     226    Vector *idxVec = vec[Nfields];
     227
     228    // only write out the rows which were found
     229    Npts = 0;
     230    for (i = 0; i < NPTS; i++) {
     231      if (!found[i]) continue;
     232      idxVec->elements.Int[Npts] = i;
     233      Npts ++;
     234    }
     235    int Nfound = Npts;
     236    idxVec->Nelements = Nfound;
     237
     238    fprintf (stderr, "found %d of %d pts\n", Nfound, NPTS);
     239
     240    for (i = 0; i < Nfields; i++) {
     241      if (vec[i][0].type == OPIHI_FLT) {
     242        opihi_flt *tmp = NULL;
     243        ALLOCATE (tmp, opihi_flt, Nfound);
     244        Npts = 0;
     245        for (j = 0; j < NPTS; j++) {
     246          if (!found[j]) continue;
     247          tmp[Npts] = vec[i][0].elements.Flt[j];
     248          Npts++;
     249        }
     250        free (vec[i][0].elements.Flt);
     251        vec[i][0].elements.Flt = tmp;
     252      } else {
     253        opihi_int *tmp = NULL;
     254        ALLOCATE (tmp, opihi_int, Nfound);
     255        Npts = 0;
     256        for (j = 0; j < NPTS; j++) {
     257          if (!found[j]) continue;
     258          tmp[Npts] = vec[i][0].elements.Int[j];
     259          Npts++;
     260        }
     261        free (vec[i][0].elements.Int);
     262        vec[i][0].elements.Int = tmp;
     263      }
     264      vec[i][0].Nelements = Nfound;
     265    }
     266    int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields + 1, FALSE, NULL);
     267    free (vec[Nfields]->elements.Int);
     268    free (vec[Nfields]);
     269    if (!status) goto escape;
     270  }
     271
    149272  if (vec) free (vec);
    150273  if (values) free (values);
     274  if (invec) FreeVectorArray (invec, Ninvec);
    151275  dbFreeFields (fields, Nfields);
    152276  SkyListFree (skylist);
     
    156280  if (vec) free (vec);
    157281  if (values) free (values);
     282  if (invec) FreeVectorArray (invec, Ninvec);
    158283  dbFreeFields (fields, Nfields);
    159284  SkyListFree (skylist);
     
    162287 help:
    163288  gprint (GP_ERR, "USAGE: avmatch (RA) (DEC) (RADIUS) field[,field,field...]\n");
     289  gprint (GP_ERR, "   OR: avmatch -coords (filename.fits) (RADIUS) field[,field,field...]\n");
    164290
    165291  if ((argc > N + 1) && !strcasecmp (argv[N+1], "fields")) {
  • trunk/Ohana/src/opihi/dvo/dvo.c.in

    r16433 r33662  
    2929  set_str_variable ("PROMPT", opihi_prompt);
    3030  set_str_variable ("RCFILE", opihi_rcfile);
     31  set_int_variable ("DVO_CLIENT", FALSE);
    3132
    3233  {
     
    4445    free (modules);
    4546  }
     47
     48  // dvo_client uses the following; they should be NULL for dvo
     49  HOST_ID = 0;
     50  HOSTDIR = NULL;
     51  RESULT_FILE = NULL;
    4652
    4753  return;
  • trunk/Ohana/src/opihi/dvo/gcat.c

    r20535 r33662  
    33int gcat (int argc, char **argv) {
    44 
    5   int i;
     5  int i, N;
    66  struct stat filestat;
    77  double Ra, Dec, Radius;
     
    1010  void *Signal;
    1111
     12  int ShowHost = FALSE;
     13  if ((N = get_argument (argc, argv, "-host"))) {
     14    remove_argument (N, &argc, argv);
     15    ShowHost = TRUE;
     16  }
     17  int ShowBackup = FALSE;
     18  if ((N = get_argument (argc, argv, "-backup"))) {
     19    remove_argument (N, &argc, argv);
     20    ShowBackup = TRUE;
     21  }
     22  int ShowFlags = FALSE;
     23  if ((N = get_argument (argc, argv, "-flags"))) {
     24    remove_argument (N, &argc, argv);
     25    ShowFlags = TRUE;
     26  }
     27
    1228  if ((argc != 3) && (argc != 4)) {
    13     gprint (GP_ERR, "USAGE: gcat RA DEC [Radius]\n");
     29    gprint (GP_ERR, "USAGE: gcat RA DEC [Radius] [-host] [-backup] [-flags]\n");
    1430    return (FALSE);
    1531  }
     
    3147
    3248  for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
     49    gprint (GP_ERR, "%3d %s", i, skylist[0].regions[i][0].name);
    3350    if (stat (skylist[0].filename[i], &filestat) != -1) {
    34       gprint (GP_ERR, "%3d %s *\n", i, skylist[0].regions[i][0].name);
     51      gprint (GP_ERR, " *");
    3552    } else {
    36       gprint (GP_ERR, "%3d %s\n", i, skylist[0].regions[i][0].name);
     53      gprint (GP_ERR, "  ");
    3754    }
     55    if (ShowHost) {
     56      gprint (GP_ERR, "  %3d", skylist[0].regions[i][0].hostID);
     57    } else {
     58      gprint (GP_ERR, "     ");
     59    }
     60    if (ShowBackup) {
     61      gprint (GP_ERR, "  %3d", skylist[0].regions[i][0].backupID);
     62    } else {
     63      gprint (GP_ERR, "     ");
     64    }
     65    if (ShowFlags) {
     66      gprint (GP_ERR, "  0x%04x", skylist[0].regions[i][0].hostFlags);
     67    } else {
     68      gprint (GP_ERR, "        ");
     69    }
     70    gprint (GP_ERR, "\n");
    3871    set_str_variable ("CATNAME", skylist[0].filename[i]);
    3972  }
  • trunk/Ohana/src/opihi/dvo/gstar.c

    r31667 r33662  
    6868  }
    6969
     70  int PARALLEL = FALSE;
     71  if ((N = get_argument (argc, argv, "-parallel"))) {
     72    remove_argument (N, &argc, argv);
     73    PARALLEL = TRUE;
     74  }
     75
    7076  if (argc != 4) {
    7177    gprint (GP_ERR, "USAGE: gstar RA DEC Radius [-m]\n");
     
    8995  }
    9096
     97  HostTable *table = NULL; 
     98  if (PARALLEL) {
     99    char *CATDIR = GetCATDIR();
     100    table = HostTableLoad (CATDIR, sky->hosts);
     101    if (!table) {
     102      gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
     103      return FALSE;
     104    }   
     105
     106    SkyRegion *region = skylist[0].regions[0];
     107    int hostID = (region->hostFlags & DATA_USE_BCK) ? region->backupID : region->hostID;
     108    int index = table->index[hostID];
     109   
     110    char hostfile[1024];
     111    snprintf (hostfile, 1024, "%s/%s.cpt", table->hosts[index].pathname, region->name);
     112    catalog.filename = hostfile;
     113  } else {
     114    catalog.filename = skylist[0].filename[0];
     115  }
     116
    91117  /* lock, load, unlock catalog */
    92   catalog.filename = skylist[0].filename[0];
    93118  catalog.catflags = GetMeasures ? LOAD_AVES | LOAD_MEAS | LOAD_SECF : LOAD_AVES | LOAD_SECF;
    94119  catalog.Nsecfilt = 0;
     
    177202            gprint (GP_LOG, "%f ",     catalog.average[k].duD);
    178203            gprint (GP_LOG, "%f ",     catalog.average[k].P);
    179             gprint (GP_LOG, "%f ",     catalog.average[k].dP);
     204            gprint (GP_LOG, "%f   ",     catalog.average[k].dP);
     205
     206            gprint (GP_LOG, "%f   ",     catalog.average[k].ChiSqAve);
     207            gprint (GP_LOG, "%f   ",     catalog.average[k].ChiSqPM);
     208            gprint (GP_LOG, "%f   ",     catalog.average[k].ChiSqPar);
     209
     210            date = ohana_sec_to_date (catalog.average[k].Tmean);
     211            gprint (GP_LOG, "%20s ",     date);
     212            gprint (GP_LOG, "%f   ",     catalog.average[k].Trange / 86400.0);
    180213        }
    181214
     
    197230        for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, 2);
    198231        gprint (GP_LOG, "\n");
    199       }
    200 
     232
     233        if (FULL_OUTPUT) {
     234          /* Map */
     235          for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, 5);
     236          gprint (GP_LOG, "\n");
     237
     238          /* M_20 */
     239          for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, 6);
     240          gprint (GP_LOG, "\n");
     241
     242          /* M_80 */
     243          for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, 7);
     244          gprint (GP_LOG, "\n");
     245
     246          /* secfilt flags */
     247          for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, 4);
     248          gprint (GP_LOG, "\n");
     249
     250        }
     251      }
    201252      if (GetMeasures || SaveVectors) {
    202253        m = catalog.average[k].measureOffset;
     
    218269            gprint (GP_LOG, "%7.4f ",  catalog.measure[m].dR);
    219270            gprint (GP_LOG, "%7.4f ",  catalog.measure[m].dD);
    220             gprint (GP_LOG, "%4x ",    catalog.measure[m].photFlags);
    221             gprint (GP_LOG, "%3x ",    catalog.measure[m].dbFlags);
     271            gprint (GP_LOG, "0x%08x ", catalog.measure[m].photFlags);
     272            gprint (GP_LOG, "0x%08x ", catalog.measure[m].dbFlags);
    222273            gprint (GP_LOG, "%5d ",    catalog.measure[m].photcode);
    223274            gprint (GP_LOG, "%-20s ",  GetPhotcodeNamebyCode (catalog.measure[m].photcode));
     
    226277
    227278            if (FULL_OUTPUT) {
    228                 gprint (GP_LOG, "%f ", catalog.measure[m].Mcal);
    229                 gprint (GP_LOG, "%f ", catalog.measure[m].Map);
    230                 gprint (GP_LOG, "%f ", pow(10.0, 0.4*catalog.measure[m].dt));
    231                 gprint (GP_LOG, "%f ", 1.0 + catalog.measure[m].airmass);
    232                 gprint (GP_LOG, "%f ", catalog.measure[m].az);
    233                 gprint (GP_LOG, "%f ", catalog.measure[m].Xccd);
    234                 gprint (GP_LOG, "%f ", catalog.measure[m].Yccd);
    235                 gprint (GP_LOG, "%f ", FromShortPixels(catalog.measure[m].dXccd));
    236                 gprint (GP_LOG, "%f ", FromShortPixels(catalog.measure[m].dYccd));
    237                 gprint (GP_LOG, "%f ", catalog.measure[m].Sky);
    238                 gprint (GP_LOG, "%f ", catalog.measure[m].dSky);
    239                 gprint (GP_LOG, "%d ", catalog.measure[m].averef);
    240                 gprint (GP_LOG, "%d ", catalog.measure[m].detID);
    241                 gprint (GP_LOG, "%d ", catalog.measure[m].imageID);
    242                 gprint (GP_LOG, "%f ", catalog.measure[m].psfQual);
    243                 gprint (GP_LOG, "%f ", catalog.measure[m].psfChisq);
    244                 gprint (GP_LOG, "%f ", catalog.measure[m].crNsigma);
    245                 gprint (GP_LOG, "%f ", catalog.measure[m].extNsigma);
    246                 gprint (GP_LOG, "%f ", FromShortDegrees(catalog.measure[m].theta));
     279                gprint (GP_LOG, "%6.3f ", catalog.measure[m].Mcal);
     280                gprint (GP_LOG, "%6.3f ", catalog.measure[m].Map);
     281                gprint (GP_LOG, "%5.1f ", pow(10.0, 0.4*catalog.measure[m].dt));
     282                gprint (GP_LOG, "%5.3f ", catalog.measure[m].airmass);
     283                gprint (GP_LOG, "%6.1f ", catalog.measure[m].az);
     284                gprint (GP_LOG, "%6.1f ", catalog.measure[m].Xccd);
     285                gprint (GP_LOG, "%6.1f ", catalog.measure[m].Yccd);
     286                gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[m].dXccd));
     287                gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[m].dYccd));
     288                gprint (GP_LOG, "%6.1f ", catalog.measure[m].Sky);
     289                gprint (GP_LOG, "%5.1f ", catalog.measure[m].dSky);
     290                gprint (GP_LOG, "%8d ", catalog.measure[m].averef);
     291                gprint (GP_LOG, "0x%08x ", catalog.measure[m].detID);
     292                gprint (GP_LOG, "0x%08x ", catalog.measure[m].imageID);
     293                gprint (GP_LOG, "%.3f ", catalog.measure[m].psfQual);
     294                gprint (GP_LOG, "%.1f ", catalog.measure[m].psfChisq);
     295                gprint (GP_LOG, "%.1f ", catalog.measure[m].crNsigma);
     296                gprint (GP_LOG, "%.1f ", catalog.measure[m].extNsigma);
     297                gprint (GP_LOG, "%.1f ", FromShortDegrees(catalog.measure[m].theta));
    247298            }
    248299            gprint (GP_LOG, "\n");
     
    295346void print_double (double value) {
    296347  if (isnan(value))
    297     gprint (GP_LOG, "NaN    ");
     348    gprint (GP_LOG, "  NaN    ");
    298349  else
    299     gprint (GP_LOG, "%6.3f ", value);
     350    gprint (GP_LOG, "  %6.3f ", value);
    300351}
    301352
    302353void print_short (double value, short int ival) {
    303354  if (ival == NAN_S_SHORT)
    304     gprint (GP_LOG, "NaN    ");
     355    gprint (GP_LOG, "  NaN    ");
    305356  else
    306     gprint (GP_LOG, "%6.3f ", value);
     357    gprint (GP_LOG, "  %6.3f ", value);
    307358}
    308359
     
    370421    case 3: /* filter names */
    371422      code = GetPhotcodebyNsec (seq);
    372       gprint (GP_LOG, "%-6s ", code[0].name);
    373       break;
    374   }
    375 }
     423      gprint (GP_LOG, "  %-6s ", code[0].name);
     424      break;
     425
     426    case 4: /* secfilt flags */
     427      if (seq == -1) {
     428        gprint (GP_LOG, "%08x ", 0);
     429      } else {
     430        gprint (GP_LOG, "%08x ", secfilt[seq].flags);
     431      }
     432      break;
     433
     434    case 5: /* average ap mags */
     435      if (seq == -1) {
     436        print_double (NAN);
     437      } else {
     438        print_double (secfilt[seq].Map);
     439      }
     440      break;
     441
     442    case 6: /* average ap mags */
     443      if (seq == -1) {
     444        print_double (NAN);
     445      } else {
     446        print_short (0.001*secfilt[seq].M_20, secfilt[seq].M_20);
     447      }
     448      break;
     449
     450    case 7: /* average ap mags */
     451      if (seq == -1) {
     452        print_double (NAN);
     453      } else {
     454        print_short (0.001*secfilt[seq].M_20, secfilt[seq].M_80);
     455      }
     456      break;
     457
     458  }
     459}
  • trunk/Ohana/src/opihi/dvo/init.c

    r31450 r33662  
    2323int fitsed          PROTO((int, char **));
    2424int gcat            PROTO((int, char **));
     25int catlist         PROTO((int, char **));
    2526int getxtra         PROTO((int, char **));
    2627int gimages         PROTO((int, char **));
    2728int gstar           PROTO((int, char **));
    2829int gtypes          PROTO((int, char **));
     30int hosts           PROTO((int, char **));
    2931int images          PROTO((int, char **));
    3032int imbox           PROTO((int, char **));
     
    4749int paverage        PROTO((int, char **));
    4850int procks          PROTO((int, char **));
     51int remote          PROTO((int, char **));
    4952int showtile        PROTO((int, char **));
    5053int skycat          PROTO((int, char **));
     
    7780  {1, "fitsed",      fitsed,       "fit stellar SEDs to objects"},
    7881  {1, "gcat",        gcat,         "get catalog at location"},
     82  {1, "catlist",     catlist,      "get list of catalogs for region / host"},
    7983  {1, "gimages",     gimages,      "get images at location"},
    8084  {1, "gstar",       gstar,        "get star statistics"},
     85  {1, "hosts",       hosts,        "remote host support functions"},
    8186  {1, "images",      images,       "plot image boxes"},
    8287  {1, "imbox",       imbox,        "plot expected image box"},
     
    99104  {1, "paverage",    paverage,     "plot average magnitude"},
    100105  {1, "procks",      procks,       "plot rocks"},
     106  {1, "remote",      remote,       "generic remote dvo client operation"},
    101107  {1, "showtile",    showtile,     "plot tile pattern"},
    102108  {1, "skycat",      skycat,       "show sky catalog boundaries"},
  • trunk/Ohana/src/opihi/dvo/mextract.c

    r30612 r33662  
    2525  selection = NULL;
    2626
     27  // fprintf (stderr, "start...");
    2728  if ((N = get_argument (argc, argv, "-h"))) goto help;
    2829  if ((N = get_argument (argc, argv, "--help"))) goto help;
     
    3435  }
    3536
     37  int PARALLEL = FALSE;
     38  if ((N = get_argument (argc, argv, "-parallel"))) {
     39    remove_argument (N, &argc, argv);
     40    PARALLEL = TRUE;
     41  }
     42
     43  // this is used to NOT save the results in the results file
     44  // use this option when mextract is used in a script which does its
     45  // own job of packaging the results
     46  int SKIP_RESULTS = FALSE;
     47  if ((N = get_argument (argc, argv, "-skip-results"))) {
     48    remove_argument (N, &argc, argv);
     49    SKIP_RESULTS = TRUE;
     50  }
     51
     52  // init here so free in 'escape' block does not crash
    3653  dvo_catalog_init (&catalog, TRUE);
    3754
     
    4057  Nsecfilt = GetPhotcodeNsecfilt ();
    4158 
     59  // parse skyregion options.  NOTE: this is stripped off in parallel operation and always
     60  // defined for the client via the -skyregion option.  The dvo_client parses this
     61  // argument in the main program, before it is passed to the command (like mextract)
     62  if ((selection = SetRegionSelection (&argc, argv)) == NULL) {
     63    print_error();
     64    goto escape;
     65  }
     66
    4267  // init locally static variables (time refs)
    4368  dbExtractMeasuresInit();
    4469
    45   // parse skyregion options
    46   if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape;
    47 
    48   // command-line is of the form: avextract field,field, field [where (field op value)...]
     70  // command-line is of the form: mextract field,field, field [where (field op value)...]
    4971
    5072  // parse the fields to be extracted and returned
     
    84106  if ((skylist = SelectRegions (selection)) == NULL) goto escape;
    85107
     108  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
     109  if (PARALLEL && !HOST_ID) {
     110    int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
     111
     112    dbFreeFields (fields, Nfields);
     113    dbFreeStack (stack, Nstack);
     114    free (stack);
     115    FreeSkyRegionSelection (selection);
     116    dvo_catalog_free (&catalog);
     117
     118    return status;
     119  }
     120
    86121  // load image data if needed (for fields listed below)
    87122  loadImages = FALSE;
    88123  mosaicMode = FALSE;
    89124  for (i = 0; !loadImages && (i < Nfields); i++) {
    90     if (fields[i].ID == MEAS_XCCD) loadImages = TRUE;   // Are these still needed? Xccd and Yccd are in measurement
    91     if (fields[i].ID == MEAS_YCCD) loadImages = TRUE;   // and dbExtractMeasures doesn't look at the image for these
    92     if (fields[i].ID == MEAS_XMOSAIC) loadImages = mosaicMode = TRUE;
    93     if (fields[i].ID == MEAS_YMOSAIC) loadImages = mosaicMode = TRUE;
     125    if (!MEASURE_HAS_XCCD) {
     126      // I'm keeping this code because it gives a way of handling dvo dbs that don't have
     127      // measure.xccd if we need it
     128      if (fields[i].ID == MEAS_XCCD) loadImages = TRUE;
     129      if (fields[i].ID == MEAS_YCCD) loadImages = TRUE;
     130    }
     131    if (fields[i].ID == MEAS_XMOSAIC)   loadImages = mosaicMode = TRUE;
     132    if (fields[i].ID == MEAS_YMOSAIC)   loadImages = mosaicMode = TRUE;
    94133    if (fields[i].ID == MEAS_EXTERN_ID) loadImages = mosaicMode = TRUE;
     134    if (fields[i].ID == MEAS_FLAT)      loadImages = mosaicMode = TRUE;
    95135  }
    96136  if (loadImages && !SetImageSelection (mosaicMode, selection)) goto escape;
     
    115155  interrupt = FALSE;
    116156
     157  // fprintf (stderr, "done setup...");
     158
    117159  for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
     160
     161    // does this host ID match the desired location for the table?
     162    if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue;
     163
    118164    /* lock, load, unlock catalog */
    119     catalog.filename = skylist[0].filename[i];
     165    char hostfile[1024];
     166    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
     167    catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i];
    120168    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    121169    catalog.Nsecfilt = Nsecfilt;
     
    126174    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
    127175      gprint (GP_ERR, "ERROR: failure to open catalog file %s\n", catalog.filename);
    128       exit (2);
     176      return FALSE;
    129177    }
    130178    dvo_catalog_unlock (&catalog);
     
    132180    /* XXX need to call dvo_catalog_chipcoords here passing the loaded images */
    133181
     182    // fprintf (stderr, "done read...");
     183
    134184    for (j = 0; (j < catalog.Naverage) && !interrupt; j++) {
    135185      m = catalog.average[j].measureOffset;
    136       dbExtractMeasuresInitAve (); // reset counters for saved fields
     186      if (m > catalog.Nmeasure) {
     187        gprint (GP_ERR, "ERROR: inconsistent average->measure offset.  Unsorted database?\n");
     188        goto escape;
     189      }
     190
     191      dbExtractMeasuresInitAve (); // reset counters for saved fields (costs very little
    137192
    138193      for (k = 0; (k < catalog.average[j].Nmeasure); k++, m++) {
     194        if (catalog.measure[m].averef != j) {
     195          gprint (GP_ERR, "ERROR: inconsistent measure->average link.  Unsorted database?\n");
     196          goto escape;
     197        }
    139198
    140199        // extract the relevant values for this measurement
    141         dbExtractMeasuresInitMeas (); // reset counters for saved fields
     200        dbExtractMeasuresInitMeas (); // reset counters for saved fields  (costs very little
    142201        for (n = 0; n < Nfields; n++) {
    143202          values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
     
    173232  interrupt = FALSE;
    174233
     234  // fprintf (stderr, "done load...");
     235
    175236  for (n = 0; n < Nreturn; n++) {
    176     ResetVector (vec[n], fields[n].type, MAX(1,Npts));
     237    ResetVector (vec[n], fields[n].type, Npts);
     238  }
     239
     240  // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)
     241  if (RESULT_FILE && !SKIP_RESULTS) {
     242    int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL);
     243    if (!status) goto escape;
    177244  }
    178245
     
    185252  SkyListFree (skylist);
    186253  FreeSkyRegionSelection (selection);
     254
     255  // fprintf (stderr, "done extr...\n");
    187256  return (TRUE);
    188257
     
    307376    gprint (GP_ERR, "  imageID : ID of source image (32 bit)\n");
    308377    gprint (GP_ERR, "  externID : externID of source image (32 bit)\n");
     378
     379    gprint (GP_ERR, "  Mcal_offset : difference wrt nominal zero point (clouds are positive)\n");
     380    gprint (GP_ERR, "  flat : flat-field correction (measure.Mcal - image.Mcal)\n");
    309381    return (FALSE);
    310382  }
  • trunk/Ohana/src/opihi/dvo/region_list.c

    r31635 r33662  
    113113  /* check for Region selection from display */
    114114  if ((N = get_argument (*argc, argv, "-skyregion"))) {
    115     if (N + 5 >= *argc) {
     115    if (N + 4 >= *argc) {
    116116      gprint (GP_ERR, "USAGE: -skyregion (RA) (RA) (DEC) (DEC)\n");
    117117      FreeSkyRegionSelection (selection);
     
    134134
    135135/* given possible options (by name, by list, by graph region), select SkyRegions */
     136int SetSkyRegions (SkyRegionSelection *selection) {
     137
     138  if (selection->name != NULL) {
     139    gprint (GP_ERR, "name-based selection not yet implemented (in parallel mode)\n");
     140    return FALSE;
     141  }
     142
     143  if (selection->list != NULL) {
     144    gprint (GP_ERR, "list-based selection not yet implemented (in parallel mode)\n");
     145    return FALSE;
     146  }
     147
     148  if (selection->useDisplay) {
     149    double Rmin, Rmax, Dmin, Dmax, Radius;
     150    Graphdata graphsky;
     151
     152    if (!GetGraphdata (&graphsky, NULL, NULL)) {
     153      gprint (GP_ERR, "region display not available\n");
     154      return FALSE;
     155    }
     156    Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
     157    Dmin = graphsky.coords.crval2 - Radius;
     158    Dmax = graphsky.coords.crval2 + Radius;
     159   
     160    if ((Dmin <= -89) || (Dmax >= 89)) {
     161      Rmin = 0;
     162      Rmax = 360;
     163    } else {
     164      double Rmod = MAX (Radius / (cos(Dmin*RAD_DEG)), Radius / (cos(Dmax*RAD_DEG)));
     165      Rmin = graphsky.coords.crval1 - Rmod;
     166      Rmax = graphsky.coords.crval1 + Rmod;
     167    }
     168
     169    set_skyregion (Rmin, Rmax, Dmin, Dmax);
     170    return TRUE;
     171  }
     172  if (selection->useSkyregion) {
     173    return TRUE;
     174  }
     175  return FALSE;
     176}
     177
     178/* given possible options (by name, by list, by graph region), select SkyRegions */
    136179SkyList *SelectRegions (SkyRegionSelection *selection) {
    137180
     
    140183  /* determine region-file names */
    141184  if (selection->name != NULL) {
    142     char filename[256];
    143     char *CATDIR = dvo_get_catdir();
    144 
    145     ALLOCATE (skylist, SkyList, 1);
    146     ALLOCATE (skylist[0].regions, SkyRegion *, 1);
    147     ALLOCATE (skylist[0].regions[0], SkyRegion, 1);
    148     ALLOCATE (skylist[0].filename, char *, 1);
    149     skylist[0].ownElements = TRUE; // free these elements when freeing the list
    150    
    151     strcpy (skylist[0].regions[0][0].name, selection->name);
    152     sprintf (filename, "%s/%s.cpt", CATDIR, selection->name);
    153     skylist[0].filename[0] = strcreate (filename);
     185    skylist = SkyListByName (sky, selection->name);
    154186    return (skylist);
    155187  }
  • trunk/Ohana/src/opihi/dvo/skycoverage.c

    r32632 r33662  
    11# include "dvoshell.h"
    22
     3// enum to define possible modes
     4enum {COVERAGE, DENSITY, MIN_UBERCAL, MIN_DMAG_SYS, MIN_MCAL, MAX_MCAL};
     5
    36int wordhash (char *word);
    47
    58int skycoverage (int argc, char **argv) {
    69
    7   int WITH_MOSAIC, SOLO_MOSAIC, ShowDensity;
     10  int WITH_MOSAIC, SOLO_MOSAIC, mode;
    811  off_t i, Nimage;
    912  int N, status, TimeSelect, ByName, xs, ys;
     
    6063  }
    6164
    62   ShowDensity = FALSE;
     65  mode = COVERAGE;
    6366  if ((N = get_argument (argc, argv, "-density"))) {
    6467    remove_argument (N, &argc, argv);
    65     ShowDensity = TRUE;
     68    mode = DENSITY;
     69  }
     70  if ((N = get_argument (argc, argv, "-min-ubercal"))) {
     71    remove_argument (N, &argc, argv);
     72    mode = MIN_UBERCAL;
     73  }
     74  if ((N = get_argument (argc, argv, "-min-dmag-sys"))) {
     75    remove_argument (N, &argc, argv);
     76    mode = MIN_DMAG_SYS;
     77  }
     78  if ((N = get_argument (argc, argv, "-min-mcal"))) {
     79    remove_argument (N, &argc, argv);
     80    mode = MIN_MCAL;
     81  }
     82  if ((N = get_argument (argc, argv, "-max-mcal"))) {
     83    remove_argument (N, &argc, argv);
     84    mode = MAX_MCAL;
    6685  }
    6786
     
    194213  V = (float *)buf[0].matrix.buffer;
    195214
     215  // init the V array (depends on mode)
    196216  for (ys = 0; ys < Ny; ys++) {
    197217    for (xs = 0; xs < Nx; xs++) {
     
    199219      status &= (r >= 0);
    200220      status &= (r <= 360);
     221      // are we in a part of the projection covering the sky or not?
    201222      if (status) {
    202         V[ys*Nx + xs] = ShowDensity ?  0 : 2;
     223        switch (mode) {
     224          case COVERAGE:
     225            V[ys*Nx + xs] = 2;
     226            break;
     227          case DENSITY:
     228            V[ys*Nx + xs] = 0;
     229            break;
     230          case MIN_UBERCAL:
     231          case MIN_DMAG_SYS:
     232          case MIN_MCAL:
     233            V[ys*Nx + xs] = 1E6;
     234            break;
     235          case MAX_MCAL:
     236            V[ys*Nx + xs] = -1E6;
     237            break;
     238        }
    203239      } else {
    204         V[ys*Nx + xs] = ShowDensity ? NAN : 0;
     240        switch (mode) {
     241          case COVERAGE:
     242            V[ys*Nx + xs] = 0;
     243            break;
     244          case DENSITY:
     245          case MIN_UBERCAL:
     246          case MIN_DMAG_SYS:
     247          case MIN_MCAL:
     248          case MAX_MCAL:
     249            V[ys*Nx + xs] = NAN;
     250            break;
     251        }
    205252      }
    206253    }
     
    257304          xs = (int)Xs;
    258305          ys = (int)Ys;
    259           if (ShowDensity) {
     306          switch (mode) {
     307            case COVERAGE:
     308              V[ys*Nx + xs] = 1;
     309              break;
     310            case DENSITY:
    260311              V[ys*Nx + xs] += 1;
    261           } else {
    262               V[ys*Nx + xs] = 1;
     312              break;
     313            case MIN_UBERCAL:
     314              V[ys*Nx + xs] = MIN(V[ys*Nx + xs], image[i].ubercalDist);
     315              break;
     316            case MIN_DMAG_SYS:
     317              V[ys*Nx + xs] = MIN(V[ys*Nx + xs], image[i].dMagSys);
     318              break;
     319            case MIN_MCAL:
     320              V[ys*Nx + xs] = MIN(V[ys*Nx + xs], image[i].Mcal);
     321              break;
     322            case MAX_MCAL:
     323              V[ys*Nx + xs] = MAX(V[ys*Nx + xs], image[i].Mcal);
     324              break;
    263325          }
    264326        }
  • trunk/Ohana/src/opihi/dvo/skyregion.c

    r31635 r33662  
    11# include "dvoshell.h"
    2 
    3 #ifdef NO_MOVED_TO_DVO
    4 static double RAs = 0.0;
    5 static double RAe = 0.0;
    6 static double DECs = 0.0;
    7 static double DECe = 0.0;
    8 #endif
    92
    103// define the sky region for which extractions are limited
    114int skyregion (int argc, char **argv) {
    125 
     6  int N;
     7
     8  // dvo_client should have 2 standard arguments: -hostID and -hostdir
     9  int SaveRegion = FALSE;
     10  if ((N = get_argument (argc, argv, "-save"))) {
     11    remove_argument (N, &argc, argv);
     12    SaveRegion = TRUE;
     13  }
     14
    1315  if (argc == 1) {
    14     double RAs, RAe, DECs, DECe;
    15     get_skyregion(&RAs, &RAe, &DECs, &DECe);
     16    double Rmin, Rmax, Dmin, Dmax;
     17    get_skyregion(&Rmin, &Rmax, &Dmin, &Dmax);
    1618
    17     gprint (GP_ERR, "current skyregion: %f - %f : %f - %f\n", RAs, RAe, DECs, DECe);
    18     gprint (GP_ERR, "USAGE:  skyregion (min RA) (max RA) (min DEC) (max DEC)\n");
    19     return (FALSE);
     19    if (SaveRegion) {
     20      set_variable ("Rmin", Rmin);
     21      set_variable ("Rmax", Rmax);
     22      set_variable ("Dmin", Dmin);
     23      set_variable ("Dmax", Dmax);
     24      return TRUE;
     25    } else {
     26      gprint (GP_ERR, "current skyregion: %f - %f : %f - %f\n", Rmin, Rmax, Dmin, Dmax);
     27      gprint (GP_ERR, "USAGE:  skyregion (min RA) (max RA) (min DEC) (max DEC)\n");
     28      return FALSE;
     29    }
    2030  }
    2131
     
    2939  return (TRUE);
    3040}
    31 #ifdef NOT_MOVED_TO_LIBDVO
    32 int get_skyregion (double *Rs, double *Re, double *Ds, double *De) {
    33 
    34   *Rs = RAs;
    35   *Re = RAe;
    36   *Ds = DECs;
    37   *De = DECe;
    38 
    39   return TRUE;
    40 }
    41 
    42 int set_skyregion (double Rs, double Re, double Ds, double De) {
    43 
    44   RAs  = Rs;
    45   RAe  = Re;
    46   DECs = Ds;
    47   DECe = De;
    48 
    49   return TRUE;
    50 }
    51 #endif
    5241
    5342/* find region which overlaps c at given depth (-1 : populated ) */
     
    10796  ALLOCATE (new[0].regions,  SkyRegion *, 1);
    10897  ALLOCATE (new[0].filename,  char *, 1);
     98  new[0].Nregions = 0;
     99  new[0].ownElements = FALSE; // this list is only holding a view to the elements
    109100
    110101  // output list
  • trunk/Ohana/src/opihi/include/dvomath.h

    r31635 r33662  
    111111
    112112/* vector handling */
     113void          InitVectors           PROTO((void));
     114void          FreeVectors           PROTO((void));
    113115Vector       *InitVector            PROTO((void));
    114 void          InitVectors           PROTO((void));
     116void          FreeVectorArray       PROTO((Vector **vec, int Nvec));
    115117int           CopyVector            PROTO((Vector *out, Vector *in));
    116118int           ResetVector           PROTO((Vector *vec, char type, int Nelements));
     
    126128int           IsVectorPtr           PROTO((Vector *vec));
    127129int           ListVectors           PROTO((void));
     130int           ListVectorsToList     PROTO((char *name));
    128131Vector       *SelectVector          PROTO((char *name, int mode, int verbose));
     132int           AssignVector          PROTO((Vector *vec, char *name, int mode, int verbose));
     133Vector      **MergeVectors          PROTO((Vector **vec, int *Nvec, Vector **invec, int Ninvec));
     134Vector      **MergeVectorsByIndex   PROTO((Vector **vec, int *Nvec, Vector **invec, int Ninvec, int Nelements));
     135
     136/* vector IO functions */
     137int           WriteVectorTableFITS  PROTO((char *filename, char *extname, Vector **vec, int Nvec, int append, char *format));
     138Vector      **ReadVectorTableFITS   PROTO((char *filename, char *extname, int *Nvec));
    129139
    130140/* buffer handling */
     
    140150int           IsBufferPtr           PROTO((Buffer *buf));
    141151int           PrintBuffers          PROTO((int Long));
     152int           ListBuffersToList     PROTO((char *name));
    142153int           CreateBuffer          PROTO((Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale));
    143154Buffer       *SelectBuffer          PROTO((char *name, int mode, int verbose));
  • trunk/Ohana/src/opihi/include/dvoshell.h

    r31635 r33662  
    66# ifndef DVOSHELL_H
    77# define DVOSHELL_H
    8 
    9 #ifdef NOT_MOVED_TO_LIBDVO
    10 typedef enum {
    11   DB_STACK_NONE  = 0,
    12   DB_STACK_INT   = 0x01,
    13   DB_STACK_FIELD = 0x02,
    14   DB_STACK_TEMP  = 0x04,
    15   DB_STACK_VALUE = 0x08,
    16   DB_STACK_CLOSE_PAR = 0x10,
    17   DB_STACK_OPEN_PAR,
    18   DB_STACK_LOGIC,
    19   DB_STACK_COMPARE,
    20   DB_STACK_BITWISE,
    21   DB_STACK_SUM,
    22   DB_STACK_MULTIPLY,
    23   DB_STACK_POWER,
    24   DB_STACK_UNARY,
    25 } dbStackTypes;
    26 
    27 /* magnitude types */
    28 enum {MAG_NONE,
    29       MAG_INST,
    30       MAG_CAT,
    31       MAG_APER,
    32       MAG_SYS,
    33       MAG_REL,
    34       MAG_CAL,
    35       MAG_AVE,
    36       MAG_REF,
    37       MAG_ERR,
    38       MAG_AVE_ERR,
    39       MAG_PHOT_FLAGS,
    40       MAG_CHISQ,
    41       MAG_NCODE,
    42       MAG_NPHOT,
    43 };
    44 
    45 /* measure fields */
    46 enum {MEAS_ZERO,
    47       MEAS_GLON,
    48       MEAS_GLAT,
    49       MEAS_GLON_AVE,
    50       MEAS_GLAT_AVE,
    51       MEAS_ELON,
    52       MEAS_ELAT,
    53       MEAS_ELON_AVE,
    54       MEAS_ELAT_AVE,
    55       MEAS_RA,
    56       MEAS_DEC,
    57       MEAS_RA_AVE,
    58       MEAS_DEC_AVE,
    59       MEAS_RA_AVE_ERR,
    60       MEAS_DEC_AVE_ERR,
    61       MEAS_U_RA,
    62       MEAS_U_DEC,
    63       MEAS_U_RA_ERR,
    64       MEAS_U_DEC_ERR,
    65       MEAS_PAR,
    66       MEAS_PAR_ERR,
    67       MEAS_RA_OFFSET,
    68       MEAS_DEC_OFFSET,
    69       MEAS_RA_FIT_OFFSET,
    70       MEAS_DEC_FIT_OFFSET,
    71       MEAS_RA_OFFSET_ERR,
    72       MEAS_DEC_OFFSET_ERR,
    73       MEAS_CHISQ_POS,
    74       MEAS_CHISQ_PM, 
    75       MEAS_CHISQ_PAR,
    76       MEAS_TMEAN,
    77       MEAS_TRANGE,
    78       MEAS_NMEAS,
    79       MEAS_NMISS,
    80       MEAS_NPOS,
    81       MEAS_OBJ_FLAGS,
    82       MEAS_MAG,
    83       MEAS_MINST,
    84       MEAS_MCAT,
    85       MEAS_MSYS,
    86       MEAS_MREL,
    87       MEAS_MCAL,
    88       MEAS_EXPTIME,
    89       MEAS_AIRMASS,
    90       MEAS_ALT,
    91       MEAS_AZ,
    92       MEAS_PHOTCODE,
    93       MEAS_PHOTCODE_EQUIV,
    94       MEAS_TIME,
    95       MEAS_FWHM,
    96       MEAS_FWHM_MAJ,
    97       MEAS_FWHM_MIN,
    98       MEAS_THETA,
    99       MEAS_POSANGLE,
    100       MEAS_PLATESCALE,
    101       MEAS_MXX,
    102       MEAS_MXY,
    103       MEAS_MYY,
    104       MEAS_DOPHOT,
    105       MEAS_DB_FLAGS,
    106       MEAS_PHOT_FLAGS,
    107       MEAS_XCCD,
    108       MEAS_YCCD,
    109       MEAS_XCCD_ERR,
    110       MEAS_YCCD_ERR,
    111       MEAS_POS_SYS_ERR,
    112       MEAS_XMOSAIC,
    113       MEAS_YMOSAIC,
    114       MEAS_SKY,
    115       MEAS_dSKY,
    116       MEAS_DET_ID,
    117       MEAS_OBJ_ID,
    118       MEAS_CAT_ID,
    119       MEAS_IMAGE_ID,
    120       MEAS_PSF_QF,
    121       MEAS_PSF_QF_PERFECT,
    122       MEAS_PSF_CHISQ,
    123       MEAS_PSF_NDOF,
    124       MEAS_PSF_NPIX,
    125       MEAS_CR_NSIGMA,
    126       MEAS_EXT_NSIGMA,
    127       MEAS_EXTERN_ID,
    128 };
    129 
    130 /* average fields */
    131 enum {AVE_ZERO,
    132       AVE_RA,
    133       AVE_DEC,
    134       AVE_RA_ERR,
    135       AVE_DEC_ERR,
    136       AVE_GLON,
    137       AVE_GLAT,
    138       AVE_ELON,
    139       AVE_ELAT,
    140       AVE_U_RA,
    141       AVE_U_DEC,
    142       AVE_U_RA_ERR,
    143       AVE_U_DEC_ERR,
    144       AVE_PAR,
    145       AVE_PAR_ERR,
    146       AVE_CHISQ_POS,
    147       AVE_CHISQ_PM,
    148       AVE_CHISQ_PAR,
    149       AVE_TMEAN,
    150       AVE_TRANGE,
    151       AVE_Xp,
    152       AVE_NMEAS,
    153       AVE_NMISS,
    154       AVE_NPOS,
    155       AVE_NPHOT,
    156       AVE_NCODE,
    157       AVE_MAG,
    158       AVE_dMAG,
    159       AVE_Xm,
    160       AVE_OBJ_FLAGS,
    161       AVE_TYPE,
    162       AVE_TYPEFRAC,
    163       AVE_OBJID,
    164       AVE_CATID,
    165       AVE_EXTID_HI,
    166       AVE_EXTID_LO,
    167 };
    168 
    169 enum {IMAGE_ZERO,
    170       IMAGE_RA,
    171       IMAGE_DEC,
    172       IMAGE_GLON,
    173       IMAGE_GLAT,
    174       IMAGE_ELON,
    175       IMAGE_ELAT,
    176       IMAGE_XM,
    177       IMAGE_AIRMASS,
    178       IMAGE_MCAL,
    179       IMAGE_dMCAL,
    180       IMAGE_PHOTCODE,
    181       IMAGE_TIME,
    182       IMAGE_FWHM,
    183       IMAGE_FWHM_MEDIAN,
    184       IMAGE_EXPTIME,
    185       IMAGE_NSTAR,
    186       IMAGE_NCAL,
    187       IMAGE_SKY,
    188       IMAGE_FLAGS,
    189       IMAGE_CCDNUM,
    190       IMAGE_NX_PIX,
    191       IMAGE_NY_PIX,
    192       IMAGE_THETA,
    193       IMAGE_SKEW,
    194       IMAGE_SCALE,
    195       IMAGE_DSCALE,
    196       IMAGE_APRESID,
    197       IMAGE_DAPRESID,
    198       IMAGE_SIDTIME,
    199       IMAGE_LATITUDE,
    200       IMAGE_DET_LIMIT,
    201       IMAGE_SAT_LIMIT,
    202       IMAGE_CERROR,
    203       IMAGE_FWHM_MAJ,
    204       IMAGE_FWHM_MIN,
    205       IMAGE_FWHM_MAJ_MEDIAN,
    206       IMAGE_FWHM_MIN_MEDIAN,
    207       IMAGE_TRATE,
    208       IMAGE_IMAGE_ID,
    209       IMAGE_EXTERN_ID,
    210       IMAGE_SOURCE_ID,
    211       IMAGE_X_LL_CHIP,
    212       IMAGE_X_LR_CHIP,
    213       IMAGE_X_UL_CHIP,
    214       IMAGE_X_UR_CHIP,
    215       IMAGE_Y_LL_CHIP,
    216       IMAGE_Y_LR_CHIP,
    217       IMAGE_Y_UL_CHIP,
    218       IMAGE_Y_UR_CHIP,
    219       IMAGE_X_LL_FP,
    220       IMAGE_X_LR_FP,
    221       IMAGE_X_UL_FP,
    222       IMAGE_X_UR_FP,
    223       IMAGE_Y_LL_FP,
    224       IMAGE_Y_LR_FP,
    225       IMAGE_Y_UL_FP,
    226       IMAGE_Y_UR_FP,
    227       IMAGE_X_ERR_SYS,
    228       IMAGE_Y_ERR_SYS,
    229       IMAGE_MAG_ERR_SYS,
    230       IMAGE_NFIT_PHOTOM,
    231       IMAGE_NFIT_ASTROM,
    232       IMAGE_NLINK_PHOTOM,
    233       IMAGE_NLINK_ASTROM
    234 };
    235 
    236 enum {DVO_TABLE_AVERAGE, DVO_TABLE_MEASURE, DVO_TABLE_IMAGE};
    237 enum {DVO_DB_CMDLINE_ERROR, DVO_DB_CMDLINE_IS_END, DVO_DB_CMDLINE_IS_WHERE, DVO_DB_CMDLINE_IS_MATCH};
    238 
    239 // options for selecting the ra,dec limits of the db selections
    240 typedef struct {
    241   char *name;
    242   char *list;
    243   int useDisplay;
    244   int useSkyregion;
    245 } SkyRegionSelection;
    246 
    247 // a single db field
    248 typedef struct {
    249   char *name;
    250   int extract;
    251   int table;
    252   int ID;
    253   int magMode;
    254   char type;
    255   PhotCode *photcode;
    256 } dbField;
    257 
    258 // db boolean operations
    259 typedef struct {
    260   char   *name;
    261   char    type;
    262   int     field;
    263   opihi_flt FltValue;
    264   opihi_int IntValue;
    265 } dbStack;
    266 
    267 typedef struct {
    268   opihi_flt Flt;
    269   opihi_int Int;
    270 } dbValue;
    271 
    272 #endif // notdef MOVED_TO_LIBDVO
    2738
    2749typedef struct {
     
    29126  e_time t;
    29227} CMPstars;
     28
     29/** some globals used particularly by DVO_CLIENT **/
     30int   HOST_ID;
     31char *HOSTDIR;
     32char *RESULT_FILE;
    29333
    29434/*** dvo prototypes ***/
     
    31656void          FreeDVO               PROTO((void));
    31757int           InitPhotcodes         PROTO((void));
    318 #ifdef NOT_MOVED_TO_DVO
    319 Image        *LoadImages            PROTO((off_t *Nimage));
    320 void          FreeImages            PROTO((Image *images));
    321 Image        *MatchImage            PROTO((unsigned int time, short int source, unsigned int imageID));
    322 #endif
    32358Coords       *MatchMosaic           PROTO((unsigned int time, short int source));
    32459int           Quality               PROTO((Measure *measure, int IsDophot));
    32560int           SelectMags            PROTO((int Nphot, int Tphot, int Ns, Average *average, Measure *measure, SecFilt *secfilt, int UL));
    32661
     62int           SetSkyRegions         PROTO((SkyRegionSelection *selection));
    32763SkyList      *SelectRegions         PROTO((SkyRegionSelection *selection));
    32864SkyList      *SkyListLoadFile       PROTO((char *filename));
     
    35288CMPstars     *cmpReadText           PROTO((FILE *f, off_t *nstars));
    35389int           RD_to_XYpic           PROTO((double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside));
    354 int wordhash (char *word);
    355 
    356 #ifdef NOT_MOVED_TO_LIBDVO
    357 // dvo DB field functions
    358 dbField     *dbCmdlineFields        PROTO((int argc, char **argv, int table, int *last, int *nfields));
    359 int          dbCmdlineConditions    PROTO((int argc, char **argv, int first, int *nextField));
    360 dbStack     *dbRPN                  PROTO((int argc, char **argv, int *nstack));
    361 int          dbCheckStack           PROTO((dbStack *stack, int Nstack, int table, dbField **inFields, int *Nfields));
    362 int          dbBooleanCond          PROTO((dbStack *inStack, int NinStack, dbValue *fields));
    363 void         dbInitStack            PROTO((dbStack *stack));
    364 void         dbFreeStack            PROTO((dbStack *stack, int Nstack));
    365 void         dbFreeEntry            PROTO((dbStack *stack));
    366 void         dbFreeTempEntry        PROTO((dbStack *stack));
    367 
    368 dbStack     *dbBinary               PROTO((dbStack *V1, dbStack *V2, char *op, dbValue *fields));
    369 dbStack     *dbUnary                PROTO((dbStack *V1, char *op, dbValue *fields));
    370 #endif
     90int           wordhash              PROTO((char *word));
    37191
    37292int          GetMagMode             PROTO((char *string));
     
    37898dbValue      dbExtractMeasures      PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));
    37999dbValue      dbExtractImages        PROTO((Image *image, off_t Nimage, off_t N, dbField *field));
    380 #ifdef NOT_MOVED_TO_LIBDVO
    381 dbValue      dbExtractAverages      PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));
    382100
    383 void         dbInitField            PROTO((dbField *field));
    384 void         dbFreeFields           PROTO((dbField *fields, int Nfields));
    385 int          dbAstroRegionLimits    PROTO((dbStack **stack, int *nstack, SkyRegionSelection *selection, int table));
    386 int get_skyregion (double *Rs, double *Re, double *Ds, double *De);
    387 int set_skyregion (double Rs, double Re, double Ds, double De);
    388 void FreeImageSelection (void);
    389 char        *strfloat               PROTO((float value));
    390 
    391 
    392 void FreeSkyRegionSelection (SkyRegionSelection *selection);
    393 
    394 
    395 int dbExtractMeasuresInitTransform (CoordTransformSystem target);
    396 int dbExtractMeasuresInitAve (void);
    397 int dbExtractMeasuresInitMeas (void);
    398 int dbExtractMeasuresInit (void);
    399 
    400 int dbExtractAveragesInitTransform (CoordTransformSystem target);
    401 int dbExtractAveragesInit (void);
    402 
    403 int dbExtractImagesInitTransform (CoordTransformSystem target);
    404 int dbExtractImagesInit (void);
    405 int dbExtractImagesReset (void);
    406 #endif // NOT_MOVED_TO_LIBDVO
    407 
     101int          HostTableLaunchJobs    PROTO((HostTable *table, char *basecmd, char *options));
     102int          HostTableParallelOps   PROTO((int argc, char **argv, char *ResultFile, int Nelements, int VERBOSE));
    408103# endif
  • trunk/Ohana/src/opihi/include/pcontrol.h

    r32632 r33662  
    252252int CheckDoneJob (Job *job, Host *host);
    253253int GetJobOutput (char *command, Host *host, JobOutput *output);
    254 int rconnect (char *command, char *hostname, char *shell, int *stdio);
    255254
    256255int PclientCommand (Host *host, char *command, char *response, HostResp response_state);
  • trunk/Ohana/src/opihi/include/shell.h

    r32632 r33662  
    148148char         *opihi_append              PROTO((char *output, int *Noutput, char *start, char *stop));
    149149void          interpolate_slash         PROTO((char *line));
     150char         *paste_args                PROTO((int argc, char **argv));
    150151
    151152/* macro functions (mapped to commands) */
  • trunk/Ohana/src/opihi/lib.shell/BufferOps.c

    r27435 r33662  
    256256  return (TRUE);
    257257}
     258
     259int ListBuffersToList (char *name) {
     260
     261  int i;
     262  char line[1024];
     263
     264  for (i = 0; i < Nbuffers; i++) {
     265    sprintf (line, "%s:%d", name, i);
     266    set_str_variable (line, buffers[i][0].name);
     267  }
     268  sprintf (line, "%s:n", name);
     269  set_int_variable (line, Nbuffers);
     270  return (Nbuffers);
     271}
  • trunk/Ohana/src/opihi/lib.shell/ListOps.c

    r27587 r33662  
    193193      if (!strcmp (temp, "-add")) goto escape;
    194194      if (!strcmp (temp, "-del")) goto escape;
     195      if (!strcmp (temp, "-vectors")) goto escape;
     196      if (!strcmp (temp, "-buffers")) goto escape;
    195197  }
    196198
  • trunk/Ohana/src/opihi/lib.shell/Makefile

    r31635 r33662  
    2424$(SDIR)/VariableOps.$(ARCH).o           \
    2525$(SDIR)/VectorOps.$(ARCH).o             \
     26$(SDIR)/VectorIO.$(ARCH).o             \
    2627$(SDIR)/check_stack.$(ARCH).o           \
    2728$(SDIR)/command.$(ARCH).o               \
  • trunk/Ohana/src/opihi/lib.shell/VectorOps.c

    r31160 r33662  
    1515
    1616// this function is NOT thread protected : it is only used in startup and/or shutdown
     17void FreeVectorArray (Vector **vec, int Nvec) {
     18
     19  int i;
     20
     21  if (!vec) return;
     22  for (i = 0; i < Nvec; i++) {
     23    if (!vec[i]) continue;
     24    if (vec[i]->elements.Int) {
     25      free (vec[i]->elements.Int);
     26    }
     27    free (vec[i]);
     28  }
     29  free (vec);
     30}
     31
     32// this function is NOT thread protected : it is only used in startup and/or shutdown
    1733void FreeVectors () {
    18 
    19   int i;
    20 
    21   for (i = 0; i < Nvectors; i++) {
    22     if (vectors[i][0].elements.Int) {
    23       free (vectors[i][0].elements.Int);
    24     }
    25     free (vectors[i]);
    26   }
    27   free (vectors);
     34  FreeVectorArray (vectors, Nvectors);
    2835}
    2936
     
    93100}
    94101 
     102// Assign the given Vector to the internal array of vectors by name
     103int AssignVector (Vector *vec, char *name, int mode, int verbose) {
     104
     105  int i;
     106
     107  if (name == NULL) goto error;
     108  if (ISNUM(name[0])) goto error;
     109  if (IsBuffer(name)) goto error;
     110
     111  for (i = 0; (i < Nvectors) && (strcmp(vectors[i][0].name, name)); i++);
     112  /* is a new vector */
     113  if (i == Nvectors) {
     114    if (mode == OLDVECTOR) goto error;
     115    pthread_mutex_lock (&mutex);
     116    Nvectors ++;
     117    REALLOCATE (vectors, Vector *, Nvectors);
     118    vectors[i] = vec;
     119    pthread_mutex_unlock (&mutex);
     120    return TRUE;
     121  }
     122  /* is an old vector */
     123  if (mode == NEWVECTOR) goto error;
     124  if (vectors[i]) {
     125    if (vectors[i][0].elements.Ptr) free (vectors[i][0].elements.Ptr);
     126    free (vectors[i]);
     127  }
     128  vectors[i] = vec;
     129  return TRUE;
     130
     131 error:
     132  if (verbose) gprint (GP_ERR, "invalid vector %s\n", name);
     133  return FALSE;
     134}
     135 
    95136/* delete by pointer */
    96137int DeleteVector (Vector *vec) {
     
    148189  if (in[0].elements.Ptr) {
    149190    if (in[0].type == OPIHI_FLT) {
    150       ALLOCATE (out[0].elements.Flt, opihi_flt, out[0].Nelements);
     191      ALLOCATE (out[0].elements.Flt, opihi_flt, MAX(1,out[0].Nelements));
    151192      memcpy (out[0].elements.Flt, in[0].elements.Flt, out[0].Nelements*sizeof(opihi_flt));
    152193      out[0].type = OPIHI_FLT;
    153194    } else {
    154       ALLOCATE (out[0].elements.Int, opihi_int, out[0].Nelements);
     195      ALLOCATE (out[0].elements.Int, opihi_int, MAX(1,out[0].Nelements));
    155196      memcpy (out[0].elements.Int, in[0].elements.Int, out[0].Nelements*sizeof(opihi_int));
    156197      out[0].type = OPIHI_INT;
     
    164205  out[0].Nelements = in[0].Nelements;
    165206  if (type == OPIHI_FLT) {
    166     ALLOCATE (out[0].elements.Flt, opihi_flt, out[0].Nelements);
     207    ALLOCATE (out[0].elements.Flt, opihi_flt, MAX(1,out[0].Nelements));
    167208    out[0].type = OPIHI_FLT;
    168209  } else {
    169     ALLOCATE (out[0].elements.Int, opihi_int, out[0].Nelements);
     210    ALLOCATE (out[0].elements.Int, opihi_int, MAX(1,out[0].Nelements));
    170211    out[0].type = OPIHI_INT;
    171212  }
     
    173214}
    174215
    175 // ResetVector (vecx, OPIHI_FLT, MAX (Npts, 1));
    176216int ResetVector (Vector *vec, char type, int Nelements) {
    177217
    178   vec[0].Nelements = Nelements;
     218  // a vector can only have >= 0 elements
     219  vec[0].Nelements = MAX(Nelements,0);
    179220  if (type == OPIHI_FLT) {
    180221    REALLOCATE (vec[0].elements.Flt, opihi_flt, MAX(1, Nelements));
     
    190231int SetVector (Vector *vec, char type, int Nelements) {
    191232
    192   vec[0].Nelements = Nelements;
     233  vec[0].Nelements = MAX(Nelements,0);
    193234  if (type == OPIHI_FLT) {
    194     ALLOCATE (vec[0].elements.Flt, opihi_flt, Nelements);
     235    ALLOCATE (vec[0].elements.Flt, opihi_flt, MAX(1,Nelements));
    195236    vec[0].type = OPIHI_FLT;
    196237  } else {
    197     ALLOCATE (vec[0].elements.Int, opihi_int, Nelements);
     238    ALLOCATE (vec[0].elements.Int, opihi_int, MAX(1,Nelements));
    198239    vec[0].type = OPIHI_INT;
    199240  }
     
    287328  return (TRUE);
    288329}
     330
     331int ListVectorsToList (char *name) {
     332
     333  int i;
     334  char line[1024];
     335
     336  for (i = 0; i < Nvectors; i++) {
     337    sprintf (line, "%s:%d", name, i);
     338    set_str_variable (line, vectors[i][0].name);
     339  }
     340  sprintf (line, "%s:n", name);
     341  set_int_variable (line, Nvectors);
     342  return (Nvectors);
     343}
     344
     345// Take two arrays of vectors and merge equal named vectors.
     346// Output is a single array in (vec), with vectors lengths of len(vec) + len(invec)
     347// For ease, require that the order of the names match & number of vectors match
     348Vector **MergeVectors (Vector **vec, int *Nvec, Vector **invec, int Ninvec) {
     349
     350  int i, j;
     351
     352  if (vec == NULL) {
     353    *Nvec = Ninvec;
     354    return invec;
     355  }
     356
     357  myAssert (*Nvec == Ninvec, "programming error (1) %d vs %d", *Nvec, Ninvec);
     358
     359  for (i = 0; i < Ninvec; i++) {
     360    myAssert (!strcmp(vec[i]->name, invec[i]->name), "programming error (2) %s vs %s", vec[i]->name, invec[i]->name);
     361    myAssert (vec[i]->type == invec[i]->type, "programming error (3), %d vs %d", vec[i]->type, invec[i]->type);
     362
     363    int N = vec[i]->Nelements;
     364    if (vec[i]->type == OPIHI_FLT) {
     365      REALLOCATE (vec[i]->elements.Flt, opihi_flt, vec[i]->Nelements + invec[i]->Nelements);
     366      for (j = 0; j < invec[i]->Nelements; j++) {
     367        vec[i]->elements.Flt[N+j] = invec[i]->elements.Flt[j];
     368      }
     369    } else {
     370      REALLOCATE (vec[i]->elements.Int, opihi_int, vec[i]->Nelements + invec[i]->Nelements);
     371      for (j = 0; j < invec[i]->Nelements; j++) {
     372        vec[i]->elements.Int[N+j] = invec[i]->elements.Int[j];
     373      }
     374    }
     375    vec[i]->Nelements += invec[i]->Nelements;
     376  }
     377  return vec;
     378}
     379
     380// Take two arrays of vectors and merge equal named vectors, where the last vector
     381// specifies the element in the output vector.  All input vectors must have a max sequence
     382// value of Nelements.  Output is a single array in (vec), with vector lengths of
     383// Nelements for ease, require that the order of the names match & number of vectors match
     384Vector **MergeVectorsByIndex (Vector **vec, int *Nvec, Vector **invec, int Ninvec, int Nelements) {
     385
     386  int i, j;
     387
     388  // on first call, allocate a new vector, excluding the index
     389  int newArray = FALSE;
     390  if (vec == NULL) {
     391    ALLOCATE (vec, Vector *, Ninvec - 1);
     392    *Nvec = Ninvec - 1;
     393    newArray = TRUE;
     394  }
     395
     396  myAssert (*Nvec == Ninvec - 1, "programming error (1)");
     397
     398  // find the index vector
     399  int idx = Ninvec - 1;
     400  myAssert (!strcmp(invec[idx]->name, "index"), "failed to find index vector");
    289401 
     402  for (i = 0; i < Ninvec - 1; i++) {
     403    // on first call, create the output vector
     404    if (newArray) {
     405      vec[i] = InitVector();
     406      strcpy (vec[i]->name, invec[i]->name);
     407      ResetVector (vec[i], invec[i]->type, Nelements);
     408      for (j = 0; j < Nelements; j++) {
     409        if (vec[i][0].type == OPIHI_FLT) {
     410          vec[i][0].elements.Flt[j] = NAN;
     411        } else {
     412          vec[i][0].elements.Int[j] = 0; // or NAN_INT?
     413        }
     414      }
     415    }
     416
     417    myAssert (!strcmp(vec[i]->name, invec[i]->name), "programming error (2)");
     418    myAssert (vec[i]->type == invec[i]->type, "programming error (2)");
     419
     420    // copy vector elements from input to output, matching location
     421    if (vec[i]->type == OPIHI_FLT) {
     422      for (j = 0; j < invec[i]->Nelements; j++) {
     423        int seq = invec[idx]->elements.Int[j];
     424        vec[i]->elements.Flt[seq] = invec[i]->elements.Flt[j];
     425      }
     426    } else {
     427      for (j = 0; j < invec[i]->Nelements; j++) {
     428        int seq = invec[idx]->elements.Int[j];
     429        vec[i]->elements.Int[seq] = invec[i]->elements.Int[j];
     430      }
     431    }
     432  }
     433  return vec;
     434}
     435
  • trunk/Ohana/src/opihi/lib.shell/parse.c

    r30614 r33662  
    101101    V1 ++;
    102102    while (isspace (*V1)) V1++;
    103     if (*V1 == 0) goto error;
     103    if (*V1 == 0) {
     104      // assign empty vector
     105      set_str_variable (V0, "");
     106      goto escape;
     107    }
    104108
    105109    /* command replacement.  execute the line, place answer in val. */
  • trunk/Ohana/src/opihi/lib.shell/string.c

    r31667 r33662  
    301301  *out = *in;
    302302}
     303
     304// paste together argv[0] .. argv[N] into a single string
     305char *paste_args (int argc, char **argv) {
     306
     307  int i;
     308
     309  int length = 0;
     310  for (i = 0; i < argc; i++) {
     311    length += strlen(argv[i]) + 1;
     312  }
     313 
     314  char *string = NULL;
     315  ALLOCATE (string, char, length);
     316  string[0] = 0;
     317  for (i = 0; i < argc; i++) {
     318    strcat (string, argv[i]);
     319    if (i < argc - 1) strcat (string, " ");
     320  }
     321  return string;
     322}
     323
  • trunk/Ohana/src/opihi/mana/findpeaks.c

    r20936 r33662  
    7676  }
    7777
    78   ResetVector (vecx, OPIHI_FLT, MAX (Npeak, 1));
    79   ResetVector (vecy, OPIHI_FLT, MAX (Npeak, 1));
    80   ResetVector (vecz, OPIHI_FLT, MAX (Npeak, 1));
     78  ResetVector (vecx, OPIHI_FLT, Npeak);
     79  ResetVector (vecy, OPIHI_FLT, Npeak);
     80  ResetVector (vecz, OPIHI_FLT, Npeak);
    8181
    8282  /* eliminate non-local peaks */
  • trunk/Ohana/src/opihi/mana/starcontour.c

    r20936 r33662  
    2222  N = 0;
    2323  Npts = 100;
    24   ResetVector (vecx, OPIHI_FLT, MAX (Npts, 1));
    25   ResetVector (vecy, OPIHI_FLT, MAX (Npts, 1));
     24  ResetVector (vecx, OPIHI_FLT, Npts);
     25  ResetVector (vecy, OPIHI_FLT, Npts);
    2626
    2727  Nx = buf[0].matrix.Naxis[0];
  • trunk/Ohana/src/opihi/pcontrol/Makefile

    r26411 r33662  
    2424$(SRC)/init.$(ARCH).o \
    2525$(SRC)/pcontrol.$(ARCH).o \
    26 $(SRC)/rconnect.$(ARCH).o \
    2726$(SRC)/CheckBusyJob.$(ARCH).o \
    2827$(SRC)/CheckDoneHost.$(ARCH).o \
  • trunk/Ohana/src/opihi/pcontrol/StartHost.c

    r28241 r33662  
    1414  if (VarConfig ("SHELL", "%s", shell)     == NULL) strcpy (shell, "pclient");
    1515
    16   if (VerboseMode()) gprint (GP_ERR, "starting host within thread\n");
     16  if (VerboseMode()) gprint (GP_ERR, "starting remote connection to %s...", host[0].hostname);
    1717
    18   pid = rconnect (command, host[0].hostname, shell, stdio);
     18  int errorInfo;
     19  pid = rconnect (command, host[0].hostname, shell, stdio, &errorInfo, TRUE);
    1920  if (!pid) {     
    2021    /** failure to start: extend retry period **/
    21     if (VerboseMode()) gprint (GP_ERR, "failure to start %s\n", host[0].hostname);
     22    if (VerboseMode()) gprint (GP_ERR, "failure to start %s (error %d)\n", host[0].hostname, errorInfo);
    2223    gettimeofday (&now, (void *) NULL);
    2324    if (ZTIME(host[0].next_start_try) || ZTIME(host[0].last_start_try)) {
Note: See TracChangeset for help on using the changeset viewer.