Changeset 35109 for trunk/Ohana/src/opihi/cmd.data
- Timestamp:
- Feb 6, 2013, 3:30:44 PM (13 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 11 edited
- 1 copied
-
. (modified) (1 prop)
-
cmd.data (modified) (1 prop)
-
cmd.data/Makefile (modified) (1 diff)
-
cmd.data/dbconnect.c (modified) (2 diffs)
-
cmd.data/dbinsert.c (copied) (copied from branches/eam_branches/ipp-20121219/Ohana/src/opihi/cmd.data/dbinsert.c )
-
cmd.data/init.c (modified) (2 diffs)
-
cmd.data/spline.c (modified) (4 diffs)
-
cmd.data/spline_commands.c (modified) (1 diff)
-
cmd.data/subset.c (modified) (1 diff)
-
cmd.data/vgauss.c (modified) (4 diffs)
-
cmd.data/vstats.c (modified) (1 diff)
-
cmd.data/write_vectors.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20121219/Ohana/src/opihi (added) merged: 34858,34876-34877,34886-34887,34890-34891,34895,34898,34901,34903,34935,34999,35096
- Property svn:mergeinfo changed
-
trunk/Ohana/src/opihi/cmd.data
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20121219/Ohana/src/opihi/cmd.data (added) merged: 34858,34876,34886,34890-34891,34895,34898,34903,34935,34999,35096
- Property svn:mergeinfo changed
-
trunk/Ohana/src/opihi/cmd.data/Makefile
r34584 r35109 42 42 $(SRC)/dbconnect.$(ARCH).o \ 43 43 $(SRC)/dbselect.$(ARCH).o \ 44 $(SRC)/dbinsert.$(ARCH).o \ 44 45 $(SRC)/erase.$(ARCH).o \ 45 46 $(SRC)/extract.$(ARCH).o \ -
trunk/Ohana/src/opihi/cmd.data/dbconnect.c
r34584 r35109 8 8 int dbconnect (int argc, char **argv) { 9 9 10 int N; 10 11 char query[256]; 11 char password[1024];12 12 MYSQL_RES *result; 13 14 char *password = NULL; 15 if ((N = get_argument (argc, argv, "-p"))) { 16 remove_argument (N, &argc, argv); 17 password = strcreate (argv[N]); 18 remove_argument (N, &argc, argv); 19 } 13 20 14 21 if (argc != 4) { … … 17 24 } 18 25 19 fprintf (stdout, "Enter password: "); 20 scan_line (stdin, password); 26 if (!password) { 27 ALLOCATE (password, char, 1024); 28 fprintf (stdout, "Enter password: "); 29 scan_line (stdin, password); 21 30 22 31 # if (0) 23 int i;24 char c;32 int i; 33 char c; 25 34 26 initscr(); 27 noecho(); 28 i = 0; 29 while (((c = getch()) != EOF) && (c != '\n')) { 30 password[i] = c; 31 i++; 35 initscr(); 36 noecho(); 37 i = 0; 38 while (((c = getch()) != EOF) && (c != '\n')) { 39 password[i] = c; 40 i++; 41 } 42 password[i] = 0; 43 # endif 32 44 } 33 password[i] = 0;34 # endif35 45 36 46 // XXX do I need to call mysql_library_init()? -
trunk/Ohana/src/opihi/cmd.data/init.c
r34584 r35109 24 24 int dbconnect PROTO((int, char **)); 25 25 int dbselect PROTO((int, char **)); 26 int dbinsert PROTO((int, char **)); 26 27 int delete PROTO((int, char **)); 27 28 int densify PROTO((int, char **)); … … 170 171 {1, "dbconnect", dbconnect, "setup mysql db connection"}, 171 172 {1, "dbselect", dbselect, "extract vectors from mysql database table"}, 173 {1, "dbinsert", dbinsert, "sql insert command"}, 172 174 {1, "delete", delete, "delete vectors or images"}, 173 175 {1, "densify", densify, "create an image histogram from a set of vectors"}, -
trunk/Ohana/src/opihi/cmd.data/spline.c
r34584 r35109 2 2 3 3 int spline_list (int argc, char **argv); 4 int spline_help (int argc, char **argv); 4 5 int spline_create (int argc, char **argv); 5 6 int spline_apply (int argc, char **argv); … … 7 8 int spline_save (int argc, char **argv); 8 9 int spline_delete (int argc, char **argv); 10 int spline_rename (int argc, char **argv); 9 11 int spline_getspline (int argc, char **argv); 10 12 11 13 static Command spline_commands[] = { 14 {1, "help", spline_help, "list spline help info"}, 12 15 {1, "list", spline_list, "list splines"}, 13 16 {1, "create", spline_create, "create a spline"}, … … 16 19 {1, "save", spline_save, "read a spline from a FITS file"}, 17 20 {1, "delete", spline_delete, "delete a spline"}, 21 {1, "rename", spline_rename, "rename a spline"}, 18 22 }; 23 24 int spline_help (int argc, char **argv) { 25 26 gprint (GP_ERR, "USAGE: spline (command)\n"); 27 gprint (GP_ERR, " spline help : this listing\n"); 28 gprint (GP_ERR, " spline list : list splines\n"); 29 gprint (GP_ERR, " spline create (spline) (Xknots) (Yknots) : create a spline\n"); 30 gprint (GP_ERR, " spline apply (spline) (Xpts) (Ypts) : apply a spline to Xpts to get Ypts\n"); 31 gprint (GP_ERR, " spline delete (spline) : delete named spline\n"); 32 gprint (GP_ERR, " spline rename (spline) (new) : change spline name to new name\n"); 33 gprint (GP_ERR, " spline load (spline) (filename) : load a spline from a FITS file\n"); 34 gprint (GP_ERR, " spline save (spline) (filename) [-append] : save a spline in FITS format\n"); 35 36 return FALSE; 37 } 19 38 20 39 int spline_command (int argc, char **argv) { … … 23 42 24 43 if (argc < 2) { 25 gprint (GP_ERR, "USAGE: spline (command)\n"); 26 gprint (GP_ERR, " spline list : list splines\n"); 27 gprint (GP_ERR, " spline create (spline) : create a spline\n"); 28 gprint (GP_ERR, " spline delete (spline) : delete a spline\n"); 44 spline_help(0,NULL); 29 45 return (FALSE); 30 46 } -
trunk/Ohana/src/opihi/cmd.data/spline_commands.c
r34584 r35109 126 126 } 127 127 128 int spline_rename (int argc, char **argv) { 129 130 Spline *spline; 131 132 if (argc != 3) { 133 gprint (GP_ERR, "USAGE: spline rename (spline) (newname)\n"); 134 return FALSE; 135 } 136 137 spline = FindSpline (argv[1]); 138 if (spline == NULL) { 139 gprint (GP_ERR, "spline %s not found\n", argv[1]); 140 return FALSE; 141 } 142 143 free (spline->name); 144 spline->name = strcreate (argv[2]); 145 return TRUE; 146 } 147 128 148 /* 129 149 int spline_listspline (int argc, char **argv) { -
trunk/Ohana/src/opihi/cmd.data/subset.c
r34461 r35109 35 35 } 36 36 if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) goto error; 37 /* check size of ivec, tvec: must match */ 37 if (ivec->Nelements != tvec->Nelements) { 38 /* check size of ivec, tvec: must match */ 39 gprint (GP_ERR, "logical expression has different length from input vector\n"); 40 goto error; 41 } 38 42 39 43 // ovec matches ivec in type -
trunk/Ohana/src/opihi/cmd.data/vgauss.c
r29938 r35109 31 31 } 32 32 33 // Guess = FALSE; 34 // if ((N = get_argument (argc, argv, "-guess"))) { 35 // Guess = TRUE; 36 // remove_argument (N, &argc, argv); 37 // } 38 33 39 if (argc != 5) { 34 40 gprint (GP_ERR, "USAGE: vgauss <x> <y> <dy> (out)\n"); 41 gprint (GP_ERR, " <dy> may be the words 'con[stant]' or 'poi[sson]', in which case the error is constructed'\n"); 35 42 gprint (GP_ERR, " uses guesses: C0 (mean), C1 (sigma), C2 (norm), C3 (sky)\n"); 36 43 return (FALSE); … … 39 46 if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 40 47 if ((yvec = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE); 41 if ((svec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE);42 48 if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE); 49 50 int Nsvec = strlen(argv[3]); 51 52 if ((Nsvec >= 3) && (!strncasecmp ("poisson", argv[3], Nsvec) || !strncasecmp ("constant", argv[3], Nsvec))) { 53 svec = SelectVector ("vgauss_err", ANYVECTOR, TRUE); 54 if (svec == NULL) return (FALSE); 55 MatchVector (svec, xvec, OPIHI_FLT); 56 v1 = svec[0].elements.Flt; 57 v2 = yvec[0].elements.Flt; 58 if (!strncasecmp ("poisson", argv[3], Nsvec)) { 59 for (i = 0; i < svec[0].Nelements; i++) { 60 v1[i] = (isfinite(v2[i]) && (v2[i] > 0)) ? sqrt(v2[i]) : 1.0; 61 } 62 } else { 63 for (i = 0; i < svec[0].Nelements; i++) { 64 v1[i] = 1.0; 65 } 66 } 67 } else { 68 if ((svec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE); 69 } 43 70 44 71 CastVector (xvec, OPIHI_FLT); … … 46 73 CastVector (svec, OPIHI_FLT); 47 74 // XXX Cast is failing. 48 49 75 50 76 Npts = xvec[0].Nelements; … … 58 84 GET_VAR (par[3], "C3"); 59 85 Npar = 4; 86 60 87 61 88 // mrqmin takes the inverse variance (do not generate NANs) -
trunk/Ohana/src/opihi/cmd.data/vstats.c
r33963 r35109 123 123 124 124 ALLOCATE (Nval, int, Nbin + 2); 125 bzero (Nval, Nbin*sizeof(int));125 bzero (Nval, (Nbin + 2)*sizeof(int)); 126 126 var = 0; 127 127 if (vec[0].type == OPIHI_FLT) { -
trunk/Ohana/src/opihi/cmd.data/write_vectors.c
r34584 r35109 10 10 Vector **vec; 11 11 12 if ((N = get_argument (argc, argv, "-h"))) goto usage; 13 if ((N = get_argument (argc, argv, "--h"))) goto usage; 14 if ((N = get_argument (argc, argv, "-help"))) goto usage; 15 if ((N = get_argument (argc, argv, "--help"))) goto usage; 16 12 17 /* look for format option */ 13 18 format = (char *) NULL; … … 17 22 remove_argument (N, &argc, argv); 18 23 } 24 if ((N = get_argument (argc, argv, "-format"))) { 25 if (format) { 26 gprint (GP_ERR, "ERROR: do not mix -f and -format\n"); 27 free (format); 28 return (FALSE); 29 } 30 remove_argument (N, &argc, argv); 31 format = strcreate (argv[N]); 32 remove_argument (N, &argc, argv); 33 } 19 34 20 35 /* option generate a FITS output table */ 21 36 FITS = NULL; 22 37 if ((N = get_argument (argc, argv, "-fits"))) { 23 if (format) {24 gprint (GP_ERR, "ERROR: do not mix -fits and -format\n");25 free (format);26 return (FALSE);27 }28 38 remove_argument (N, &argc, argv); 29 39 FITS = strcreate (argv[N]); … … 61 71 62 72 if (argc < 3) { 63 gprint (GP_ERR, "USAGE: write [-append] [-f \"format\"] file vector vector ...\n"); 73 gprint (GP_ERR, "USAGE: write [options] file vector vector ...\n"); 74 gprint (GP_ERR, "OPTIONS: [-header] [-append] [-f \"format\"] [-fits NAME] [-csv] [-h,--help]\n"); 64 75 return (FALSE); 65 76 } … … 222 233 return (TRUE); 223 234 235 usage: 236 gprint (GP_ERR, "USAGE: write [options] file vector vector ...\n"); 237 gprint (GP_ERR, "OPTIONS: [-header] [-append] [-f \"format\"] [-fits NAME] [-csv] [-h,--help]\n\n"); 238 239 gprint (GP_ERR, "OPTIONS: \n"); 240 gprint (GP_ERR, " -header : add a descriptive header line to ascii or csv output\n"); 241 gprint (GP_ERR, " -append : write to the end of the existing file\n"); 242 gprint (GP_ERR, " -fits NAME : write a fits table (extention name is NAME, column names match vector names)\n"); 243 gprint (GP_ERR, " -csv : write a comma-separated values file (eg, to read in excel)\n"); 244 gprint (GP_ERR, " -f \"format\" : provide formatting codes for output:\n"); 245 gprint (GP_ERR, " ascii / csv : format consists of c-style format codes in form %NN.Md\n"); 246 gprint (GP_ERR, ", the following codes are allowed\n"); 247 gprint (GP_ERR, " %e -- double, %f -- float\n"); 248 gprint (GP_ERR, " %d -- int, %c -- char, %x -- hex int\n"); 249 gprint (GP_ERR, " FITS : format consists of the following FITS binary table format codes:\n"); 250 gprint (GP_ERR, " B : 1 byte int\n"); 251 gprint (GP_ERR, " I : 2 byte int\n"); 252 gprint (GP_ERR, " J : 4 byte int\n"); 253 gprint (GP_ERR, " K : 8 byte int\n"); 254 gprint (GP_ERR, " D : 4 byte float\n"); 255 gprint (GP_ERR, " F : 1 byte float\n"); 256 gprint (GP_ERR, " -h : this help listing\n"); 257 gprint (GP_ERR, " --h : this help listing\n"); 258 gprint (GP_ERR, " -help : this help listing\n"); 259 gprint (GP_ERR, " --help : this help listing\n"); 260 return FALSE; 224 261 } 225 262
Note:
See TracChangeset
for help on using the changeset viewer.
