- Timestamp:
- Jul 17, 2014, 12:32:26 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-ops-20130712/Ohana
- Files:
-
- 11 edited
- 11 copied
-
. (modified) (1 prop)
-
src/opihi (modified) (1 prop)
-
src/opihi/cmd.data (modified) (1 prop)
-
src/opihi/cmd.data/Makefile (modified) (5 diffs)
-
src/opihi/cmd.data/cast.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/cast.c )
-
src/opihi/cmd.data/densify.c (modified) (5 diffs)
-
src/opihi/cmd.data/impeaks.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/impeaks.c )
-
src/opihi/cmd.data/imsmooth.2d.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imsmooth.2d.c )
-
src/opihi/cmd.data/imsmooth.generic.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imsmooth.generic.c )
-
src/opihi/cmd.data/init.c (modified) (10 diffs)
-
src/opihi/cmd.data/join.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/join.c )
-
src/opihi/cmd.data/match2d.c (modified) (3 diffs)
-
src/opihi/cmd.data/medimage.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/medimage.c )
-
src/opihi/cmd.data/medimage_commands.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/medimage_commands.c )
-
src/opihi/cmd.data/print_vectors.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/print_vectors.c )
-
src/opihi/cmd.data/read_vectors.c (modified) (20 diffs)
-
src/opihi/cmd.data/rebin.c (modified) (1 diff)
-
src/opihi/cmd.data/test/join.sh (copied) (copied from trunk/Ohana/src/opihi/cmd.data/test/join.sh )
-
src/opihi/cmd.data/test/medimage.sh (copied) (copied from trunk/Ohana/src/opihi/cmd.data/test/medimage.sh )
-
src/opihi/cmd.data/vellipse.c (modified) (1 diff)
-
src/opihi/cmd.data/vgauss.c (modified) (2 diffs)
-
src/opihi/cmd.data/vlist.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/vlist.c )
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 25 25 $(SRC)/book.$(ARCH).o \ 26 26 $(SRC)/book_commands.$(ARCH).o \ 27 $(SRC)/cast.$(ARCH).o \ 27 28 $(SRC)/center.$(ARCH).o \ 28 29 $(SRC)/clear.$(ARCH).o \ … … 63 64 $(SRC)/imcut.$(ARCH).o \ 64 65 $(SRC)/imhist.$(ARCH).o \ 66 $(SRC)/impeaks.$(ARCH).o \ 65 67 $(SRC)/imsmooth.$(ARCH).o \ 68 $(SRC)/imsmooth.generic.$(ARCH).o \ 69 $(SRC)/imsmooth.2d.$(ARCH).o \ 66 70 $(SRC)/integrate.$(ARCH).o \ 67 71 $(SRC)/interpolate.$(ARCH).o \ 72 $(SRC)/join.$(ARCH).o \ 68 73 $(SRC)/jpeg.$(ARCH).o \ 69 74 $(SRC)/kern.$(ARCH).o \ … … 84 89 $(SRC)/mget.$(ARCH).o \ 85 90 $(SRC)/minterpolate.$(ARCH).o \ 91 $(SRC)/medimage.$(ARCH).o \ 92 $(SRC)/medimage_commands.$(ARCH).o \ 86 93 $(SRC)/mset.$(ARCH).o \ 87 94 $(SRC)/peak.$(ARCH).o \ … … 91 98 $(SRC)/point.$(ARCH).o \ 92 99 $(SRC)/ps.$(ARCH).o \ 100 $(SRC)/print_vectors.$(ARCH).o \ 93 101 $(SRC)/queuedelete.$(ARCH).o \ 94 102 $(SRC)/queuedrop.$(ARCH).o \ … … 143 151 $(SRC)/vmaxwell.$(ARCH).o \ 144 152 $(SRC)/vgrid.$(ARCH).o \ 153 $(SRC)/vlist.$(ARCH).o \ 145 154 $(SRC)/vload.$(ARCH).o \ 146 155 $(SRC)/vzload.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/densify.c
r34088 r37067 2 2 3 3 # define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); } 4 enum {IS_DOT, IS_SQUARE, IS_CIRCLE, IS_GAUSS}; 4 5 5 6 int densify (int argc, char **argv) { 6 7 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; 8 9 double Xmin, Xmax, dX, Ymin, Ymax, dY; 9 10 float *val; … … 24 25 } 25 26 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 26 44 good = UseGraph ? (argc == 4) : (argc == 10); 27 45 if (!good) { 28 46 gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n"); 29 47 gprint (GP_ERR, " OR: densify buffer x y -graph\n"); 48 gprint (GP_ERR, " option: -psf [dot] (circle) (square) (gauss)\n"); 30 49 return (FALSE); 31 50 } … … 69 88 CHECKVAL(dY); 70 89 90 float scaleX = (scale > 0.0) ? scale / dX : 3.0; 91 float scaleY = (scale > 0.0) ? scale / dY : 3.0; 92 71 93 Nx = (Xmax - Xmin) / dX + 1; 72 94 Ny = (Ymax - Ymin) / dY + 1; … … 76 98 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0); 77 99 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); 78 106 79 107 x = vx[0].elements.Flt; … … 83 111 Xb = (*x - Xmin) / dX; 84 112 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 } 90 162 } 91 163 return (TRUE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/init.c
r35416 r37067 10 10 int center PROTO((int, char **)); 11 11 int parity PROTO((int, char **)); 12 int cast PROTO((int, char **)); 12 13 int circstats PROTO((int, char **)); 13 14 int clear PROTO((int, char **)); … … 52 53 int imcut PROTO((int, char **)); 53 54 int imhist PROTO((int, char **)); 55 int impeaks PROTO((int, char **)); 54 56 int imsmooth PROTO((int, char **)); 57 int imsmooth_generic PROTO((int, char **)); 58 int imsmooth_2d PROTO((int, char **)); 55 59 int integrate PROTO((int, char **)); 56 60 int interpolate PROTO((int, char **)); 61 int join PROTO((int, char **)); 57 62 int jpeg PROTO((int, char **)); 58 63 int kern PROTO((int, char **)); … … 74 79 int mget PROTO((int, char **)); 75 80 int minterp PROTO((int, char **)); 81 int medimage_command PROTO((int, char **)); 76 82 int mset PROTO((int, char **)); 77 83 int peak PROTO((int, char **)); … … 81 87 int point PROTO((int, char **)); 82 88 int ps PROTO((int, char **)); 89 int print_vectors PROTO((int, char **)); 83 90 int queuelist PROTO((int, char **)); 84 91 int queueload PROTO((int, char **)); … … 133 140 int vmaxwell PROTO((int, char **)); 134 141 int vload PROTO((int, char **)); 142 int vlist PROTO((int, char **)); 135 143 int vzload PROTO((int, char **)); 136 144 int vstats PROTO((int, char **)); … … 160 168 {1, "buffers", list_buffers, "list the currently allocated buffers (images)"}, 161 169 {1, "center", center, "center image on coords"}, 170 {1, "cast", cast, "cast input vector to specified type"}, 162 171 {1, "circstats", circstats, "circular statistics"}, 163 172 {1, "clear", clear, "erase plot"}, … … 205 214 {1, "imcut", imcut, "linear image cut between arbitrary coords"}, 206 215 {1, "imhistogram", imhist, "histogram of an image region"}, 216 {1, "impeaks", impeaks, "find peaks in an image (return vectors)"}, 207 217 {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"}, 208 220 {1, "imstats", imstats, "statistics on a portion of an image"}, 209 221 {1, "integrate", integrate, "integrate a vector"}, 210 222 {1, "interpolate", interpolate, "interpolate between vector pairs"}, 223 {1, "join", join, "find the join of two ID vectors"}, 211 224 {1, "jpeg", jpeg, "convert display image to JPEG"}, 212 225 {1, "kern", kern, "convolve with 3x3 kernel"}, … … 224 237 {1, "minterp", minterp, "interpolate image pixels"}, 225 238 {1, "iminterp", minterp, "interpolate image pixels"}, 239 {1, "medimage", medimage_command, "median image manipulation"}, 226 240 {1, "matrix", matrix, "matrix math operations"}, 227 241 {1, "match2d", match2d, "match 2 pairs of X,Y vectors and return matched indexes"}, … … 237 251 {1, "ppm", jpeg, "convert display graphic to PPM"}, 238 252 {1, "ps", ps, "convert display to PostScript"}, 253 {1, "print_vectors", print_vectors, "print a set of vectors"}, 239 254 {1, "queuedelete", queuedelete, "delete a queue"}, 240 255 {1, "queuedrop", queuedrop, "drop values from queue matching a key"}, … … 290 305 {1, "vgrid", vgrid, "generate an image from a triplet of vectors"}, 291 306 {1, "vhistogram", histogram, "generate histogram from vector"}, 307 {1, "vlist", vlist, "append values to a vector from command line"}, 292 308 {1, "vload", vload, "load vectors as overlay on image display"}, 293 309 {1, "vmaxwell", vmaxwell, "fit a Maxwellian to a vector"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/match2d.c
r33963 r37067 14 14 Vector *index1, *index2; 15 15 16 if ((N = get_argument (argc, argv, "-h"))) goto usage; 17 if ((N = get_argument (argc, argv, "--help"))) goto usage; 18 16 19 CLOSEST = FALSE; 17 20 if ((N = get_argument (argc, argv, "-closest"))) { … … 38 41 if (argc != 6) { 39 42 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"); 42 44 return (FALSE); 43 45 } … … 90 92 91 93 return (TRUE); 94 95 usage: 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; 92 111 } 93 112 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/read_vectors.c
r34753 r37067 3 3 FILE *f = (FILE *) NULL; 4 4 char filename[2048]; 5 6 void read_vectors_cleanup (); 5 7 6 8 int datafile (int argc, char **argv) { … … 24 26 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR}; 25 27 28 static int Nvec = 0; 29 static Vector **vec = NULL; 30 static char **listname = NULL; 31 static int *col = NULL; 32 static int *coltype = NULL; 33 static char *buffer = NULL; 34 26 35 int read_vectors (int argc, char **argv) { 27 36 28 37 int TimeFormat; 29 38 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; 32 41 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 36 43 37 44 /* auto-sense table type */ … … 81 88 82 89 Nvec = (argc - 1) / 2; 90 ALLOCATE (listname, char *, Nvec); 83 91 ALLOCATE (vec, Vector *, Nvec); 84 92 ALLOCATE (col, int, Nvec); 85 93 ALLOCATE (coltype, int, Nvec); 94 for (i = 0; i < Nvec; i++) { 95 listname[i] = NULL; 96 vec[i] = NULL; 97 } 86 98 87 99 for (i = 0; i < Nvec; i++) { … … 108 120 } 109 121 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 } 115 130 } 116 131 … … 137 152 bad_colname: 138 153 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 139 free (vec); 140 free (col); 154 read_vectors_cleanup(); 141 155 return (FALSE); 142 156 } … … 146 160 NELEM = 1000; 147 161 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; 153 174 } 154 175 } … … 159 180 if (scan_line_maxlen (f, buffer, 0x10000) == EOF) { 160 181 gprint (GP_ERR, "problem reading file %s\n", filename); 161 free (vec); 162 free (col); 182 read_vectors_cleanup(); 163 183 return FALSE; 164 184 } … … 206 226 for (i = 0; i < Nvec; i++) { 207 227 int ivalue; 208 char cvalue;209 228 double dvalue; 210 229 time_t tvalue; … … 217 236 break; 218 237 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 } 222 255 case COLTYPE_FLT: 223 256 readStatus = IsCSV ? dparse_csv (&dvalue, col[i], c0) : dparse (&dvalue, col[i], c0); … … 249 282 NELEM += 1000; 250 283 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; 255 295 } 256 296 } … … 259 299 } 260 300 } 301 // set the final vector / list length 261 302 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(); 273 320 return (TRUE); 274 275 321 } 276 322 277 # define ESCAPE( MSG) {\278 gprint (GP_ERR, "%s\n", MSG); \323 # define ESCAPE(...) { \ 324 gprint (GP_ERR, __VA_ARGS__); \ 279 325 if (CCDKeyword != NULL) free (CCDKeyword); \ 280 326 gfits_free_table (&table); \ … … 285 331 286 332 off_t Nbytes; 287 int i, j, k,N, Nextend, Ny, Binary, vecType, padIfShort;333 int i, j, N, Nextend, Ny, Binary, vecType, padIfShort; 288 334 char type[16], ID[80], *CCDKeyword; 289 335 FTable table; 290 336 Header header; 291 337 Vector **vec; 338 int FITS_TRANSPOSE; 292 339 293 340 table.buffer = NULL; 294 341 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 } 295 348 296 349 CCDKeyword = NULL; … … 321 374 // } 322 375 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"); 326 379 fseeko (f, 0LL, SEEK_SET); 327 380 table.header = &header; … … 331 384 // first extension is PHU, cannot be a table. 332 385 // 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"); 334 387 Nbytes = gfits_data_size (&header); 335 388 fseeko (f, Nbytes, SEEK_CUR); … … 337 390 338 391 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); 340 393 Nbytes = gfits_data_size (&header); 341 394 /* skip the prior data buffers */ … … 343 396 gfits_free_header (&header); 344 397 } 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); 347 400 348 401 } else { … … 375 428 continue; 376 429 } 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"); 378 431 break; 379 432 } … … 384 437 gfits_scan (&header, "XTENSION", "%s", 1, type); 385 438 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); 387 440 } 388 441 Binary = !strcmp (type, "BINTABLE"); … … 410 463 } 411 464 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); 425 504 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); 470 514 } 471 515 free (data); … … 477 521 return (TRUE); 478 522 } 523 524 void 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 133 133 *Vout += *Vin; 134 134 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); 135 136 } 136 137 if (Normalize) {Vn ++;} -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/vellipse.c
r25757 r37067 228 228 */ 229 229 230 // XXX NOTE that PHI is defined with the wrong sign, should fix this... 230 231 opihi_flt fellipseOD (opihi_flt alpha, opihi_flt *par, int Npar, opihi_flt *dpar) { 231 232 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/vgauss.c
r35109 r37067 48 48 if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE); 49 49 50 CastVector (xvec, OPIHI_FLT); 51 CastVector (yvec, OPIHI_FLT); 52 50 53 int Nsvec = strlen(argv[3]); 51 54 … … 69 72 } 70 73 71 CastVector (xvec, OPIHI_FLT);72 CastVector (yvec, OPIHI_FLT);73 74 CastVector (svec, OPIHI_FLT); 74 75 // XXX Cast is failing.
Note:
See TracChangeset
for help on using the changeset viewer.
