Changeset 30631 for branches/czw_branch/20101203/Ohana/src/opihi
- Timestamp:
- Feb 14, 2011, 1:05:28 PM (15 years ago)
- Location:
- branches/czw_branch/20101203
- Files:
-
- 29 edited
- 3 copied
-
. (modified) (1 prop)
-
Ohana/src/opihi/cmd.astro/cgrid.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/region.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.astro/test (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/test )
-
Ohana/src/opihi/cmd.astro/test/region.sh (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/test/region.sh )
-
Ohana/src/opihi/cmd.data/limits.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/match2d.c (modified) (6 diffs)
-
Ohana/src/opihi/cmd.data/reindex.c (modified) (3 diffs)
-
Ohana/src/opihi/cmd.data/subset.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/vstats.c (modified) (8 diffs)
-
Ohana/src/opihi/cmd.data/write_vectors.c (modified) (1 diff)
-
Ohana/src/opihi/doc/image-graph-overlay.txt (copied) (copied from trunk/Ohana/src/opihi/doc/image-graph-overlay.txt )
-
Ohana/src/opihi/dvo/avextract.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/dbExtractImages.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/dbExtractMeasures.c (modified) (3 diffs)
-
Ohana/src/opihi/dvo/dbFields.c (modified) (4 diffs)
-
Ohana/src/opihi/dvo/gimages.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/gstar.c (modified) (3 diffs)
-
Ohana/src/opihi/dvo/images.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/imextract.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/imphot.c (modified) (4 diffs)
-
Ohana/src/opihi/dvo/mextract.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/mmextract.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/photometry.c (modified) (3 diffs)
-
Ohana/src/opihi/dvo/skycat.c (modified) (2 diffs)
-
Ohana/src/opihi/include/dvoshell.h (modified) (3 diffs)
-
Ohana/src/opihi/include/shell.h (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/VectorOps.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/command.c (modified) (5 diffs)
-
Ohana/src/opihi/lib.shell/expand_vars.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/parse.c (modified) (10 diffs)
-
Ohana/src/opihi/lib.shell/stack_math.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20101203
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/Ohana/src/opihi/cmd.astro/cgrid.c
r29001 r30631 98 98 99 99 if (argc != 1) { 100 gprint (GP_ERR, "USAGE: cgrid [style] \n");100 gprint (GP_ERR, "USAGE: cgrid [style] [-ra-by-hour] [-labels]\n"); 101 101 return (FALSE); 102 102 } -
branches/czw_branch/20101203/Ohana/src/opihi/cmd.astro/region.c
r30118 r30631 18 18 FREE (name); 19 19 20 NoClear = FALSE; 21 if ((N = get_argument (argc, argv, "-no-clear"))) { 22 remove_argument (N, &argc, argv); 23 NoClear = TRUE; 24 } 25 20 26 if ((N = get_argument (argc, argv, "-image"))) { 21 27 remove_argument (N, &argc, argv); 22 28 KapaGetImageCoords (kapa, &graphmode.coords); 23 29 KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin); 30 31 set_variable ("XMIN", graphmode.xmin); 32 set_variable ("XMAX", graphmode.xmax); 33 set_variable ("YMIN", graphmode.ymin); 34 set_variable ("YMAX", graphmode.ymax); 35 36 set_variable ("RMIN", Ra + graphmode.xmin); 37 set_variable ("RMAX", Ra + graphmode.xmax); 38 set_variable ("DMIN", Dec + graphmode.ymin); 39 set_variable ("DMAX", Dec + graphmode.ymax); 40 41 // if (!NoClear) KapaClearSections (kapa); 42 KapaSetLimits (kapa, &graphmode); 43 24 44 SetGraph (&graphmode); 25 45 return (TRUE); … … 45 65 remove_argument (N, &argc, argv); 46 66 graphmode.flipnorth = FALSE; 47 }48 49 NoClear = FALSE;50 if ((N = get_argument (argc, argv, "-no-clear"))) {51 remove_argument (N, &argc, argv);52 NoClear = TRUE;53 67 } 54 68 -
branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/limits.c
r29540 r30631 26 26 27 27 // XXX need an option to set the limits based on the current image bounds 28 if ((N = get_argument (argc, argv, "-image"))) { 29 remove_argument (N, &argc, argv); 30 KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin); 31 32 set_variable ("XMIN", graphmode.xmin); 33 set_variable ("XMAX", graphmode.xmax); 34 set_variable ("YMIN", graphmode.ymin); 35 set_variable ("YMAX", graphmode.ymax); 36 37 // if (!NoClear) KapaClearSections (kapa); 38 SetGraph (&graphmode); 39 KapaSetLimits (kapa, &graphmode); 40 return (TRUE); 41 // Set Region based on image 42 } 28 43 29 44 if (argc == 1) { -
branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/match2d.c
r27817 r30631 1 1 # include "data.h" 2 2 3 int find_matches2d (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index1, Vector *index2); 4 int find_matches2d_closest (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index); 3 5 4 6 // match2d (X1) (Y1) (X2) (Y2) (Radius) [-index1 (index1)] [-index2 (index2)] [-nomatch1 nomatch1] [-nomatch2 nomatch2] … … 6 8 int match2d (int argc, char **argv) { 7 9 8 int N ;10 int N, CLOSEST; 9 11 double Radius; 10 12 char *endptr; … … 12 14 Vector *index1, *index2; 13 15 16 CLOSEST = FALSE; 17 if ((N = get_argument (argc, argv, "-closest"))) { 18 remove_argument (N, &argc, argv); 19 CLOSEST = TRUE; 20 } 21 14 22 if ((N = get_argument (argc, argv, "-index1"))) { 15 23 remove_argument (N, &argc, argv); … … 30 38 if (argc != 6) { 31 39 gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n"); 32 // gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n"); 33 // gprint (GP_ERR, " if -closest is provided, index1 & index2 will have the same length as X1 and X2 (respectively)\n"); 34 // gprint (GP_ERR, " with either the index of the match or a value of -1 for non-matches\n"); 35 return (FALSE); 36 } 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"); 42 return (FALSE); 43 } 44 45 /* 46 we have two modes of operation: 47 48 without -closest, we are finding all matched pairs within the match radius. in this 49 case, the two index vectors have the same length, one entry per matched pair. 50 x1[index1],y1[index1] matches to x2[index2],y2[index2]. 51 52 with -closest selected, we are finding the closest element of set 1 to each of set 2 53 and vice versa. in this case, index1 is always the same length as x1,y1, while index2 54 is the same lengths as x2,y2. x2[index1],y2[index1] matches x1,y1 while 55 x1[index2],y1[index2] matches x2,y2 56 57 */ 37 58 38 59 if ((X1vec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); … … 61 82 } 62 83 63 find_matches2d (X1vec, Y1vec, X2vec, Y2vec, Radius, index1, index2); 84 if (CLOSEST) { 85 find_matches2d_closest (X1vec, Y1vec, X2vec, Y2vec, Radius, index1); 86 find_matches2d_closest (X2vec, Y2vec, X1vec, Y1vec, Radius, index2); 87 } else { 88 find_matches2d (X1vec, Y1vec, X2vec, Y2vec, Radius, index1, index2); 89 } 64 90 65 91 return (TRUE); … … 132 158 return (TRUE); 133 159 } 160 161 // find the elements of X2,Y2 which are closest to each element of X1,Y1 (-1 if no match) 162 int find_matches2d_closest (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index) { 163 164 off_t i, j, Jmin, Ji, I, J, *N1, *N2, NMATCH; 165 double dX, dY, dR, Radius2, Rmin; 166 167 NMATCH = X1->Nelements; 168 ResetVector (index, OPIHI_INT, NMATCH); 169 170 ALLOCATE (N1, off_t, X1->Nelements); 171 ALLOCATE (N2, off_t, X2->Nelements); 172 173 for (i = 0; i < X1->Nelements; i++) { N1[i] = i; } 174 for (i = 0; i < X2->Nelements; i++) { N2[i] = i; } 175 176 sort_coords_indexonly (X1->elements.Flt, Y1->elements.Flt, N1, X1->Nelements); 177 sort_coords_indexonly (X2->elements.Flt, Y2->elements.Flt, N2, X2->Nelements); 178 179 Radius2 = Radius*Radius; 180 181 // find the closest entry in list 2 to the current entry in list 1: 182 for (i = j = 0; (i < X1->Nelements) && (j < X2->Nelements);) { 183 I = N1[i]; 184 J = N2[j]; 185 186 dX = X1->elements.Flt[I] - X2->elements.Flt[J]; 187 188 if (dX <= -1.02*Radius) { 189 // no match in list 2 to this entry 190 index->elements.Int[I] = -1; 191 i++; 192 continue; 193 } 194 if (dX >= +1.02*Radius) { j++; continue; } 195 196 // look for closest matches of list2() to list1(i) 197 Jmin = -1; 198 Rmin = Radius2; 199 for (Ji = j; (dX > -1.02*Radius) && (Ji < X2->Nelements); Ji++) { 200 J = N2[Ji]; 201 dX = X1->elements.Flt[I] - X2->elements.Flt[J]; 202 dY = Y1->elements.Flt[I] - Y2->elements.Flt[J]; 203 dR = dX*dX + dY*dY; 204 if (dR > Radius2) continue; 205 if (dR < Rmin) { 206 Rmin = dR; 207 Jmin = J; 208 } 209 } 210 211 // no match in list 2 to this entry 212 if (Jmin == -1) { 213 index->elements.Int[I] = -1; 214 i++; 215 continue; 216 } 217 index->elements.Int[I] = Jmin; 218 i++; 219 } 220 index->Nelements = NMATCH; 221 222 free (N1); 223 free (N2); 224 225 return (TRUE); 226 } -
branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/reindex.c
r29540 r30631 5 5 int reindex (int argc, char **argv) { 6 6 7 int i, Npts, Nmax , valid;7 int i, Npts, Nmax; 8 8 Vector *ivec, *ovec, *xvec; 9 9 … … 11 11 Npts = 0; 12 12 13 valid = TRUE; 14 valid &= (argc >= 6); 15 valid &= !strcmp(argv[2], "="); 16 valid &= !strcmp(argv[4], "using"); 17 if (!valid) { 18 gprint (GP_ERR, "USAGE: reindex (out) = (in) using (index)\n"); 19 gprint (GP_ERR, " creates a new vectors (out) from (in) based on sequence in (index)\n"); 20 return (FALSE); 21 } 13 if (argc != 6) goto usage; 14 if (strcmp(argv[2], "=")) goto usage; 15 if (strcmp(argv[4], "using")) goto usage; 22 16 23 17 if ((ovec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto error; … … 63 57 DeleteVector (ovec); 64 58 return (FALSE); 59 60 usage: 61 gprint (GP_ERR, "USAGE: reindex (out) = (in) using (index)\n"); 62 gprint (GP_ERR, " creates a new vectors (out) from (in) based on sequence in (index)\n"); 63 return (FALSE); 65 64 } 66 65 -
branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/subset.c
r27491 r30631 34 34 35 35 // ovec matches ivec in type 36 ResetVector (ovec, ivec->type, MAX (tvec[0].Nelements, 1));36 ResetVector (ovec, ivec->type, tvec[0].Nelements); 37 37 38 38 // we have four cases: (ivec == flt or int) and (tvec == flt or int) … … 75 75 76 76 // free up unused memory 77 ResetVector (ovec, ivec->type, MAX (Npts, 1));77 ResetVector (ovec, ivec->type, Npts); 78 78 79 79 DeleteVector (tvec); -
branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/vstats.c
r21508 r30631 3 3 int vstats (int argc, char **argv) { 4 4 5 int i, N;6 double max, min, sum, var, dvar, mean, stdev;7 float IgnoreValue ;5 int i, iter, N, Nbin, Niter; 6 double max, min, pmin, pmax, sum, var, dvar, mean, stdev; 7 float IgnoreValue, Nsigma; 8 8 int Ignore, Quiet; 9 9 10 int *Nval, bin, Nmode, Nmed ;11 double dx, mode, median ;10 int *Nval, bin, Nmode, Nmed, Nused; 11 double dx, mode, median, threshold; 12 12 Vector *vec; 13 char *mask = NULL; 13 14 14 15 IgnoreValue = 0; … … 21 22 } 22 23 24 Niter = 1; 25 Nsigma = 3.0; 26 27 if ((N = get_argument (argc, argv, "-sigma-clip"))) { 28 remove_argument (N, &argc, argv); 29 Nsigma = atof(argv[N]); 30 Niter = 3; 31 remove_argument (N, &argc, argv); 32 } 33 34 if ((N = get_argument (argc, argv, "-iter"))) { 35 remove_argument (N, &argc, argv); 36 Niter = atoi(argv[N]); 37 remove_argument (N, &argc, argv); 38 } 39 23 40 Quiet = FALSE; 24 41 if ((N = get_argument (argc, argv, "-q"))) { … … 32 49 33 50 if (argc != 2) { 34 gprint (GP_ERR, "USAGE: vstat (vector)\n"); 51 gprint (GP_ERR, "USAGE: vstat (vector) [-ignore value] [-q] [-quiet] [-iter Niter] [-sigma-clip Nsigma]\n"); 52 gprint (GP_ERR, " default is 1 iteration without sigma clipping or 3 with sigma clipping\n"); 35 53 return (FALSE); 36 54 } … … 39 57 40 58 /* we need two passes, one for max, min, mean, sum, one for median, stdev, etc */ 59 60 // set a good / bad mask 61 ALLOCATE (mask, char, vec[0].Nelements); 62 if (vec[0].type == OPIHI_FLT) { 63 opihi_flt *X = vec[0].elements.Flt; 64 for (i = 0; i < vec[0].Nelements; i++, X++) { 65 mask[i] = 1; 66 if (!finite (*X)) continue; 67 if (Ignore && (*X == IgnoreValue)) continue; 68 mask[i] = 0; 69 } 70 } else { 71 opihi_int *X = vec[0].elements.Int; 72 for (i = 0; i < vec[0].Nelements; i++, X++) { 73 mask[i] = 1; 74 if (!finite (*X)) continue; 75 if (Ignore && (*X == IgnoreValue)) continue; 76 mask[i] = 0; 77 } 78 } 41 79 42 80 /* calculate max, min, mean, sum, npix */ … … 47 85 opihi_flt *X = vec[0].elements.Flt; 48 86 for (i = 0; i < vec[0].Nelements; i++, X++) { 49 if (!finite (*X)) continue; 50 if (Ignore && (*X == IgnoreValue)) continue; 87 if (mask[i]) continue; 51 88 max = MAX (*X, max); 52 89 min = MIN (*X, min); … … 57 94 opihi_int *X = vec[0].elements.Int; 58 95 for (i = 0; i < vec[0].Nelements; i++, X++) { 59 if (!finite (*X)) continue; 60 if (Ignore && (*X == IgnoreValue)) continue; 96 if (mask[i]) continue; 61 97 max = MAX (*X, max); 62 98 min = MIN (*X, min); … … 67 103 mean = sum / N; 68 104 69 /* calculate median and mode with resolution of (max - min) / 1000 */ 70 dx = (max - min) / 1000; 71 if (dx == 0) { 72 median = mode = min; 73 stdev = 0.0; 74 goto skip; 75 } 76 77 ALLOCATE (Nval, int, 1002); 78 bzero (Nval, 1000*sizeof(int)); 79 var = 0; 80 if (vec[0].type == OPIHI_FLT) { 81 opihi_flt *X = vec[0].elements.Flt; 82 for (i = 0; i < vec[0].Nelements; i++, X++) { 83 if (!finite (*X)) continue; 84 if (Ignore && (*X == IgnoreValue)) continue; 85 bin = MAX (0, MIN (1000, (*X - min) / dx)); 86 Nval[bin] ++; 87 dvar = (*X - mean); 88 var += dvar*dvar; 89 } 90 } else { 91 opihi_int *X = vec[0].elements.Int; 92 for (i = 0; i < vec[0].Nelements; i++, X++) { 93 if (!finite (*X)) continue; 94 if (Ignore && (*X == IgnoreValue)) continue; 95 bin = MAX (0, MIN (1000, (*X - min) / dx)); 96 Nval[bin] ++; 97 dvar = (*X - mean); 98 var += dvar*dvar; 99 } 100 } 101 stdev = sqrt (var / N); 102 103 Nmode = 0; 104 mode = Nval[Nmode]; 105 median = 0; 106 Nmed = -1; 107 for (i = 0; i < 1001; i++) { 108 if (Nmed == -1) { 109 median += Nval[i]; 110 if (median >= N / 2.0) { 111 Nmed = i; 112 median = i * dx + min; 105 // we do Niter passes; on each pass, we exclude entries > Nsigma from the median 106 pmin = min; 107 pmax = max; 108 109 stdev = mode = median = Nused = 0.0; 110 111 for (iter = 0; iter < Niter; iter ++) { 112 113 // reduce Nbin after the first iteration? 114 Nbin = 1000; 115 116 /* calculate median and mode with resolution of (max - min) / 1000 */ 117 dx = (pmax - pmin) / Nbin; 118 if (dx == 0) { 119 median = mode = min; 120 stdev = 0.0; 121 goto skip; 122 } 123 124 ALLOCATE (Nval, int, Nbin + 2); 125 bzero (Nval, Nbin*sizeof(int)); 126 var = 0; 127 if (vec[0].type == OPIHI_FLT) { 128 opihi_flt *X = vec[0].elements.Flt; 129 for (i = 0; i < vec[0].Nelements; i++, X++) { 130 if (mask[i]) continue; 131 bin = MAX (0, MIN (Nbin, (*X - pmin) / dx)); 132 Nval[bin] ++; 133 dvar = (*X - mean); 134 var += dvar*dvar; 135 } 136 } else { 137 opihi_int *X = vec[0].elements.Int; 138 for (i = 0; i < vec[0].Nelements; i++, X++) { 139 if (mask[i]) continue; 140 bin = MAX (0, MIN (Nbin, (*X - pmin) / dx)); 141 Nval[bin] ++; 142 dvar = (*X - mean); 143 var += dvar*dvar; 144 } 145 } 146 stdev = sqrt (var / N); 147 148 Nmode = 0; 149 mode = Nval[Nmode]; 150 median = 0; 151 Nmed = -1; 152 for (i = 0; i < Nbin + 1; i++) { 153 if (Nmed == -1) { 154 median += Nval[i]; 155 if (median >= N / 2.0) { 156 Nmed = i; 157 median = i * dx + pmin; 158 } 113 159 } 114 } 115 if (mode < Nval[i]) { 116 Nmode = i; 117 mode = Nval[Nmode]; 118 } 119 } 120 mode = Nmode * dx + min; 121 free (Nval); 160 if (mode < Nval[i]) { 161 Nmode = i; 162 mode = Nval[Nmode]; 163 } 164 } 165 mode = Nmode * dx + pmin; 166 free (Nval); 167 168 threshold = Nsigma * stdev; 169 170 // we are going to do another pass: mark the entries to skip 171 pmin = max; 172 pmax = min; 173 if (iter < Niter - 1) { 174 if (vec[0].type == OPIHI_FLT) { 175 opihi_flt *X = vec[0].elements.Flt; 176 for (i = 0; i < vec[0].Nelements; i++, X++) { 177 if (mask[i]) continue; 178 if (fabs(*X - median) > threshold) { 179 mask[i] = 1; 180 } else { 181 pmin = MIN (*X, pmin); 182 pmax = MAX (*X, pmax); 183 } 184 } 185 } else { 186 opihi_int *X = vec[0].elements.Int; 187 for (i = 0; i < vec[0].Nelements; i++, X++) { 188 if (mask[i]) continue; 189 if (fabs(*X - median) > threshold) { 190 mask[i] = 1; 191 } else { 192 pmin = MIN (*X, pmin); 193 pmax = MAX (*X, pmax); 194 } 195 } 196 } 197 } 198 // gprint (GP_ERR, "iter %d, mean: %g, stdev: %g, min: %g, max: %g, median: %g, mode: %g, Npts: %d\n", 199 // iter, mean, stdev, min, max, median, mode, N); 200 } 201 202 Nused = 0; 203 for (i = 0; i < vec[0].Nelements; i++) { 204 if (mask[i]) continue; 205 Nused ++; 206 } 122 207 123 208 skip: 209 FREE(mask); 210 124 211 if (!Quiet) { 125 212 gprint (GP_ERR, "mean: %g, stdev: %g, min: %g, max: %g, median: %g, mode: %g, Npts: %d\n", 126 mean, stdev, min, max, median, mode, N); 127 } 128 213 mean, stdev, min, max, median, mode, N); 214 } 215 216 set_variable ("PMIN", pmin); 217 set_variable ("PMAX", pmax); 129 218 set_variable ("MIN", min); 130 219 set_variable ("MAX", max); … … 134 223 set_variable ("TOTAL", sum); 135 224 set_int_variable ("NPIX", N); 225 set_int_variable ("NPTS", N); 226 set_int_variable ("NUSED", Nused); 136 227 set_variable ("SIGMA", stdev); 137 228 return (TRUE); -
branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/write_vectors.c
r20936 r30631 140 140 if (fmttype[j] == 'd') { 141 141 if (vec[j][0].type == OPIHI_FLT) { 142 fprintf (f, fmtlist[j], ( int)(vec[j][0].elements.Flt[i]));142 fprintf (f, fmtlist[j], (opihi_int)(vec[j][0].elements.Flt[i])); 143 143 } else { 144 fprintf (f, fmtlist[j], ( int)(vec[j][0].elements.Int[i]));144 fprintf (f, fmtlist[j], (opihi_int)(vec[j][0].elements.Int[i])); 145 145 } 146 146 } 147 147 if (fmttype[j] == 'f') { 148 148 if (vec[j][0].type == OPIHI_FLT) { 149 fprintf (f, fmtlist[j], ( float)(vec[j][0].elements.Flt[i]));149 fprintf (f, fmtlist[j], (opihi_flt)(vec[j][0].elements.Flt[i])); 150 150 } else { 151 fprintf (f, fmtlist[j], ( float)(vec[j][0].elements.Int[i]));151 fprintf (f, fmtlist[j], (opihi_flt)(vec[j][0].elements.Int[i])); 152 152 } 153 153 } -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/avextract.c
r28241 r30631 44 44 45 45 // parse skyregion options 46 if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape; 46 if ((selection = SetRegionSelection (&argc, argv)) == NULL) { 47 print_error(); 48 goto escape; 49 } 47 50 48 51 // command-line is of the form: avextract field,field, field [where (field op value)...] … … 68 71 // construct the db Boolean math stack (frees cstack) 69 72 stack = dbRPN (Ncstack, cstack, &Nstack); 73 if (Ncstack && !Nstack) { 74 print_error(); 75 goto escape; 76 } 70 77 71 78 // add the skyregion limits to the where statement (or create) -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/dbExtractImages.c
r27587 r30631 241 241 242 242 case IMAGE_NCAL: 243 value.Int = image[N]. Mxxxx;243 value.Int = image[N].nFitPhotom; 244 244 break; 245 245 case IMAGE_SKY: 246 value.Flt = image[N].Myyyy + 0x8000;246 value.Flt = NAN; 247 247 break; 248 248 case IMAGE_FLAGS: … … 299 299 value.Flt = (field->ID == IMAGE_X_UR_FP) ? x : y; 300 300 break; 301 302 case IMAGE_X_ERR_SYS: 303 value.Flt = image[N].dXpixSys; 304 break; 305 case IMAGE_Y_ERR_SYS: 306 value.Flt = image[N].dXpixSys; 307 break; 308 case IMAGE_MAG_ERR_SYS: 309 value.Flt = image[N].dMagSys; 310 break; 311 312 case IMAGE_NFIT_PHOTOM: 313 value.Int = image[N].nFitPhotom; 314 break; 315 case IMAGE_NFIT_ASTROM: 316 value.Int = image[N].nFitAstrom; 317 break; 318 case IMAGE_NLINK_PHOTOM: 319 value.Int = image[N].nLinkPhotom; 320 break; 321 case IMAGE_NLINK_ASTROM: 322 value.Int = image[N].nLinkAstrom; 323 break; 301 324 } 302 325 return (value); -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/dbExtractMeasures.c
r28955 r30631 320 320 break; 321 321 case MEAS_FWHM: /* OK */ 322 value.Flt = 0.01*(measure[0].FWx + measure[0].FWy) / 2.0;322 value.Flt = FromShortPixels(measure[0].FWx + measure[0].FWy) / 2.0; 323 323 break; 324 324 case MEAS_FWHM_MAJ: /* OK */ 325 value.Flt = 0.01*measure[0].FWx;325 value.Flt = FromShortPixels(measure[0].FWx); 326 326 break; 327 327 case MEAS_FWHM_MIN: /* OK */ 328 value.Flt = 0.01*measure[0].FWy;328 value.Flt = FromShortPixels(measure[0].FWy); 329 329 break; 330 330 case MEAS_THETA: /* OK */ 331 value.Flt = measure[0].theta;331 value.Flt = FromShortDegrees(measure[0].theta); 332 332 break; 333 333 case MEAS_MXX: /* OK */ 334 value.Flt = measure[0].Mxx;334 value.Flt = FromShortPixels(measure[0].Mxx); 335 335 break; 336 336 case MEAS_MXY: /* OK */ 337 value.Flt = measure[0].Mxy;337 value.Flt = FromShortPixels(measure[0].Mxy); 338 338 break; 339 339 case MEAS_MYY: /* OK */ 340 value.Flt = measure[0].Myy;340 value.Flt = FromShortPixels(measure[0].Myy); 341 341 break; 342 342 case MEAS_DOPHOT: /* OK */ … … 382 382 break; 383 383 case MEAS_XCCD_ERR: /* OK */ 384 value.Flt = measure[0].dXccd / 100.0;384 value.Flt = FromShortPixels(measure[0].dXccd); 385 385 break; 386 386 case MEAS_YCCD_ERR: /* OK */ 387 value.Flt = measure[0].dYccd / 100.0; 387 value.Flt = FromShortPixels(measure[0].dYccd); 388 break; 389 case MEAS_POS_SYS_ERR: /* OK */ 390 value.Flt = FromShortPixels(measure[0].dRsys); 388 391 break; 389 392 case MEAS_XMOSAIC: /* OK */ … … 425 428 value.Flt = measure[0].psfQual; 426 429 break; 430 case MEAS_PSF_QF_PERFECT: /* OK */ 431 value.Flt = NAN; 432 break; 427 433 case MEAS_PSF_CHISQ: /* OK */ 428 434 value.Flt = measure[0].psfChisq; -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/dbFields.c
r28955 r30631 194 194 if (!strcasecmp (fieldName, "XCCD:ERR")) ESCAPE (MEAS_XCCD_ERR, MAG_NONE, OPIHI_FLT); 195 195 if (!strcasecmp (fieldName, "YCCD:ERR")) ESCAPE (MEAS_YCCD_ERR, MAG_NONE, OPIHI_FLT); 196 if (!strcasecmp (fieldName, "POS_SYS_ERR")) ESCAPE (MEAS_POS_SYS_ERR, MAG_NONE, OPIHI_FLT); 196 197 if (!strcasecmp (fieldName, "XMOSAIC")) ESCAPE (MEAS_XMOSAIC, MAG_NONE, OPIHI_FLT); 197 198 if (!strcasecmp (fieldName, "YMOSAIC")) ESCAPE (MEAS_YMOSAIC, MAG_NONE, OPIHI_FLT); … … 205 206 if (!strcasecmp (fieldName, "IMAGEID")) ESCAPE (MEAS_IMAGE_ID, MAG_NONE, OPIHI_INT); 206 207 if (!strcasecmp (fieldName, "PSF_QF")) ESCAPE (MEAS_PSF_QF, MAG_NONE, OPIHI_FLT); 208 if (!strcasecmp (fieldName, "PSF_QF_PERFECT")) ESCAPE (MEAS_PSF_QF_PERFECT, MAG_NONE, OPIHI_FLT); 207 209 if (!strcasecmp (fieldName, "PSF_CHISQ")) ESCAPE (MEAS_PSF_CHISQ, MAG_NONE, OPIHI_FLT); 208 210 if (!strcasecmp (fieldName, "PSF_NDOF")) ESCAPE (MEAS_PSF_NDOF, MAG_NONE, OPIHI_INT); … … 398 400 if (!strcasecmp (fieldName, "trate" )) ESCAPE (IMAGE_TRATE, MAG_NONE, OPIHI_FLT); 399 401 400 // XXX : these are mapped to ridiculous things: Myyyy + 0x8000 and Mxxxx401 402 if (!strcasecmp (fieldName, "ncal" )) ESCAPE (IMAGE_NCAL, MAG_NONE, OPIHI_INT); 402 if (!strcasecmp (fieldName, "sky" )) ESCAPE (IMAGE_SKY, MAG_NONE, OPIHI_FLT); 403 if (!strcasecmp (fieldName, "sky" )) ESCAPE (IMAGE_SKY, MAG_NONE, OPIHI_FLT); // deprecated for now 403 404 404 405 if (!strcasecmp (fieldName, "imflags" )) ESCAPE (IMAGE_FLAGS, MAG_NONE, OPIHI_INT); … … 427 428 if (!strcasecmp (fieldName, "Y_UR_FP" )) ESCAPE (IMAGE_Y_UR_FP, MAG_NONE, OPIHI_FLT); 428 429 430 if (!strcasecmp (fieldName, "dX_SYS" )) ESCAPE (IMAGE_X_ERR_SYS, MAG_NONE, OPIHI_FLT); 431 if (!strcasecmp (fieldName, "dY_SYS" )) ESCAPE (IMAGE_Y_ERR_SYS, MAG_NONE, OPIHI_FLT); 432 if (!strcasecmp (fieldName, "dM_SYS" )) ESCAPE (IMAGE_MAG_ERR_SYS,MAG_NONE, OPIHI_FLT); 433 if (!strcasecmp (fieldName, "NFIT_PHOTOM")) ESCAPE (IMAGE_NFIT_PHOTOM,MAG_NONE, OPIHI_INT); 434 if (!strcasecmp (fieldName, "NFIT_ASTROM")) ESCAPE (IMAGE_NFIT_ASTROM,MAG_NONE, OPIHI_INT); 435 if (!strcasecmp (fieldName, "NLINK_PHOTOM")) ESCAPE (IMAGE_NLINK_PHOTOM,MAG_NONE, OPIHI_INT); 436 if (!strcasecmp (fieldName, "NLINK_ASTROM")) ESCAPE (IMAGE_NLINK_ASTROM,MAG_NONE, OPIHI_INT); 437 429 438 // for words that don't parse, try a photcode 430 439 gprint (GP_ERR, "unknown field '%s' for image table in DVO database\n", fieldName); -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/gimages.c
r28958 r30631 201 201 } 202 202 203 /*** XXX we need to re-introduce the use of applyMcal 204 Mcal = applyMcal (&image[i], 2048.0, 2048.0); 205 ***/ 203 // XXX Mcal = applyMcal (&image[i], 2048.0, 2048.0); 206 204 207 205 got_spot: -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/gstar.c
r28326 r30631 222 222 gprint (GP_LOG, "%5d ", catalog.measure[m].photcode); 223 223 gprint (GP_LOG, "%-20s ", GetPhotcodeNamebyCode (catalog.measure[m].photcode)); 224 gprint (GP_LOG, "%5.2f ", 0.01*catalog.measure[m].FWx);225 gprint (GP_LOG, "%5.2f ", 0.01*catalog.measure[m].FWy);224 gprint (GP_LOG, "%5.2f ", FromShortPixels(catalog.measure[m].FWx)); 225 gprint (GP_LOG, "%5.2f ", FromShortPixels(catalog.measure[m].FWy)); 226 226 227 227 if (FULL_OUTPUT) { … … 233 233 gprint (GP_LOG, "%f ", catalog.measure[m].Xccd); 234 234 gprint (GP_LOG, "%f ", catalog.measure[m].Yccd); 235 gprint (GP_LOG, "% d ", catalog.measure[m].dXccd);236 gprint (GP_LOG, "% d ", catalog.measure[m].dYccd);235 gprint (GP_LOG, "%f ", FromShortPixels(catalog.measure[m].dXccd)); 236 gprint (GP_LOG, "%f ", FromShortPixels(catalog.measure[m].dYccd)); 237 237 gprint (GP_LOG, "%f ", catalog.measure[m].Sky); 238 238 gprint (GP_LOG, "%f ", catalog.measure[m].dSky); … … 244 244 gprint (GP_LOG, "%f ", catalog.measure[m].crNsigma); 245 245 gprint (GP_LOG, "%f ", catalog.measure[m].extNsigma); 246 gprint (GP_LOG, "%f ", (360.0/(float)0xffff)*catalog.measure[m].theta);246 gprint (GP_LOG, "%f ", FromShortDegrees(catalog.measure[m].theta)); 247 247 } 248 248 gprint (GP_LOG, "\n"); -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/images.c
r30118 r30631 223 223 goto got_type; 224 224 } 225 // For 'TrianglePts' (TRI-), we are using the Mx,My, etc terms to save the coordinates 226 // this means triangular images cannot carry photometric zero-point variations 225 // For 'TrianglePts' (TRI-), we are absurdly overloaded values otherwise not used 227 226 if (typehash == TrianglePts) { 228 227 Npts = 3; 229 x[0] = image[ i].Mx; y[0] = image[i].My;230 x[1] = image[ i].Mxxx; y[1] = image[i].Mxyy;231 x[2] = image[ i].Mxxy; y[2] = image[i].Myyy;228 x[0] = image[0].dXpixSys; y[0] = image[0].dYpixSys; 229 x[1] = image[0].dMagSys; y[1] = image[0].nFitAstrom; 230 x[2] = image[0].photom_map_id; y[2] = image[0].astrom_map_id; 232 231 goto got_type; 233 232 } -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/imextract.c
r28958 r30631 62 62 // construct the db Boolean math stack (frees cstack) 63 63 stack = dbRPN (Ncstack, cstack, &Nstack); 64 if (Ncstack && !Nstack) { 65 print_error(); 66 goto escape; 67 } 64 68 65 69 // add the skyregion limits to the where statement (or create) -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/imphot.c
r29540 r30631 9 9 char bufname[64]; 10 10 float *p; 11 double fx, fy, x, y , applyMcal();11 double fx, fy, x, y; 12 12 Image *image; 13 13 Buffer *buf; … … 63 63 for (y = 0; y < 200; y+=1.0) { 64 64 for (x = 0; x < 100; x+=1.0, p++) { 65 *p = applyMcal (&image[subset[0]], (fx*x), (fy*y)); 65 // *p = applyMcal (&image[subset[0]], (fx*x), (fy*y)); 66 *p = image[subset[0]].Mcal; 66 67 } 67 68 } … … 70 71 for (j = 0; j < Nsubset; j++) { 71 72 i = subset[j]; 73 gprint (GP_ERR, "%s: %f\n", image[i].name, image[i].Mcal); 74 75 // XXX old code when we had the option of a 2D zero point model 76 # if (0) 72 77 switch (image[i].order) { 73 78 case 0: … … 90 95 break; 91 96 } 97 # endif 92 98 } 93 99 -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/mextract.c
r28955 r30631 68 68 // construct the db Boolean math stack (frees cstack) 69 69 stack = dbRPN (Ncstack, cstack, &Nstack); 70 if ( (Ncstack > 0) && (Nstack < 1)) {70 if (Ncstack && !Nstack) { 71 71 print_error (); 72 72 goto escape; -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/mmextract.c
r28241 r30631 106 106 // construct the db Boolean math stack (frees cstack) 107 107 stack1 = dbRPN (Ncstack1, cstack1, &Nstack1); 108 if ( (Ncstack1 > 0) && (Nstack1 < 1)) {108 if (Ncstack1 && !Nstack1) { 109 109 print_error (); 110 110 goto escape; … … 113 113 // construct the db Boolean math stack (frees cstack) 114 114 stack2 = dbRPN (Ncstack2, cstack2, &Nstack2); 115 if ( (Ncstack2 > 0) && (Nstack2 < 1)) {115 if (Ncstack2 && !Nstack2) { 116 116 print_error (); 117 117 goto escape; -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/photometry.c
r28955 r30631 778 778 } else { 779 779 780 if ( 0.01 * measure[0].FWx < 3.0) return (FALSE);781 if ( 0.01 * measure[0].FWx > 10.0) return (FALSE);780 if (FromShortPixels(measure[0].FWx < 3.0)) return (FALSE); 781 if (FromShortPixels(measure[0].FWx > 10.0)) return (FALSE); 782 782 783 783 return (TRUE); … … 810 810 Nm = 0; 811 811 for (i = 0; i < average[0].Nmeasure; i++) { 812 fwhm = measure[i].FWx / 100.0;812 fwhm = FromShortPixels(measure[i].FWx); 813 813 switch (FWHMsign) { 814 814 case 0: … … 1166 1166 break; 1167 1167 case MEAS_FWHM: /* OK */ 1168 value = 0.01*measure[0].FWx;1168 value = FromShortPixels(measure[0].FWx); 1169 1169 break; 1170 1170 case MEAS_DB_FLAGS: /* ? */ -
branches/czw_branch/20101203/Ohana/src/opihi/dvo/skycat.c
r20936 r30631 36 36 37 37 if (argc != 1) { 38 gprint (GP_ERR, "USAGE: skycat [-all] \n");38 gprint (GP_ERR, "USAGE: skycat [-all] [-depth depth] [-v]\n"); 39 39 return (FALSE); 40 40 } … … 116 116 117 117 r = ohana_normalize_angle (r); 118 while (r < Rmin) { r += 360.0; } 119 while (r > Rmax) { r -= 360.0; } 118 120 119 121 if (*leftside == -1) { -
branches/czw_branch/20101203/Ohana/src/opihi/include/dvoshell.h
r28958 r30631 107 107 MEAS_XCCD_ERR, 108 108 MEAS_YCCD_ERR, 109 MEAS_POS_SYS_ERR, 109 110 MEAS_XMOSAIC, 110 111 MEAS_YMOSAIC, … … 116 117 MEAS_IMAGE_ID, 117 118 MEAS_PSF_QF, 119 MEAS_PSF_QF_PERFECT, 118 120 MEAS_PSF_CHISQ, 119 121 MEAS_PSF_NDOF, … … 218 220 IMAGE_Y_UL_FP, 219 221 IMAGE_Y_UR_FP, 222 IMAGE_X_ERR_SYS, 223 IMAGE_Y_ERR_SYS, 224 IMAGE_MAG_ERR_SYS, 225 IMAGE_NFIT_PHOTOM, 226 IMAGE_NFIT_ASTROM, 227 IMAGE_NLINK_PHOTOM, 228 IMAGE_NLINK_ASTROM 220 229 }; 221 230 -
branches/czw_branch/20101203/Ohana/src/opihi/include/shell.h
r27790 r30631 76 76 char *expand_vars PROTO((char *line)); 77 77 char *expand_vectors PROTO((char *line)); 78 char *parse PROTO(( char *line));78 char *parse PROTO((int *status, char *line)); 79 79 char **parse_commands PROTO((char *, int *)); 80 80 void welcome PROTO((void)); -
branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/VectorOps.c
r20936 r30631 178 178 vec[0].Nelements = Nelements; 179 179 if (type == OPIHI_FLT) { 180 REALLOCATE (vec[0].elements.Flt, opihi_flt, Nelements);180 REALLOCATE (vec[0].elements.Flt, opihi_flt, MAX(1, Nelements)); 181 181 vec[0].type = OPIHI_FLT; 182 182 } else { 183 REALLOCATE (vec[0].elements.Int, opihi_int, Nelements);183 REALLOCATE (vec[0].elements.Int, opihi_int, MAX(1, Nelements)); 184 184 vec[0].type = OPIHI_INT; 185 185 } -
branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/command.c
r27790 r30631 10 10 Command *cmd; 11 11 12 // rawline = NULL; 13 rawline = strcreate (line); 12 // the input line is never NULL 13 if (!line) { fprintf (stderr, "programming error\n"); abort(); } 14 15 rawline = strcreate (line); // used for error messages which should echo the unparsed line 14 16 15 17 /* force a space between ! and first word: !ls becomes ! ls */ … … 22 24 /* expand anything of the form $fred or $fred$sam, etc */ 23 25 line = expand_vars (line); /* line is freed here, new one allocated */ 26 if (!line) goto escape; 27 24 28 /* expand anything of the form fred[N] */ 25 29 line = expand_vectors (line); /* line is freed here, new one allocated */ 30 if (!line) goto escape; 26 31 27 32 // print the line with the variables and vectors expanded, but before evaluating … … 29 34 if (VERBOSE_SHELL == OPIHI_VERBOSE_ON) gprint (GP_ERR, "opihi: %s\n", line); 30 35 31 /* solve math expresions, assign variable, if needed */ 32 line = parse (line); /* line is freed here, new one allocated */ 33 /* any entry in line of the form {foo} returns value or tmp vector / buffer */ 36 /* solve math expresions, assign variable, if needed. any entry in line of the form {foo} 37 * returns value or tmp vector / buffer */ 38 line = parse (&status, line); /* line is freed here, new one allocated */ 39 if (!status) goto escape; 34 40 35 41 /* we may have reallocated line, return new pointer */ … … 39 45 if (argc == 0) { 40 46 FREE (rawline); 47 set_int_variable ("STATUS", TRUE); 41 48 return (TRUE); /* empty command or assignment */ 42 49 } … … 74 81 FREE (rawline); 75 82 return (status); 83 84 escape: 85 set_int_variable ("STATUS", FALSE); 86 87 # if (DEBUG) 88 gprint (GP_ERR, "command: %s, status: %d\n", line, FALSE); 89 # endif 90 91 FREE (rawline); 92 93 if (VERBOSE_SHELL != OPIHI_VERBOSE_OFF) gprint (GP_ERR, "error on line: %s\n", rawline); 94 95 // return the current value of line, in case it was modified 96 *outline = line; 97 return FALSE; 76 98 } 77 99 -
branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/expand_vars.c
r15878 r30631 64 64 /* variable assignment (skip these variables) */ 65 65 if ((L == line) && (V1 != NULL)) { 66 if ((*V1 == '=') || !strcmp (V1, "++") || !strcmp (V1, "--")) { 66 int isAssignment; 67 68 isAssignment = FALSE; 69 isAssignment |= (V1[0] == '='); 70 isAssignment |= (V1[0] == '+') && (V1[1] == '='); 71 isAssignment |= (V1[0] == '-') && (V1[1] == '='); 72 isAssignment |= (V1[0] == '+') && (V1[1] == '+'); 73 isAssignment |= (V1[0] == '-') && (V1[1] == '-'); 74 75 if (isAssignment) { 67 76 *N = *L; 68 77 free (V0); -
branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/parse.c
r27491 r30631 1 1 # include "opihi.h" 2 2 3 char *parse ( char *line) {3 char *parse (int *status, char *line) { 4 4 5 5 double fval; 6 6 float *fptr; 7 7 char *newline, *N, *L, *val, *B, *V, *V0, *V1, *c1, *c2, *p; 8 int Nx, Ny, Nbytes, status, size, NLINE, isBuffer, inRange;8 int Nx, Ny, Nbytes, filestatus, size, NLINE, isBuffer, inRange; 9 9 FILE *f; 10 10 Vector *vec; 11 11 Buffer *buf; 12 13 *status = TRUE; 12 14 13 15 Ny = 0; … … 49 51 } 50 52 53 if (!strncmp (V1, "+=", 2)) { 54 V1 ++; 55 if (*V1 == 0) goto error; 56 V1 ++; 57 if (*V1 == 0) goto error; 58 59 val = get_variable (V0); 60 if (val == NULL) { 61 fval = 0.0; 62 } else { 63 fval = atof (val); 64 } 65 66 /* dvomath returns a new string, or NULL, with the result of the expression */ 67 val = dvomath (1, &V1, &size, 0); 68 if (val == NULL) goto error; 69 fval += atof(val); 70 // save the result 71 set_variable (V0, fval); 72 goto escape; 73 } 74 75 if (!strncmp (V1, "-=", 2)) { 76 V1 ++; 77 if (*V1 == 0) goto error; 78 V1 ++; 79 if (*V1 == 0) goto error; 80 81 val = get_variable (V0); 82 if (val == NULL) { 83 fval = 0.0; 84 } else { 85 fval = atof (val); 86 } 87 88 /* dvomath returns a new string, or NULL, with the result of the expression */ 89 val = dvomath (1, &V1, &size, 0); 90 if (val == NULL) goto error; 91 fval -= atof(val); 92 // save the result 93 set_variable (V0, fval); 94 goto escape; 95 } 96 51 97 /* not an assignement, syntax error */ 52 98 if (*V1 != '=') goto error; … … 73 119 Nbytes = fread (val, 1, 1023, f); 74 120 val[Nbytes] = 0; 75 status = pclose (f);121 filestatus = pclose (f); 76 122 free (B); 77 123 78 if ( status) gprint (GP_ERR, "warning: exit status of command %d\n",status);124 if (filestatus) gprint (GP_ERR, "warning: exit status of command %d\n", filestatus); 79 125 80 126 /* convert all but last return to ' '. drop last return */ … … 88 134 } 89 135 } 136 // save the resulting value 137 set_str_variable (V0, val); 138 goto escape; /* frees temp variables */ 139 } 140 141 /* simple variable assignment */ 142 /* dvomath returns a new string, or NULL, with the result of the expression */ 143 val = dvomath (1, &V1, &size, 0); 144 if (val == NULL) { 145 while (OHANA_WHITESPACE (*V1)) V1++; 146 val = strcreate (V1); 90 147 } 91 92 /* simple variable assignment */ 93 if (*V1 != '`') { 94 /* dvomath returns a new string, or NULL, with the result of the expression */ 95 val = dvomath (1, &V1, &size, 0); 96 if (val == NULL) { 97 while (OHANA_WHITESPACE (*V1)) V1++; 98 val = strcreate (V1); 99 } 100 } 101 /* both dvomath and command replacement create (char *) val */ 148 // save the result 102 149 set_str_variable (V0, val); 103 150 goto escape; /* frees temp variables */ … … 172 219 if (!inRange) { 173 220 gprint (GP_ERR, "no element %d,%d\n", Nx, Ny); 174 goto e scape;221 goto error; 175 222 } 176 223 if (Nx < 0) Nx += buf[0].header.Naxis[0]; … … 188 235 if (!inRange) { 189 236 gprint (GP_ERR, "no element %d\n", Nx); 190 goto e scape;237 goto error; 191 238 } 192 239 if (Nx < 0) Nx += vec[0].Nelements; … … 197 244 } 198 245 } 199 200 246 goto escape; 201 247 } … … 226 272 if (c1 == NULL) { 227 273 gprint (GP_ERR, "no close brackets!\n"); 228 goto e scape;274 goto error; 229 275 } 230 276 c2 = strchr (L, '{'); 231 277 if ((c2 != NULL) && (c2 < c1)) { 232 278 gprint (GP_ERR, "can't nest brackets!\n"); 233 goto e scape;279 goto error; 234 280 } 235 281 *c1 = 0; … … 240 286 if (val == NULL) { 241 287 print_error (); 242 goto e scape;288 goto error; 243 289 } 244 290 … … 257 303 258 304 REALLOCATE (newline, char, strlen (newline) + 1); 305 *status = TRUE; 259 306 return (newline); 260 307 261 308 error: 262 309 gprint (GP_ERR, "syntax error\n"); 263 264 escape: 310 // assignment or increment operation: free line and return NULL 265 311 if (line != (char *) NULL) free (line); 266 312 if (val != (char *) NULL) free (val); 267 313 if (V0 != (char *) NULL) free (V0); 314 *status = FALSE; 315 return NULL; 316 317 escape: 318 // assignment or increment operation: free line and return NULL 319 if (line != (char *) NULL) free (line); 320 if (val != (char *) NULL) free (val); 321 if (V0 != (char *) NULL) free (V0); 322 *status = TRUE; 268 323 return (NULL); 269 324 } -
branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/stack_math.c
r27435 r30631 972 972 *out = OP; \ 973 973 } \ 974 clear_stack (V1); \ 975 return (TRUE); \ 974 goto escape; \ 976 975 } \ 977 976 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 'S')) { \ … … 982 981 *out = OP; \ 983 982 } \ 984 clear_stack (V1); \ 985 return (TRUE); \ 983 goto escape; \ 986 984 } \ 987 985 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 's')) { \ … … 992 990 *out = OP; \ 993 991 } \ 994 clear_stack (V1); \ 995 return (TRUE); \ 992 goto escape; \ 996 993 } } 997 994 … … 1035 1032 # undef V_FUNC 1036 1033 1034 escape: 1035 1037 1036 if (V1[0].type == 'v') { 1038 1037 free (V1[0].vector[0].elements.Ptr);
Note:
See TracChangeset
for help on using the changeset viewer.
