IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 17, 2014, 12:32:26 PM (12 years ago)
Author:
eugene
Message:

merge changes (from past YEAR) into trunk

Location:
branches/eam_branches/ipp-ops-20130712/Ohana
Files:
11 edited
11 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-ops-20130712/Ohana

    • Property svn:mergeinfo deleted
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi

    • Property svn:mergeinfo deleted
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data

    • Property svn:mergeinfo deleted
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/Makefile

    r35416 r37067  
    2525$(SRC)/book.$(ARCH).o           \
    2626$(SRC)/book_commands.$(ARCH).o  \
     27$(SRC)/cast.$(ARCH).o           \
    2728$(SRC)/center.$(ARCH).o \
    2829$(SRC)/clear.$(ARCH).o          \
     
    6364$(SRC)/imcut.$(ARCH).o          \
    6465$(SRC)/imhist.$(ARCH).o \
     66$(SRC)/impeaks.$(ARCH).o        \
    6567$(SRC)/imsmooth.$(ARCH).o       \
     68$(SRC)/imsmooth.generic.$(ARCH).o       \
     69$(SRC)/imsmooth.2d.$(ARCH).o    \
    6670$(SRC)/integrate.$(ARCH).o      \
    6771$(SRC)/interpolate.$(ARCH).o    \
     72$(SRC)/join.$(ARCH).o           \
    6873$(SRC)/jpeg.$(ARCH).o           \
    6974$(SRC)/kern.$(ARCH).o           \
     
    8489$(SRC)/mget.$(ARCH).o           \
    8590$(SRC)/minterpolate.$(ARCH).o   \
     91$(SRC)/medimage.$(ARCH).o       \
     92$(SRC)/medimage_commands.$(ARCH).o \
    8693$(SRC)/mset.$(ARCH).o           \
    8794$(SRC)/peak.$(ARCH).o           \
     
    9198$(SRC)/point.$(ARCH).o          \
    9299$(SRC)/ps.$(ARCH).o             \
     100$(SRC)/print_vectors.$(ARCH).o  \
    93101$(SRC)/queuedelete.$(ARCH).o    \
    94102$(SRC)/queuedrop.$(ARCH).o      \
     
    143151$(SRC)/vmaxwell.$(ARCH).o          \
    144152$(SRC)/vgrid.$(ARCH).o             \
     153$(SRC)/vlist.$(ARCH).o             \
    145154$(SRC)/vload.$(ARCH).o             \
    146155$(SRC)/vzload.$(ARCH).o            \
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/densify.c

    r34088 r37067  
    22
    33# define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); }
     4enum {IS_DOT, IS_SQUARE, IS_CIRCLE, IS_GAUSS};
    45
    56int densify (int argc, char **argv) {
    67
    7   int i, Nx, Ny, Xb, Yb, N, Xpix, Ypix, good, UseGraph;
     8  int i, Nx, Ny, Xb, Yb, ix, iy, N, Xpix, Ypix, good, UseGraph;
    89  double Xmin, Xmax, dX, Ymin, Ymax, dY;
    910  float *val;
     
    2425  }
    2526
     27  float scale = 0.0;
     28  if ((N = get_argument (argc, argv, "-scale"))) {
     29    remove_argument (N, &argc, argv);
     30    scale = atof(argv[N]);
     31    remove_argument (N, &argc, argv);
     32  }
     33
     34  int PSFTYPE = IS_DOT;
     35  if ((N = get_argument (argc, argv, "-psf"))) {
     36    remove_argument (N, &argc, argv);
     37    if (!strcasecmp(argv[N], "dot"))    PSFTYPE = IS_DOT;
     38    if (!strcasecmp(argv[N], "square")) PSFTYPE = IS_SQUARE;
     39    if (!strcasecmp(argv[N], "circle")) PSFTYPE = IS_CIRCLE;
     40    if (!strcasecmp(argv[N], "gauss"))  PSFTYPE = IS_GAUSS;
     41    remove_argument (N, &argc, argv);
     42  }
     43
    2644  good = UseGraph ? (argc == 4) : (argc == 10);
    2745  if (!good) {
    2846    gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n");
    2947    gprint (GP_ERR, "   OR: densify buffer x y -graph\n");
     48    gprint (GP_ERR, " option: -psf [dot] (circle) (square) (gauss)\n");
    3049    return (FALSE);
    3150  }
     
    6988  CHECKVAL(dY);
    7089
     90  float scaleX = (scale > 0.0) ? scale / dX : 3.0;
     91  float scaleY = (scale > 0.0) ? scale / dY : 3.0;
     92
    7193  Nx = (Xmax - Xmin) / dX + 1;
    7294  Ny = (Ymax - Ymin) / dY + 1;
     
    7698  CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0);
    7799  strcpy (bf[0].file, "(empty)");
     100 
     101  float scale2 = (scaleX + 1.0) * (scaleY + 1.0);
     102  float fSquare = 1.0 / scale2;
     103  float fCircle = 1.0 / (3.141592 * scale2);
     104  float fSigma  = 0.5 / scale2;
     105  float fGauss  = 1.0 / (2.0 * 3.141592 * scale2);
    78106
    79107  x = vx[0].elements.Flt;
     
    83111    Xb = (*x - Xmin) / dX;
    84112    Yb = (*y - Ymin) / dY;
    85     if (Xb >= Nx) continue;
    86     if (Yb >= Ny) continue;
    87     if (Xb < 0) continue;
    88     if (Yb < 0) continue;
    89     val[Xb + Yb*Nx] ++;
     113    switch (PSFTYPE) {
     114      case IS_DOT:
     115        if (Xb >= Nx) continue;
     116        if (Yb >= Ny) continue;
     117        if (Xb < 0) continue;
     118        if (Yb < 0) continue;
     119        val[Xb + Yb*Nx] ++;
     120        break;
     121      case IS_SQUARE:
     122        for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
     123          for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
     124            if (ix >= Nx) continue;
     125            if (iy >= Ny) continue;
     126            if (ix < 0) continue;
     127            if (iy < 0) continue;
     128            val[ix + iy*Nx] += fSquare;
     129          }
     130        }
     131        break;
     132      case IS_CIRCLE:
     133        for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
     134          float dX = ix - Xb;
     135          for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
     136            float dY = iy - Yb;
     137            float r2 = dX*dX + dY*dY;
     138            if (r2 > 9) continue;
     139            if (ix >= Nx) continue;
     140            if (iy >= Ny) continue;
     141            if (ix < 0) continue;
     142            if (iy < 0) continue;
     143            val[ix + iy*Nx] += fCircle;
     144          }
     145        }
     146        break;
     147      case IS_GAUSS:
     148        for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
     149          float dX = ix - Xb;
     150          for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
     151            float dY = iy - Yb;
     152            float r2 = dX*dX + dY*dY;
     153            if (ix >= Nx) continue;
     154            if (iy >= Ny) continue;
     155            if (ix < 0) continue;
     156            if (iy < 0) continue;
     157            val[ix + iy*Nx] += fGauss*exp(-fSigma*r2);
     158          }
     159        }
     160        break;
     161    }
    90162  }
    91163  return (TRUE);
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/init.c

    r35416 r37067  
    1010int center           PROTO((int, char **));
    1111int parity           PROTO((int, char **));
     12int cast             PROTO((int, char **));
    1213int circstats        PROTO((int, char **));
    1314int clear            PROTO((int, char **));
     
    5253int imcut            PROTO((int, char **));
    5354int imhist           PROTO((int, char **));
     55int impeaks          PROTO((int, char **));
    5456int imsmooth         PROTO((int, char **));
     57int imsmooth_generic PROTO((int, char **));
     58int imsmooth_2d      PROTO((int, char **));
    5559int integrate        PROTO((int, char **));
    5660int interpolate      PROTO((int, char **));
     61int join             PROTO((int, char **));
    5762int jpeg             PROTO((int, char **));
    5863int kern             PROTO((int, char **));
     
    7479int mget             PROTO((int, char **));
    7580int minterp          PROTO((int, char **));
     81int medimage_command PROTO((int, char **));
    7682int mset             PROTO((int, char **));
    7783int peak             PROTO((int, char **));
     
    8187int point            PROTO((int, char **));
    8288int ps               PROTO((int, char **));
     89int print_vectors    PROTO((int, char **));
    8390int queuelist        PROTO((int, char **));
    8491int queueload        PROTO((int, char **));
     
    133140int vmaxwell         PROTO((int, char **));
    134141int vload            PROTO((int, char **));
     142int vlist            PROTO((int, char **));
    135143int vzload           PROTO((int, char **));
    136144int vstats           PROTO((int, char **));
     
    160168  {1, "buffers",      list_buffers,     "list the currently allocated buffers (images)"},
    161169  {1, "center",       center,           "center image on coords"},
     170  {1, "cast",         cast,             "cast input vector to specified type"},
    162171  {1, "circstats",    circstats,        "circular statistics"},
    163172  {1, "clear",        clear,            "erase plot"},
     
    205214  {1, "imcut",        imcut,            "linear image cut between arbitrary coords"},
    206215  {1, "imhistogram",  imhist,           "histogram of an image region"},
     216  {1, "impeaks",      impeaks,          "find peaks in an image (return vectors)"},
    207217  {1, "imsmooth",     imsmooth,         "circular gaussian smoothing"},
     218  {1, "imsmooth.generic", imsmooth_generic, "circular non-gaussian smoothing"},
     219  {1, "imsmooth.2d",  imsmooth_2d,      "circular non-gaussian smoothing"},
    208220  {1, "imstats",      imstats,          "statistics on a portion of an image"},
    209221  {1, "integrate",    integrate,        "integrate a vector"},
    210222  {1, "interpolate",  interpolate,      "interpolate between vector pairs"},
     223  {1, "join",         join,             "find the join of two ID vectors"},
    211224  {1, "jpeg",         jpeg,             "convert display image to JPEG"},
    212225  {1, "kern",         kern,             "convolve with 3x3 kernel"},
     
    224237  {1, "minterp",      minterp,          "interpolate image pixels"},
    225238  {1, "iminterp",     minterp,          "interpolate image pixels"},
     239  {1, "medimage",     medimage_command, "median image manipulation"},
    226240  {1, "matrix",       matrix,           "matrix math operations"},
    227241  {1, "match2d",      match2d,          "match 2 pairs of X,Y vectors and return matched indexes"},
     
    237251  {1, "ppm",          jpeg,             "convert display graphic to PPM"},
    238252  {1, "ps",           ps,               "convert display to PostScript"},
     253  {1, "print_vectors", print_vectors,   "print a set of vectors"},
    239254  {1, "queuedelete",  queuedelete,      "delete a queue"},
    240255  {1, "queuedrop",    queuedrop,        "drop values from queue matching a key"},
     
    290305  {1, "vgrid",        vgrid,            "generate an image from a triplet of vectors"},
    291306  {1, "vhistogram",   histogram,        "generate histogram from vector"},
     307  {1, "vlist",        vlist,            "append values to a vector from command line"},
    292308  {1, "vload",        vload,            "load vectors as overlay on image display"},
    293309  {1, "vmaxwell",     vmaxwell,         "fit a Maxwellian to a vector"},
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/match2d.c

    r33963 r37067  
    1414  Vector *index1, *index2;
    1515
     16  if ((N = get_argument (argc, argv, "-h"))) goto usage;
     17  if ((N = get_argument (argc, argv, "--help"))) goto usage;
     18
    1619  CLOSEST = FALSE;
    1720  if ((N = get_argument (argc, argv, "-closest"))) {
     
    3841  if (argc != 6) {
    3942    gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n");
    40     gprint (GP_ERR, "  if -closest is provided, index1 & index2 will have the same length as X1 and X2 (respectively)\n");
    41     gprint (GP_ERR, "    with either the index of the match or a value of -1 for non-matches\n");
     43    gprint (GP_ERR, "  use -h or --help for more detail\n");
    4244    return (FALSE);
    4345  }
     
    9092
    9193  return (TRUE);
     94
     95usage:
     96  gprint (GP_ERR, "we have two modes of operation:\n\n");
     97
     98  gprint (GP_ERR, "without -closest, we are finding all matched pairs within the match radius.  in this\n");
     99  gprint (GP_ERR, "case, the two index vectors have the same length, one entry per matched pair.\n");
     100  gprint (GP_ERR, "x1[index1],y1[index1] matches to x2[index2],y2[index2].\n\n");
     101
     102  gprint (GP_ERR, "with -closest selected, we are finding the closest element of set 1 to each of set 2\n");
     103  gprint (GP_ERR, "and vice versa.  in this case, index1 is always the same length as x1,y1, while index2\n");
     104  gprint (GP_ERR, "is the same lengths as x2,y2.  x2[index1],y2[index1] matches x1,y1 while\n");
     105  gprint (GP_ERR, "x1[index2],y1[index2] matches x2,y2\n\n");
     106
     107  gprint (GP_ERR, "if -index1 or -index2 is not supplied, the vectors are created with names index1 or index2\n");
     108  gprint (GP_ERR, "use 'reindex' to generate new vectors based on these index vectors\n");
     109
     110  return FALSE;
    92111}
    93112
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/read_vectors.c

    r34753 r37067  
    33FILE *f = (FILE *) NULL;
    44char filename[2048];
     5
     6void read_vectors_cleanup ();
    57
    68int datafile (int argc, char **argv) {
     
    2426enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR};
    2527
     28static int      Nvec     = 0;
     29static Vector **vec      = NULL;
     30static char   **listname = NULL;
     31static int     *col      = NULL;
     32static int     *coltype  = NULL;
     33static char    *buffer   = NULL;
     34
    2635int read_vectors (int argc, char **argv) {
    2736 
    2837  int TimeFormat;
    2938  time_t TimeReference;
    30   int i, j, Nskip, Narg, Nvec, *col, IsCSV, VERBOSE;
    31   int Nbytes, Nstart, NELEM, Nelem, nread, *coltype;
     39  int i, j, Nskip, Narg, IsCSV, VERBOSE;
     40  int Nbytes, Nstart, NELEM, Nelem, nread;
    3241  char *colstr, *c0, *c1, *extname;
    33   Vector **vec;
    34 
    35   char *buffer = NULL;
     42  char varname[1024];  // used as a buffer for the names of string fields
    3643
    3744  /* auto-sense table type */
     
    8188
    8289  Nvec = (argc - 1) / 2;
     90  ALLOCATE (listname, char *, Nvec);
    8391  ALLOCATE (vec, Vector *, Nvec);
    8492  ALLOCATE (col, int, Nvec);
    8593  ALLOCATE (coltype, int, Nvec);
     94  for (i = 0; i < Nvec; i++) {
     95    listname[i] = NULL;
     96    vec[i] = NULL;
     97  }
    8698
    8799  for (i = 0; i < Nvec; i++) {
     
    108120    }
    109121
    110     if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) {
    111       gprint (GP_ERR, "USAGE: read name N name N ...\n");
    112       free (vec);
    113       free (col);
    114       return (FALSE);   
     122    if (coltype[i] == COLTYPE_CHAR) {
     123      listname[i] = strcreate (argv[2*i + 1]);
     124    } else {
     125      if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) {
     126        gprint (GP_ERR, "USAGE: read name N name N ...\n");
     127        read_vectors_cleanup();
     128        return (FALSE);   
     129      }
    115130    }
    116131
     
    137152    bad_colname:
    138153      gprint (GP_ERR, "USAGE: read name N name N ...\n");
    139       free (vec);
    140       free (col);
     154      read_vectors_cleanup();
    141155      return (FALSE);   
    142156    }
     
    146160  NELEM = 1000;
    147161  for (i = 0; i < Nvec; i++) {
    148     if ((coltype[i] == COLTYPE_INT) || (coltype[i] == COLTYPE_CHAR)) {
    149       ResetVector (vec[i], OPIHI_INT, NELEM);
    150     } else {
    151       // note that COLTYPE_TIME is a type of float
    152       ResetVector (vec[i], OPIHI_FLT, NELEM);
     162    switch (coltype[i]) {
     163      case COLTYPE_INT:
     164        ResetVector (vec[i], OPIHI_INT, NELEM);
     165        break;
     166      case COLTYPE_FLT:
     167      case COLTYPE_TIME:
     168        // note that COLTYPE_TIME is a type of float
     169        ResetVector (vec[i], OPIHI_FLT, NELEM);
     170        break;
     171      case COLTYPE_CHAR:
     172      default:
     173        break;
    153174    }
    154175  }
     
    159180    if (scan_line_maxlen (f, buffer, 0x10000) == EOF) {
    160181      gprint (GP_ERR, "problem reading file %s\n", filename);
    161       free (vec);
    162       free (col);
     182      read_vectors_cleanup();
    163183      return FALSE;
    164184    }
     
    206226      for (i = 0; i < Nvec; i++) {
    207227        int ivalue;
    208         char cvalue;
    209228        double dvalue;
    210229        time_t tvalue;
     
    217236            break;
    218237          case COLTYPE_CHAR:
    219             readStatus = IsCSV ? charparse_csv (&cvalue, col[i], c0) : charparse (&cvalue, col[i], c0);
    220             vec[i][0].elements.Int[Nelem] = readStatus ? cvalue : 0;
    221             break;
     238            {
     239              // I need to get an isolated word in 'value' with the string value of this field
     240              char *ptr = IsCSV ? ptrparse_csv (col[i], c0) : ptrparse (col[i], c0);
     241              char *value = NULL;
     242              if (IsCSV) {
     243                char *end = parse_nextword_csv (ptr);
     244                if (end) {
     245                  value = end ? strncreate (ptr, end - ptr) : strcreate (ptr);
     246                }
     247              } else {
     248                value = thisword(ptr);
     249              }
     250              set_list_varname (varname, listname[i], Nelem, FALSE);
     251              set_str_variable (varname, value);
     252              free (value);
     253              break;
     254            }
    222255          case COLTYPE_FLT:
    223256            readStatus = IsCSV ? dparse_csv (&dvalue, col[i], c0) : dparse (&dvalue, col[i], c0);
     
    249282        NELEM += 1000;
    250283        for (i = 0; i < Nvec; i++) {
    251           if (coltype[i] == COLTYPE_INT) {
    252             REALLOCATE (vec[i][0].elements.Int, opihi_int, NELEM);
    253           } else {
    254             REALLOCATE (vec[i][0].elements.Flt, opihi_flt, NELEM);
     284          switch (coltype[i]) {
     285            case COLTYPE_INT:
     286              ResetVector (vec[i], OPIHI_INT, NELEM);
     287              break;
     288            case COLTYPE_FLT:
     289            case COLTYPE_TIME:
     290              ResetVector (vec[i], OPIHI_FLT, NELEM);
     291              break;
     292            case COLTYPE_CHAR:
     293            default:
     294              break;
    255295          }
    256296        }
     
    259299    }
    260300  }
     301  // set the final vector / list length
    261302  for (i = 0; i < Nvec; i++) {
    262     if (coltype[i] == COLTYPE_INT) {
    263       REALLOCATE (vec[i][0].elements.Int, opihi_int, MAX (Nelem,1));
    264     } else {
    265       REALLOCATE (vec[i][0].elements.Flt, opihi_flt, MAX (Nelem,1));
    266     }
    267     vec[i][0].Nelements = Nelem;
    268   }
    269  
    270   free (vec);
    271   free (col);
    272   if (buffer) free (buffer);
     303    switch (coltype[i]) {
     304      case COLTYPE_INT:
     305        ResetVector (vec[i], OPIHI_INT, Nelem);
     306        break;
     307      case COLTYPE_FLT:
     308      case COLTYPE_TIME:
     309        ResetVector (vec[i], OPIHI_FLT, Nelem);
     310        break;
     311      case COLTYPE_CHAR:
     312        sprintf (varname, "%s:n", listname[i]);
     313        set_int_variable (varname, Nelem);
     314        break;
     315      default:
     316        break;
     317    }
     318  }
     319  read_vectors_cleanup();
    273320  return (TRUE);
    274 
    275321}
    276322
    277 # define ESCAPE(MSG) { \
    278   gprint (GP_ERR, "%s\n", MSG); \
     323# define ESCAPE(...) {          \
     324  gprint (GP_ERR, __VA_ARGS__); \
    279325  if (CCDKeyword != NULL) free (CCDKeyword); \
    280326  gfits_free_table  (&table); \
     
    285331
    286332  off_t Nbytes;
    287   int i, j, k, N, Nextend, Ny, Binary, vecType, padIfShort;
     333  int i, j, N, Nextend, Ny, Binary, vecType, padIfShort;
    288334  char type[16], ID[80], *CCDKeyword;
    289335  FTable table;
    290336  Header header;
    291337  Vector **vec;
     338  int FITS_TRANSPOSE;
    292339
    293340  table.buffer = NULL;
    294341  header.buffer = NULL;
     342
     343  FITS_TRANSPOSE = FALSE;
     344  if ((N = get_argument (argc, argv, "-transpose"))) {
     345    remove_argument (N, &argc, argv);
     346    FITS_TRANSPOSE = TRUE;
     347  }
    295348
    296349  CCDKeyword = NULL;
     
    321374  // }
    322375
    323   if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ...");
    324 
    325   if (f == NULL) ESCAPE ("file not found");
     376  if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ...\n");
     377
     378  if (f == NULL) ESCAPE ("file not found\n");
    326379  fseeko (f, 0LL, SEEK_SET);
    327380  table.header = &header;
     
    331384    // first extension is PHU, cannot be a table.
    332385    // Nextend counts from 0 for first extension
    333     if (!gfits_load_header (f, &header)) ESCAPE ("error reading primary header for file");
     386    if (!gfits_load_header (f, &header)) ESCAPE ("error reading primary header for file\n");
    334387    Nbytes = gfits_data_size (&header);
    335388    fseeko (f, Nbytes, SEEK_CUR);
     
    337390
    338391    for (i = 0; i < Nextend; i++) {
    339       if (!gfits_load_header (f, &header)) ESCAPE ("extension not found");
     392      if (!gfits_load_header (f, &header)) ESCAPE ("extension %d not found\n", i);
    340393      Nbytes = gfits_data_size (&header);
    341394      /* skip the prior data buffers */
     
    343396      gfits_free_header (&header);
    344397    }
    345     if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension");
    346     if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension");
     398    if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension %d\n", Nextend);
     399    if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend);
    347400
    348401  } else {
     
    375428        continue;
    376429      }
    377       if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension");
     430      if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension\n");
    378431      break;
    379432    }
     
    384437  gfits_scan (&header, "XTENSION", "%s", 1, type);
    385438  if (strcmp (type, "BINTABLE") && strcmp (type, "TABLE")) {
    386     ESCAPE ("specified extension is not a table\n");
     439    ESCAPE ("specified extension %s is not a table\n", type);
    387440  }
    388441  Binary = !strcmp (type, "BINTABLE");
     
    410463    }
    411464       
    412     // define the multifield vector names
    413     ALLOCATE (vec, Vector *, Nval);
    414     for (j = 0; j < Nval; j++) {
    415       if (Nval == 1)
    416         sprintf (name, "%s", argv[i]);
    417       else
    418         sprintf (name, "%s:%d", argv[i], j);
    419       if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
    420       ResetVector (vec[j], vecType, Ny);
    421     }
    422 
    423     if (!strcmp (type, "char")) {
    424       char *Ptr = data;
     465    if (!FITS_TRANSPOSE) {
     466      // read string column into a list rather than a vector
     467      if (!strcmp (type, "char")) {
     468        char *fieldName = argv[i];
     469        char *Ptr = data;
     470        char varname[1024];  // used as a buffer for the names of string fields
     471        for (j = 0; j < Ny; j++) {
     472          set_list_varname (varname, fieldName, j, FALSE);
     473          char *value = strncreate (&Ptr[j*Nval], Nval);
     474          // replace instances of $ with _
     475          char *p = strchr (value, '$');
     476          while (p) {
     477            *p = '_';
     478            p = strchr (p, '$');
     479          }
     480          set_str_variable (varname, value);
     481          free (value);
     482        }
     483        sprintf (varname, "%s:n", fieldName);
     484        set_int_variable (varname, Ny);
     485        continue;
     486      }
     487
     488      // define the multifield vector names (Nval vectors x Ny elements)
     489      ALLOCATE (vec, Vector *, Nval);
     490      for (j = 0; j < Nval; j++) {
     491        if (Nval == 1)
     492          sprintf (name, "%s", argv[i]);
     493        else
     494          sprintf (name, "%s:%d", argv[i], j);
     495        if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
     496        ResetVector (vec[j], vecType, Ny);
     497      }
     498
     499      if (!VectorAssignData (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type);
     500
     501    } else {
     502      // define the multifield vector names (Ny vectors x Nval elements)
     503      ALLOCATE (vec, Vector *, Ny);
    425504      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, "short")) {
    432       short *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, "int")) {
    440       int *Ptr = data;
    441       for (j = 0; j < Ny; j++) {
    442         for (k = 0; k < Nval; k++, Ptr++) {
    443           vec[k][0].elements.Int[j] = *Ptr;
    444         }
    445       }
    446     }
    447     if (!strcmp (type, "int64_t")) {
    448       int64_t *Ptr = data;
    449       for (j = 0; j < Ny; j++) {
    450         for (k = 0; k < Nval; k++, Ptr++) {
    451           vec[k][0].elements.Int[j] = *Ptr;
    452         }
    453       }
    454     }
    455     if (!strcmp (type, "float")) {
    456       float *Ptr = data;
    457       for (j = 0; j < Ny; j++) {
    458         for (k = 0; k < Nval; k++, Ptr++) {
    459           vec[k][0].elements.Flt[j] = *Ptr;
    460         }
    461       }
    462     }
    463     if (!strcmp (type, "double")) {
    464       double *Ptr = data;
    465       for (j = 0; j < Ny; j++) {
    466         for (k = 0; k < Nval; k++, Ptr++) {
    467           vec[k][0].elements.Flt[j] = *Ptr;
    468         }
    469       }
     505        if (Ny == 1)
     506          sprintf (name, "%s", argv[i]);
     507        else
     508          sprintf (name, "%s:%d", argv[i], j);
     509        if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
     510        ResetVector (vec[j], vecType, Nval);
     511      }
     512
     513      if (!VectorAssignDataTranspose (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type);
    470514    }
    471515    free (data);
     
    477521  return (TRUE);
    478522}
     523
     524void read_vectors_cleanup () {
     525
     526  int i;
     527
     528  if (col) free (col);
     529  if (coltype) free (coltype);
     530  if (buffer) free (buffer);
     531  if (listname) {
     532    for (i = 0; i < Nvec; i++) {
     533      if (listname[i]) free (listname[i]);
     534    }
     535    free (listname);
     536  }
     537  if (vec) free (vec);
     538}
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/rebin.c

    r28241 r37067  
    133133              *Vout += *Vin;
    134134              if (Normalize) {(*Vn) ++;}
     135              // if ((i == 1) && (j == 1)) fprintf (stderr, "%d,%d : %d,%d : %f : %f : %d\n", i, j, x, y, *Vin, *Vout, *Vn);
    135136            }
    136137            if (Normalize) {Vn ++;}
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/vellipse.c

    r25757 r37067  
    228228 */
    229229
     230// XXX NOTE that PHI is defined with the wrong sign, should fix this...
    230231opihi_flt fellipseOD (opihi_flt alpha, opihi_flt *par, int Npar, opihi_flt *dpar) {
    231232 
  • branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/vgauss.c

    r35109 r37067  
    4848  if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    4949
     50  CastVector (xvec, OPIHI_FLT);
     51  CastVector (yvec, OPIHI_FLT);
     52
    5053  int Nsvec = strlen(argv[3]);
    5154
     
    6972  }
    7073
    71   CastVector (xvec, OPIHI_FLT);
    72   CastVector (yvec, OPIHI_FLT);
    7374  CastVector (svec, OPIHI_FLT);
    7475  // XXX Cast is failing.
Note: See TracChangeset for help on using the changeset viewer.