Changeset 34584 for trunk/Ohana/src/opihi/cmd.data
- Timestamp:
- Oct 25, 2012, 10:26:16 AM (14 years ago)
- Location:
- trunk/Ohana/src/opihi/cmd.data
- Files:
-
- 2 deleted
- 8 edited
- 4 copied
-
Makefile (modified) (1 diff)
-
dbconnect.c (modified) (1 diff)
-
dbselect.c (modified) (1 diff)
-
grid.c (modified) (1 diff)
-
imspline_apply.c (copied) (copied from branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/imspline_apply.c )
-
imspline_construct.c (copied) (copied from branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/imspline_construct.c )
-
init.c (modified) (2 diffs)
-
plot.c (modified) (4 diffs)
-
spline.c (copied) (copied from branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/spline.c )
-
spline_apply.c (deleted)
-
spline_commands.c (copied) (copied from branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/spline_commands.c )
-
spline_construct.c (deleted)
-
write_vectors.c (modified) (1 diff)
-
zplot.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/Makefile
r33662 r34584 114 114 $(SRC)/shift.$(ARCH).o \ 115 115 $(SRC)/sort.$(ARCH).o \ 116 $(SRC)/spline_apply.$(ARCH).o \ 117 $(SRC)/spline_construct.$(ARCH).o \ 116 $(SRC)/spline.$(ARCH).o \ 117 $(SRC)/spline_commands.$(ARCH).o \ 118 $(SRC)/imspline_apply.$(ARCH).o \ 119 $(SRC)/imspline_construct.$(ARCH).o \ 118 120 $(SRC)/imstats.$(ARCH).o \ 119 121 $(SRC)/style.$(ARCH).o \ -
trunk/Ohana/src/opihi/cmd.data/dbconnect.c
r27435 r34584 33 33 password[i] = 0; 34 34 # endif 35 36 // XXX do I need to call mysql_library_init()? 35 37 36 38 mysql_init (&mysql); -
trunk/Ohana/src/opihi/cmd.data/dbselect.c
r20936 r34584 61 61 ALLOCATE (vec, Vector *, Ncols); 62 62 for (i = 0; i < Ncols; i++) { 63 char *name = fields[i].name ? fields[i].name : fields[i].org_name; 63 64 if ((vec[i] = SelectVector (fields[i].name, ANYVECTOR, TRUE)) == NULL) { 64 65 gprint (GP_ERR, "trouble creating vector named %s\n", fields[i].name); -
trunk/Ohana/src/opihi/cmd.data/grid.c
r26258 r34584 178 178 graphmode.ptype = 100; /* connect a pair */ 179 179 graphmode.etype = 0; 180 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);180 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 181 181 182 182 free (Xvec.elements.Flt); -
trunk/Ohana/src/opihi/cmd.data/init.c
r33662 r34584 102 102 int shift PROTO((int, char **)); 103 103 int sort_vectors PROTO((int, char **)); 104 int spline_apply_cmd PROTO((int, char **)); 105 int spline_construct_cmd PROTO((int, char **)); 104 int spline_command PROTO((int, char **)); 105 int imspline_apply PROTO((int, char **)); 106 int imspline_construct PROTO((int, char **)); 106 107 int stats PROTO((int, char **)); 107 108 int imstats PROTO((int, char **)); … … 254 255 {1, "shift", shift, "shift data in an image"}, 255 256 {1, "sort", sort_vectors, "sort list of vectors"}, 256 {1, "spline.apply", spline_apply_cmd, "apply spline fit to generate an image"}, 257 {1, "spline.const", spline_construct_cmd, "create spline 2nd deriv. terms"}, 257 {1, "spline", spline_command, "shift data in an image"}, 258 {1, "imspline.apply", imspline_apply, "apply spline fit to generate an image"}, 259 {1, "imspline.const", imspline_construct, "create spline 2nd deriv. terms"}, 258 260 {1, "stats", imstats, "statistics on a portion of an image"}, 259 261 {1, "style", style, "set the style for graph plots"}, -
trunk/Ohana/src/opihi/cmd.data/plot.c
r32346 r34584 3 3 int plot (int argc, char **argv) { 4 4 5 int kapa, N, Npts; 5 char *out; 6 int kapa, N, Npts, valid, size, i; 6 7 Graphdata graphmode; 7 8 Vector *xvec, *yvec, *dxmvec, *dxpvec, *dymvec, *dypvec; … … 32 33 } 33 34 34 if (argc != 3) { 35 valid = (argc == 3); 36 valid |= (argc > 4) && !strcmp (argv[3], "where"); 37 if (!valid) { 35 38 gprint (GP_ERR, "USAGE: plot <x> <y> [style]\n"); 39 gprint (GP_ERR, " OR: plot <x> <y> [style] where (condition)\n"); 36 40 return (FALSE); 41 } 42 43 // tvec is used for logical test (truth vector) 44 Vector *tvec = NULL; 45 char *mask = NULL; 46 if (argc > 4) { 47 out = dvomath (argc - 4, &argv[4], &size, 1); 48 if (out == NULL) { 49 print_error (); 50 return FALSE; 51 } 52 if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) { 53 gprint (GP_ERR, " invalid logic result\n"); 54 DeleteNamedVector (out); 55 free (out); 56 return (FALSE); 57 } 37 58 } 38 59 … … 53 74 return (FALSE); 54 75 } 76 if (tvec && tvec[0].Nelements != yvec[0].Nelements) { 77 gprint (GP_ERR, "logic test vector not the same length as data vectors\n"); 78 return (FALSE); 79 } 55 80 if (dypvec && (dypvec->Nelements != xvec->Nelements)) goto mismatch; 56 81 if (dymvec && (dymvec->Nelements != xvec->Nelements)) goto mismatch; … … 59 84 60 85 Npts = xvec[0].Nelements; 61 if (Npts == 0) return (TRUE); 86 if (Npts == 0) { 87 if (tvec) DeleteVector (tvec); 88 return (TRUE); 89 } 90 91 if (tvec) { 92 Npts = 0; 93 ALLOCATE (mask, char, tvec->Nelements); 94 for (i = 0; i < tvec->Nelements; i++) { 95 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0); 96 if (!mask[i]) Npts ++; 97 } 98 if (Npts == 0) { 99 DeleteVector (tvec); 100 free (mask); 101 return TRUE; 102 } 103 } 62 104 63 105 if (!KapaPrepPlot (kapa, Npts, &graphmode)) return (FALSE); 64 106 65 PlotVectorSingle (kapa, xvec, "x");66 PlotVectorSingle (kapa, yvec, "y");107 PlotVectorSingle (kapa, xvec, mask, "x"); 108 PlotVectorSingle (kapa, yvec, mask, "y"); 67 109 if (graphmode.etype & 0x01) { 68 PlotVectorSingle (kapa, dymvec, "dym");69 PlotVectorSingle (kapa, dypvec, "dyp");110 PlotVectorSingle (kapa, dymvec, mask, "dym"); 111 PlotVectorSingle (kapa, dypvec, mask, "dyp"); 70 112 } 71 113 if (graphmode.etype & 0x02) { 72 PlotVectorSingle (kapa, dxmvec, "dxm"); 73 PlotVectorSingle (kapa, dxpvec, "dxp"); 114 PlotVectorSingle (kapa, dxmvec, mask, "dxm"); 115 PlotVectorSingle (kapa, dxpvec, mask, "dxp"); 116 } 117 118 if (tvec) { 119 free (mask); 120 DeleteVector (tvec); 74 121 } 75 122 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/write_vectors.c
r33963 r34584 99 99 } 100 100 101 /* open file for out uput */101 /* open file for output */ 102 102 if (append) { 103 103 f = fopen (argv[1], "a"); -
trunk/Ohana/src/opihi/cmd.data/zplot.c
r31667 r34584 3 3 int zplot (int argc, char **argv) { 4 4 5 int i, kapa; 5 char *outname; 6 int i, kapa, valid, size; 6 7 opihi_flt *out; 7 8 double min, range; … … 11 12 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 12 13 13 if (argc != 6) { 14 valid = (argc == 6); 15 valid |= (argc > 7) && !strcmp (argv[6], "where"); 16 if (!valid) { 14 17 gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n"); 18 gprint (GP_ERR, " OR: zplot <x> <y> <z> min max where (condition)\n"); 15 19 return (FALSE); 16 20 } … … 18 22 min = atof(argv[4]); 19 23 range = atof(argv[5]) - min; 24 25 // tvec is used for logical test (truth vector) 26 Vector *tvec = NULL; 27 char *mask = NULL; 28 if (argc > 7) { 29 outname = dvomath (argc - 7, &argv[7], &size, 1); 30 if (outname == NULL) { 31 print_error (); 32 return FALSE; 33 } 34 if ((tvec = SelectVector (outname, OLDVECTOR, TRUE)) == NULL) { 35 gprint (GP_ERR, " invalid logic result\n"); 36 DeleteNamedVector (outname); 37 free (outname); 38 return (FALSE); 39 } 40 } 20 41 21 42 /* find vectors */ … … 29 50 if (xvec[0].Nelements != zvec[0].Nelements) { 30 51 gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]); 52 return (FALSE); 53 } 54 if (tvec && tvec[0].Nelements != yvec[0].Nelements) { 55 gprint (GP_ERR, "logic test vector not the same length as data vectors\n"); 31 56 return (FALSE); 32 57 } … … 46 71 } 47 72 73 if (tvec) { 74 ALLOCATE (mask, char, tvec->Nelements); 75 for (i = 0; i < tvec->Nelements; i++) { 76 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0); 77 } 78 } 79 48 80 /* point size determined by Zvec */ 49 81 graphmode.style = 2; /* plot points */ 50 82 graphmode.size = -1; /* point size determined by Zvec */ 51 83 graphmode.etype = 0; /* no errorbars */ 52 PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);84 PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode); 53 85 54 86 free (Zvec.elements.Ptr); 87 if (mask) free (mask); 88 DeleteNamedVector (outname); 55 89 56 90 return (TRUE); … … 60 94 int zcplot (int argc, char **argv) { 61 95 62 int i, kapa; 96 char *outname; 97 int i, kapa, valid, size; 63 98 opihi_flt *out; 64 99 double min, range; … … 68 103 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 69 104 70 if (argc != 6) { 71 gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n"); 105 valid = (argc == 6); 106 valid |= (argc > 7) && !strcmp (argv[6], "where"); 107 if (!valid) { 108 gprint (GP_ERR, "USAGE: zcplot <x> <y> <z> min max\n"); 109 gprint (GP_ERR, " OR: zcplot <x> <y> <z> min max where (condition)\n"); 72 110 return (FALSE); 73 111 } … … 75 113 min = atof(argv[4]); 76 114 range = atof(argv[5]) - min; 115 116 // tvec is used for logical test (truth vector) 117 Vector *tvec = NULL; 118 char *mask = NULL; 119 if (argc > 7) { 120 outname = dvomath (argc - 7, &argv[7], &size, 1); 121 if (outname == NULL) { 122 print_error (); 123 return FALSE; 124 } 125 if ((tvec = SelectVector (outname, OLDVECTOR, TRUE)) == NULL) { 126 gprint (GP_ERR, " invalid logic result\n"); 127 DeleteNamedVector (outname); 128 free (outname); 129 return (FALSE); 130 } 131 } 77 132 78 133 /* find vectors */ … … 86 141 if (xvec[0].Nelements != zvec[0].Nelements) { 87 142 gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]); 143 return (FALSE); 144 } 145 if (tvec && tvec[0].Nelements != yvec[0].Nelements) { 146 gprint (GP_ERR, "logic test vector not the same length as data vectors\n"); 88 147 return (FALSE); 89 148 } … … 103 162 } 104 163 164 if (tvec) { 165 ALLOCATE (mask, char, tvec->Nelements); 166 for (i = 0; i < tvec->Nelements; i++) { 167 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0); 168 } 169 } 170 105 171 /* point size determined by Zvec */ 106 172 graphmode.style = 2; /* plot points */ 107 173 graphmode.color = -1; /* point color determined by Zvec */ 108 174 graphmode.etype = 0; /* no errorbars */ 109 PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);175 PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode); 110 176 111 177 free (Zvec.elements.Ptr); 178 if (mask) free (mask); 179 DeleteNamedVector (outname); 112 180 113 181 return (TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
