Changeset 33963 for trunk/Ohana/src/opihi
- Timestamp:
- May 30, 2012, 1:46:12 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 28 edited
- 2 copied
-
. (modified) (1 prop)
-
Ohana/src/opihi/cmd.astro (modified) (1 prop)
-
Ohana/src/opihi/cmd.astro/Makefile (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/init.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.astro/kronflux.c (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/opihi/cmd.astro/kronflux.c )
-
Ohana/src/opihi/cmd.basic/Makefile (modified) (1 diff)
-
Ohana/src/opihi/cmd.basic/init.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.basic/input.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.basic/run_for.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.basic/run_foreach.c (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/opihi/cmd.basic/run_foreach.c )
-
Ohana/src/opihi/cmd.data/dot.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/gridify.c (modified) (6 diffs)
-
Ohana/src/opihi/cmd.data/match2d.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/threshold.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/vgroup.c (modified) (4 diffs)
-
Ohana/src/opihi/cmd.data/vstats.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/write_vectors.c (modified) (3 diffs)
-
Ohana/src/opihi/dvo/avextract.c (modified) (7 diffs)
-
Ohana/src/opihi/dvo/avmatch.c (modified) (4 diffs)
-
Ohana/src/opihi/dvo/dvo_client.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/dvo_host_utils.c (modified) (9 diffs)
-
Ohana/src/opihi/dvo/gstar.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/hosts.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/mextract.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/remote.c (modified) (4 diffs)
-
Ohana/src/opihi/dvo/skycoverage.c (modified) (6 diffs)
-
Ohana/src/opihi/include/dvoshell.h (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/ListOps.c (modified) (2 diffs)
-
Ohana/src/opihi/lib.shell/VectorIO.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/startup.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
trunk/Ohana/src/opihi/cmd.astro
- Property svn:mergeinfo set to
-
trunk/Ohana/src/opihi/cmd.astro/Makefile
r33662 r33963 46 46 $(SRC)/ringflux.$(ARCH).o \ 47 47 $(SRC)/petrosian.$(ARCH).o \ 48 $(SRC)/kronflux.$(ARCH).o \ 48 49 $(SRC)/multifit.$(ARCH).o \ 49 50 $(SRC)/objload.$(ARCH).o \ -
trunk/Ohana/src/opihi/cmd.astro/init.c
r33662 r33963 32 32 int ringflux PROTO((int, char **)); 33 33 int petrosian PROTO((int, char **)); 34 int kronflux PROTO((int, char **)); 34 35 int mkgauss PROTO((int, char **)); 35 36 int mksersic PROTO((int, char **)); … … 88 89 {1, "ringflux", ringflux, "mean flux in a ring"}, 89 90 {1, "petrosian", petrosian, "petrosian parameters given radial bins"}, 91 {1, "kronflux", kronflux, "measure kronflux stats"}, 90 92 {1, "multifit", multifit, "fit multi-order spectrum"}, 91 93 {1, "objload", objload, "plot obj data on Ximage "}, -
trunk/Ohana/src/opihi/cmd.basic/Makefile
r31635 r33963 44 44 $(SRC)/quit.$(ARCH).o \ 45 45 $(SRC)/run_for.$(ARCH).o \ 46 $(SRC)/run_foreach.$(ARCH).o \ 46 47 $(SRC)/run_if.$(ARCH).o \ 47 48 $(SRC)/run_while.$(ARCH).o \ -
trunk/Ohana/src/opihi/cmd.basic/init.c
r27255 r33963 31 31 int quit PROTO((int, char **)); 32 32 int run_for PROTO((int, char **)); 33 int run_foreach PROTO((int, char **)); 33 34 int run_if PROTO((int, char **)); 34 35 int run_while PROTO((int, char **)); … … 81 82 {1, "quit", quit, "exit program *"}, 82 83 {1, "for", run_for, "for loop"}, 84 {1, "foreach", run_foreach, "foreach loop"}, 83 85 {1, "if", run_if, "logical cases *"}, 84 86 {1, "while", run_while, "while loop"}, -
trunk/Ohana/src/opihi/cmd.basic/input.c
r7917 r33963 40 40 fclose (infile); 41 41 42 if (!inlist.Nlines) gprint (GP_ERR, "WARNING: input file (%s) was empty\n", argv[1]); 43 42 44 /* process this list */ 43 45 status = exec_loop (&inlist); -
trunk/Ohana/src/opihi/cmd.basic/run_for.c
r31667 r33963 5 5 int run_for (int argc, char **argv) { 6 6 7 int ThisList, depth, i, done, status, found, NLINES, j;7 int N, ThisList, depth, i, done, status, found, NLINES, j; 8 8 double start, end, delta; 9 9 char *input, *endptr; 10 10 double value, sign; 11 11 Macro loop; 12 13 int Inclusive = FALSE; 14 if ((N = get_argument (argc, argv, "-incl"))) { 15 remove_argument (N, &argc, argv); 16 Inclusive = TRUE; 17 } 12 18 13 19 if ((argc != 4) && (argc != 5)) { … … 95 101 REALLOCATE (loop.line, char *, MAX (loop.Nlines, 1)); 96 102 103 if (Inclusive) end += 0.01*delta; 104 97 105 status = TRUE; 98 106 interrupt = FALSE; -
trunk/Ohana/src/opihi/cmd.data/dot.c
r14181 r33963 3 3 int dot (int argc, char **argv) { 4 4 5 int kapa ;5 int kapa, N; 6 6 Graphdata graphmode; 7 7 float x, y; 8 8 9 9 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 10 11 /* FracPositions uses coordinates of 0-1 relative to axis range */ 12 int FracPositions = FALSE; 13 if ((N = get_argument (argc, argv, "-frac"))) { 14 remove_argument (N, &argc, argv); 15 FracPositions = TRUE; 16 } 10 17 11 18 if (argc != 3) { … … 15 22 x = atof(argv[1]); 16 23 y = atof(argv[2]); 24 25 if (FracPositions) { 26 x = x * (graphmode.xmax - graphmode.xmin) + graphmode.xmin; 27 y = y * (graphmode.ymax - graphmode.ymin) + graphmode.ymin; 28 } 17 29 18 30 /* set point style and errorbar mode (these are NOT sticky) */ -
trunk/Ohana/src/opihi/cmd.data/gridify.c
r31450 r33963 5 5 int i, Nx, Ny, Xb, Yb, Normalize, N; 6 6 float Xmin, Xmax, dX, Ymin, Ymax, dY, initValue; 7 float *buf, *val ;7 float *buf, *val, *cnt; 8 8 int *Nval; 9 Buffer *bf;10 9 Vector *vx, *vy, *vz; 11 10 opihi_flt *x, *y, *z; 11 12 Buffer *bf = NULL; 13 Buffer *ct = NULL; 12 14 13 15 Normalize = TRUE; … … 15 17 remove_argument (N, &argc, argv); 16 18 Normalize = FALSE; 19 if ((ct = SelectBuffer (argv[N], ANYBUFFER, TRUE)) == NULL) return (FALSE); 20 remove_argument (N, &argc, argv); 17 21 } 18 22 … … 24 28 } 25 29 26 if (argc != 11) { 27 gprint (GP_ERR, "USAGE: gridify x y z buffer Xmin Xmax dX Ymin Ymax dY\n"); 30 Xmin = Xmax = dX = NAN; 31 if ((N = get_argument (argc, argv, "-x"))) { 32 remove_argument (N, &argc, argv); 33 Xmin = atof (argv[N]); 34 remove_argument (N, &argc, argv); 35 Xmax = atof (argv[N]); 36 remove_argument (N, &argc, argv); 37 dX = atof (argv[N]); 38 remove_argument (N, &argc, argv); 39 } 40 41 Ymin = Ymax = dY = NAN; 42 if ((N = get_argument (argc, argv, "-y"))) { 43 remove_argument (N, &argc, argv); 44 Ymin = atof (argv[N]); 45 remove_argument (N, &argc, argv); 46 Ymax = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 dY = atof (argv[N]); 49 remove_argument (N, &argc, argv); 50 } 51 52 if (argc != 5) { 53 gprint (GP_ERR, "USAGE: gridify x y z buffer [-x Xmin Xmax dX] [-y Ymin Ymax dY] [-init-value value] [-raw]\n"); 28 54 return (FALSE); 29 55 } … … 41 67 REQUIRE_VECTOR_FLT (vz, FALSE); 42 68 43 Xmin = atof (argv[5]); 44 Xmax = atof (argv[6]); 45 dX = atof (argv[7]); 69 if (isnan(dX)) { 70 Xmin = 0; 71 Xmax = bf[0].matrix.Naxis[0]; 72 dX = 1; 73 } 46 74 47 Ymin = atof (argv[8]); 48 Ymax = atof (argv[9]); 49 dY = atof (argv[10]); 75 if (isnan(dY)) { 76 Ymin = 0; 77 Ymax = bf[0].matrix.Naxis[1]; 78 dY = 1; 79 } 50 80 51 Nx = (Xmax - Xmin) / dX + 1;52 Ny = (Ymax - Ymin) / dY + 1;81 Nx = (Xmax - Xmin) / dX; 82 Ny = (Ymax - Ymin) / dY; 53 83 54 gfits_free_matrix (&bf[0].matrix); 55 gfits_free_header (&bf[0].header); 56 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0); 57 strcpy (bf[0].file, "(empty)"); 84 if ((Nx != bf[0].matrix.Naxis[0]) || (Ny != bf[0].matrix.Naxis[1])) { 85 gfits_free_matrix (&bf[0].matrix); 86 gfits_free_header (&bf[0].header); 87 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0); 88 strcpy (bf[0].file, "(empty)"); 89 } 58 90 59 91 ALLOCATE (val, float, Nx*Ny); … … 68 100 Xb = (*x - Xmin) / dX; 69 101 Yb = (*y - Ymin) / dY; 102 if (Xb < 0) continue; 103 if (Yb < 0) continue; 70 104 if (Xb >= Nx) continue; 71 105 if (Yb >= Ny) continue; … … 74 108 } 75 109 110 if (!Normalize) { 111 gfits_free_matrix (&ct[0].matrix); 112 gfits_free_header (&ct[0].header); 113 CreateBuffer (ct, Nx, Ny, -32, 0.0, 1.0); 114 strcpy (ct[0].file, "(empty)"); 115 116 buf = (float *) bf[0].matrix.buffer; 117 cnt = (float *) ct[0].matrix.buffer; 118 for (i = 0; i < Nx*Ny; i++) { 119 if (Nval[i] == 0) continue; 120 buf[i] = val[i]; 121 cnt[i] = Nval[i]; 122 } 123 free (val); 124 free (Nval); 125 return TRUE; 126 } 127 76 128 buf = (float *) bf[0].matrix.buffer; 77 129 for (i = 0; i < Nx*Ny; i++) { 78 130 buf[i] = initValue; 79 if (Normalize) { 80 if (Nval[i] == 0) { 81 continue; 82 } 83 buf[i] = val[i] / Nval[i]; 84 } else { 85 buf[i] = val[i]; 86 } 131 if (Nval[i] == 0) continue; 132 buf[i] = val[i] / Nval[i]; 87 133 } 88 134 -
trunk/Ohana/src/opihi/cmd.data/match2d.c
r30610 r33963 167 167 NMATCH = X1->Nelements; 168 168 ResetVector (index, OPIHI_INT, NMATCH); 169 170 for (i = 0; i < index->Nelements; i++) { index->elements.Int[i] = -1; } 169 171 170 172 ALLOCATE (N1, off_t, X1->Nelements); -
trunk/Ohana/src/opihi/cmd.data/threshold.c
r33662 r33963 69 69 x0 = isFltX ? vecx[0].elements.Flt[Nhi] : vecy[0].elements.Int[Nhi]; 70 70 x1 = isFltX ? vecx[0].elements.Flt[Nhi+1] : vecy[0].elements.Int[Nhi+1]; 71 Xvalue = (value - y0) * (x1 - x0) / (y1 - y0) + x0; 71 if (y0 == y1) { 72 Xvalue = 0.5*(x0 + x1); 73 } else { 74 Xvalue = (value - y0) * (x1 - x0) / (y1 - y0) + x0; 75 } 72 76 } else { 73 77 // interpolate to value: … … 76 80 x0 = isFltX ? vecx[0].elements.Flt[Nhi-1] : vecy[0].elements.Int[Nhi-1]; 77 81 x1 = isFltX ? vecx[0].elements.Flt[Nhi] : vecy[0].elements.Int[Nhi]; 78 Xvalue = (value - y0) * (x1 - x0) / (y1 - y0) + x0; 82 if (y0 == y1) { 83 Xvalue = 0.5*(x0 + x1); 84 } else { 85 Xvalue = (value - y0) * (x1 - x0) / (y1 - y0) + x0; 86 } 79 87 } 80 88 -
trunk/Ohana/src/opihi/cmd.data/vgroup.c
r25757 r33963 1 1 # include "data.h" 2 3 enum {USE_MEDIAN, USE_COUNT, USE_SUM, USE_MEAN}; 2 4 3 5 int vgroup (int argc, char **argv) { … … 23 25 // } 24 26 27 int mode = USE_MEDIAN; 28 if ((N = get_argument (argc, argv, "-sum"))) { 29 remove_argument (N, &argc, argv); 30 mode = USE_SUM; 31 } 32 if ((N = get_argument (argc, argv, "-mean"))) { 33 remove_argument (N, &argc, argv); 34 mode = USE_MEAN; 35 } 36 37 float binsize = NAN; 38 if ((N = get_argument (argc, argv, "-binsize"))) { 39 remove_argument (N, &argc, argv); 40 binsize = atof(argv[N]); 41 remove_argument (N, &argc, argv); 42 } 43 25 44 if (argc != 5) { 26 gprint (GP_ERR, "USAGE: v bin<xin> <yin> <xout> <yout>\n");45 gprint (GP_ERR, "USAGE: vgroup <xin> <yin> <xout> <yout>\n"); 27 46 gprint (GP_ERR, " group x,y values in bins defined by <xout>\n"); 47 gprint (GP_ERR, " by default, yout has the median of the associated input values\n"); 48 gprint (GP_ERR, " use -sum to add values in the bin\n"); 49 gprint (GP_ERR, " use <yin> = histogram count matching values\n"); 50 gprint (GP_ERR, " use -binsize to specify a fixed bin width (<xout> will define the bin center)\n"); 28 51 return (FALSE); 29 52 } 30 53 31 54 if ((xin = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 32 if ((yin = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);33 55 if ((xout = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE); 34 56 if ((yout = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE); 57 yin = NULL; 58 59 // this should conflict with the -sum option... 60 if (!strcmp(argv[2], "histogram")) { 61 mode = USE_COUNT; 62 } else { 63 if ((yin = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE); 64 } 35 65 36 66 // re-binning creates a float vector … … 41 71 42 72 for (i = 0; i < xout[0].Nelements - 1; i++) { 43 xmin = xout[0].elements.Flt[i]; 44 xmax = xout[0].elements.Flt[i+1]; 73 if (isnan(binsize)) { 74 xmin = xout[0].elements.Flt[i]; 75 xmax = xout[0].elements.Flt[i+1]; 76 } else { 77 xmin = xout[0].elements.Flt[i] - 0.5*binsize; 78 xmax = xout[0].elements.Flt[i] + 0.5*binsize; 79 } 45 80 46 81 N = 0; … … 48 83 if (xin[0].elements.Flt[j] < xmin) continue; 49 84 if (xin[0].elements.Flt[j] > xmax) continue; 50 values[N] = yin[0].elements.Flt[j]; 85 if (yin) { 86 values[N] = yin[0].elements.Flt[j]; 87 } 51 88 N++; 52 89 } 53 90 54 dsort (values, N); 55 if (N > 1) { 56 sum = (N % 2) ? values[(int)(0.5*N)] : 0.5*(values[N/2] + values[N/2 + 1]); 57 } else { 58 sum = values[0]; 91 sum = NAN; 92 switch (mode) { 93 case USE_MEDIAN: 94 dsort (values, N); 95 if (N > 1) { 96 sum = (N % 2) ? values[(int)(0.5*N)] : 0.5*(values[N/2] + values[N/2 + 1]); 97 } else { 98 sum = values[0]; 99 } 100 break; 101 102 case USE_SUM: 103 sum = 0.0; 104 for (j = 0; j < N; j++) { 105 sum += values[j]; 106 } 107 break; 108 109 case USE_COUNT: 110 sum = N; 111 break; 112 113 case USE_MEAN: 114 sum = 0.0; 115 for (j = 0; j < N; j++) { 116 sum += values[j]; 117 } 118 sum /= N; 119 break; 59 120 } 60 61 // measure the stat for this bin62 // sum = 0.0;63 // for (j = 0; j < N; j++) {64 // sum += values[j];65 // }66 // sum /= N;67 121 yout[0].elements.Flt[i] = sum; 68 122 } -
trunk/Ohana/src/opihi/cmd.data/vstats.c
r32632 r33963 144 144 } 145 145 } 146 stdev = sqrt (var / N);146 stdev = sqrt (var / (N - 1)); 147 147 148 148 Nmode = 0; -
trunk/Ohana/src/opihi/cmd.data/write_vectors.c
r33662 r33963 21 21 FITS = NULL; 22 22 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 } 23 28 remove_argument (N, &argc, argv); 24 29 FITS = strcreate (argv[N]); 25 30 remove_argument (N, &argc, argv); 31 } 32 33 /* option generate a FITS output table */ 34 int CSV = FALSE; 35 if ((N = get_argument (argc, argv, "-csv"))) { 36 if (format) { 37 gprint (GP_ERR, "ERROR: do not mix -csv and -format\n"); 38 free (format); 39 return (FALSE); 40 } 41 if (FITS) { 42 gprint (GP_ERR, "ERROR: do not mix -csv and -fits\n"); 43 free (FITS); 44 return (FALSE); 45 } 46 remove_argument (N, &argc, argv); 47 CSV = TRUE; 26 48 } 27 49 … … 30 52 remove_argument (N, &argc, argv); 31 53 append = TRUE; 54 } 55 56 int ADD_HEADER = FALSE; 57 if ((N = get_argument (argc, argv, "-header"))) { 58 remove_argument (N, &argc, argv); 59 ADD_HEADER = TRUE; 32 60 } 33 61 … … 83 111 84 112 /* default output format */ 113 if (ADD_HEADER) { 114 for (j = 0; j < Nvec; j++) { 115 if (CSV) { 116 fprintf (f, "%s,", vec[j][0].name); 117 } else { 118 if (j == 0) fprintf (f, "# "); 119 fprintf (f, "%s ", vec[j][0].name); 120 } 121 } 122 fprintf (f, "\n"); 123 } 124 125 /* default output format */ 85 126 if (format == (char *) NULL) { 86 127 for (i = 0; i < vec[0][0].Nelements; i++) { 87 128 for (j = 0; j < Nvec; j++) { 88 129 if (vec[j][0].type == OPIHI_FLT) { 89 fprintf (f, "%.12g ", vec[j][0].elements.Flt[i]); 130 if (CSV) { 131 fprintf (f, "%.12g,", vec[j][0].elements.Flt[i]); 132 } else { 133 fprintf (f, "%.12g ", vec[j][0].elements.Flt[i]); 134 } 90 135 } else { 91 fprintf (f, "%d ", vec[j][0].elements.Int[i]); 136 if (CSV) { 137 fprintf (f, "%d,", vec[j][0].elements.Int[i]); 138 } else { 139 fprintf (f, "%d ", vec[j][0].elements.Int[i]); 140 } 92 141 } 93 142 } -
trunk/Ohana/src/opihi/dvo/avextract.c
r33662 r33963 37 37 } 38 38 39 int VERBOSE2 = FALSE; 40 if ((N = get_argument (argc, argv, "-vv"))) { 41 remove_argument (N, &argc, argv); 42 VERBOSE = TRUE; 43 VERBOSE2 = TRUE; 44 } 45 39 46 int PARALLEL = FALSE; 40 47 if ((N = get_argument (argc, argv, "-parallel"))) { … … 65 72 return FALSE; 66 73 } 74 } 75 76 // this is used to NOT save the results in the results file 77 // use this option when mextract is used in a script which does its 78 // own job of packaging the results 79 int SKIP_RESULTS = FALSE; 80 if ((N = get_argument (argc, argv, "-skip-results"))) { 81 remove_argument (N, &argc, argv); 82 SKIP_RESULTS = TRUE; 67 83 } 68 84 … … 80 96 goto escape; 81 97 } 98 99 // init locally static variables (time refs) 100 dbExtractAveragesInit (); 82 101 83 102 // command-line is of the form: avextract field,field, field [where (field op value)...] … … 173 192 catalog.filename = (HOST_ID || PARALLEL_LOCAL) ? hostfile : skylist[0].filename[i]; 174 193 catalog.catflags = LOAD_AVES | LOAD_SECF; 175 if (needMeasures) { 176 catalog.catflags |= LOAD_MEAS; 177 } 194 catalog.catflags |= needMeasures ? LOAD_MEAS : SKIP_MEAS; 178 195 catalog.Nsecfilt = 0; 179 196 … … 181 198 182 199 // an error exit status here is a significant error 183 if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {200 if (!dvo_catalog_open (&catalog, NULL, VERBOSE2, "r")) { 184 201 gprint (GP_ERR, "ERROR: failure to open catalog file %s\n", catalog.filename); 185 202 exit (2); … … 193 210 m = catalog.average[j].measureOffset; 194 211 195 // reset counters for saved fields, extract fields196 dbExtractAveragesInit (); 212 dbExtractAveragesInitAve (); // reset counters for saved fields (costs very little) 213 197 214 for (n = 0; n < Nfields; n++) { 198 215 values[n] = dbExtractAverages (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]); … … 229 246 230 247 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 231 if (RESULT_FILE ) {248 if (RESULT_FILE && !SKIP_RESULTS) { 232 249 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL); 233 if (!status) goto escape; 250 if (!status) { 251 goto escape; 252 } 234 253 } 235 254 -
trunk/Ohana/src/opihi/dvo/avmatch.c
r33662 r33963 66 66 if (!InitPhotcodes ()) goto escape; 67 67 Nsecfilt = GetPhotcodeNsecfilt (); 68 69 // init locally static variables (time refs) 70 dbExtractAveragesInit (); 68 71 69 72 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results … … 129 132 } 130 133 134 // check the requested fields : are all average/secfilt entries, or do we need measures? 135 int needMeasures = FALSE; 136 for (i = 0; !needMeasures && (i < Nfields); i++) { 137 if (fields[i].magMode == MAG_NONE) continue; 138 if (fields[i].photcode == NULL) continue; // assert this? 139 if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE; 140 if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE; 141 } 142 131 143 /* load regions which contain all supplied RA,DEC coordinates */ 132 144 if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape; … … 168 180 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 169 181 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 170 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; 182 catalog.catflags = LOAD_AVES | LOAD_SECF; 183 catalog.catflags |= needMeasures ? LOAD_MEAS : SKIP_MEAS; 171 184 catalog.Nsecfilt = 0; 172 185 … … 196 209 197 210 // reset counters for saved fields, extract fields 198 dbExtractAveragesInit ();211 dbExtractAveragesInitAve (); 199 212 for (n = 0; n < Nfields; n++) { 200 213 values[n] = dbExtractAverages (&catalog.average[Ncat], &catalog.secfilt[Ncat*Nsecfilt], &catalog.measure[m], &fields[n]); -
trunk/Ohana/src/opihi/dvo/dvo_client.c
r33662 r33963 98 98 99 99 int status = input (2, &argv[0]); 100 if (!status) exit (2); 100 if (!status) { 101 fprintf (stderr, "WARNING: exit status 2 %d (%s)\n", HOST_ID, HOSTDIR); 102 exit (2); 103 } 101 104 exit (0); 102 105 -
trunk/Ohana/src/opihi/dvo/dvo_host_utils.c
r33662 r33963 4 4 # define PARALLEL_MANUAL 0 5 5 # define PARALLEL_SERIAL 0 6 # define MAX_PATH_LENGTH 1024 7 8 int HostTableLaunchJobs (HostTable *table, char *basecmd, char *options) { 6 # define DVO_MAX_PATH 1024 7 8 # define DIE(WHO,MSG) { perror(WHO); myAbort(MSG); } 9 10 int HostTableLaunchJobs (HostTable *table, char *basecmd, char *options, int VERBOSE) { 9 11 10 12 char uniquer[12]; … … 13 15 snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000); 14 16 17 int top_status = TRUE; 15 18 int i; 16 19 for (i = 0; i < table->Nhosts; i++) { 17 20 18 21 // ensure that the paths are absolute path names 19 char *tmppath = abspath (table->hosts[i].pathname, MAX_PATH_LENGTH);22 char *tmppath = abspath (table->hosts[i].pathname, DVO_MAX_PATH); 20 23 free (table->hosts[i].pathname); 21 24 table->hosts[i].pathname = tmppath; … … 23 26 // need to save the results filename with the uniquer 24 27 // XXX a bit of a waste (but only 1024 * 60 bytes or so 25 ALLOCATE (table->hosts[i].results, char, MAX_PATH_LENGTH);26 snprintf (table->hosts[i].results, MAX_PATH_LENGTH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer);27 28 char commandBase[ MAX_PATH_LENGTH];29 snprintf (commandBase, MAX_PATH_LENGTH, "dvo.command.%s.txt", uniquer);30 char *commandFile = abspath(commandBase, MAX_PATH_LENGTH);28 ALLOCATE (table->hosts[i].results, char, DVO_MAX_PATH); 29 snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer); 30 31 char commandBase[DVO_MAX_PATH]; 32 snprintf (commandBase, DVO_MAX_PATH, "dvo.command.%s.txt", uniquer); 33 char *commandFile = abspath(commandBase, DVO_MAX_PATH); 31 34 32 35 FILE *f = fopen (commandFile, "w"); 33 36 fprintf (f, "%s\n", basecmd); 34 fclose (f); 37 if (fflush (f)) DIE("flush", "failed to flush"); 38 39 int fd = fileno (f); 40 if (fsync (fd)) DIE("fsync", "failed to fsync"); 41 42 if (fclose (f)) DIE("close", "failed to close"); 43 44 // force NFS to write the file to disk 45 int state; 46 f = fsetlockfile (commandFile, 0.5, LCK_XCLD, &state); 47 fclearlockfile (commandFile, f, LCK_XCLD, &state); 35 48 36 49 char command[1024]; … … 38 51 free (commandFile); 39 52 40 if ( DEBUG || PARALLEL_MANUAL) fprintf (stderr, "command: %s\n", command);53 if (VERBOSE) gprint (GP_ERR, "command: %s\n", command); 41 54 42 55 if (PARALLEL_MANUAL) { … … 47 60 int status = system (command); 48 61 if (status) { 49 fprintf (stderr, "ERROR running relphot_client\n");50 exit (2);62 gprint (GP_ERR, "ERROR running relphot_client\n"); 63 top_status = FALSE; 51 64 } 52 65 } else { … … 55 68 int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE); 56 69 if (!pid) { 57 if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo); 58 exit (1); 70 gprint (GP_ERR, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo); 71 top_status = FALSE; 72 continue; 59 73 } 60 74 table->hosts[i].pid = pid; // save for future reference 61 75 } 62 76 } 63 return TRUE;77 return top_status; 64 78 } 65 79 … … 86 100 } 87 101 88 char *CATDIR = abspath (tmppath, MAX_PATH_LENGTH);102 char *CATDIR = abspath (tmppath, DVO_MAX_PATH); 89 103 if (!CATDIR) { 90 104 gprint (GP_ERR, "failed to make an absolute path from %s (too long)\n", tmppath); … … 126 140 127 141 // launch this command remotely 128 HostTableLaunchJobs (table, basecmd, options );142 HostTableLaunchJobs (table, basecmd, options, VERBOSE); 129 143 free (options); 130 144 free (basecmd); … … 184 198 return TRUE; 185 199 } 200 201 // re-gather the remote results files: this can be used in case one of the clients failed, 202 // and has since been re-run 203 int HostTableReloadResults (char *uniquer, int VERBOSE) { 204 205 int i; 206 207 // load the list of hosts 208 SkyTable *sky = GetSkyTable(); 209 if (!sky) { 210 gprint (GP_ERR, "failed to load sky table for database\n"); 211 return FALSE; 212 } 213 214 char *CATDIR = GetCATDIR (); 215 if (!CATDIR) { 216 gprint (GP_ERR, "failed to get CATDIR for database\n"); 217 return FALSE; 218 } 219 220 HostTable *table = HostTableLoad (CATDIR, sky->hosts); 221 if (!table) { 222 gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR); 223 return FALSE; 224 } 225 226 // load fields from file 227 int Nvec = 0; 228 Vector **vec = NULL; 229 for (i = 0; i < table->Nhosts; i++) { 230 // ensure that the paths are absolute path names 231 char *tmppath = abspath (table->hosts[i].pathname, DVO_MAX_PATH); 232 free (table->hosts[i].pathname); 233 table->hosts[i].pathname = tmppath; 234 235 // need to save the results filename with the uniquer 236 // XXX a bit of a waste (but only 1024 * 60 bytes or so 237 ALLOCATE (table->hosts[i].results, char, DVO_MAX_PATH); 238 snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer); 239 240 int Ninvec = 0; 241 Vector **invec = ReadVectorTableFITS (table->hosts[i].results, "RESULT", &Ninvec); 242 if (!invec) { 243 // failed to read the file, now what? 244 gprint (GP_ERR, "failed to read remote result file : %s\n", table->hosts[i].results); 245 free (table->hosts[i].results); 246 table->hosts[i].results = NULL; 247 continue; 248 } 249 free (table->hosts[i].results); 250 table->hosts[i].results = NULL; 251 252 // fprintf (stderr, "%s : %d\n", table->hosts[i].pathname, invec[0]->Nelements); 253 254 vec = MergeVectors (vec, &Nvec, invec, Ninvec); 255 if (vec != invec) { 256 FreeVectorArray (invec, Ninvec); 257 } 258 } 259 260 for (i = 0; i < Nvec; i++) { 261 AssignVector (vec[i], vec[i]->name, ANYVECTOR, TRUE); 262 } 263 free (vec); 264 265 free (table); 266 return TRUE; 267 } -
trunk/Ohana/src/opihi/dvo/gstar.c
r33662 r33963 116 116 117 117 /* lock, load, unlock catalog */ 118 catalog.catflags = GetMeasures ? LOAD_AVES | LOAD_MEAS | LOAD_SECF : LOAD_AVES | LOAD_SECF; 118 catalog.catflags = LOAD_AVES | LOAD_SECF; 119 catalog.catflags |= GetMeasures ? LOAD_MEAS : SKIP_MEAS; 119 120 catalog.Nsecfilt = 0; 120 121 -
trunk/Ohana/src/opihi/dvo/hosts.c
r33662 r33963 1 1 # include "dvoshell.h" 2 2 # include <glob.h> 3 # define MAX_PATH_LENGTH 10243 # define DVO_MAX_PATH 1024 4 4 5 5 // functions to manage the remote hosts … … 59 59 for (i = 0; i < table->Nhosts; i++) { 60 60 pglob.gl_offs = 0; 61 char name[ MAX_PATH_LENGTH];62 snprintf (name, MAX_PATH_LENGTH, "%s/dvo.results.%05d.*.fits", table->hosts[i].pathname, PID);61 char name[DVO_MAX_PATH]; 62 snprintf (name, DVO_MAX_PATH, "%s/dvo.results.%05d.*.fits", table->hosts[i].pathname, PID); 63 63 if (VERBOSE) gprint (GP_ERR, "checking %s\n", name); 64 64 glob (name, 0, NULL, &pglob); -
trunk/Ohana/src/opihi/dvo/mextract.c
r33662 r33963 189 189 } 190 190 191 dbExtractMeasuresInitAve (); // reset counters for saved fields (costs very little 191 dbExtractMeasuresInitAve (); // reset counters for saved fields (costs very little) 192 192 193 193 for (k = 0; (k < catalog.average[j].Nmeasure); k++, m++) { -
trunk/Ohana/src/opihi/dvo/remote.c
r33662 r33963 1 1 # include "dvoshell.h" 2 2 # include <glob.h> 3 # define MAX_PATH_LENGTH 10243 # define DVO_MAX_PATH 1024 4 4 5 5 // functions to manage the remote hosts … … 8 8 int N; 9 9 10 int VERBOSE = FALSE; 11 if ((N = get_argument (argc, argv, "-v"))) { 12 remove_argument (N, &argc, argv); 13 VERBOSE = TRUE; 14 } 15 10 16 if (argc < 2) { 11 17 gprint (GP_ERR, "USAGE: remote (command)\n"); … … 13 19 gprint (GP_ERR, " options:\n"); 14 20 gprint (GP_ERR, " -v : verbose mode:\n"); 21 gprint (GP_ERR, "OR: remote -reload (uniquer)\n"); 15 22 return FALSE; 16 23 } … … 23 30 // with a set of vectors to load. 24 31 25 int VERBOSE = FALSE; 26 if ((N = get_argument (argc, argv, "-v"))) { 32 if ((N = get_argument (argc, argv, "-reload"))) { 27 33 remove_argument (N, &argc, argv); 28 VERBOSE = TRUE; 34 if (argc != 2) { 35 gprint (GP_ERR, "USAGE: remote -reload (uniquer)\n"); 36 gprint (GP_ERR, " (uniquer) is the element in the middle of the results file\n"); 37 gprint (GP_ERR, " eg: dvo.results.XXXXX.YYYYY.fits\n"); 38 return FALSE; 39 } 40 int status = HostTableReloadResults (argv[1], VERBOSE); 41 return status; 29 42 } 30 43 -
trunk/Ohana/src/opihi/dvo/skycoverage.c
r33662 r33963 2 2 3 3 // enum to define possible modes 4 enum {COVERAGE, DENSITY, MIN_UBERCAL, MIN_DMAG_SYS, MIN_MCAL, MAX_MCAL };4 enum {COVERAGE, DENSITY, MIN_UBERCAL, MIN_DMAG_SYS, MIN_MCAL, MAX_MCAL, MIN_TIME, MAX_TIME}; 5 5 6 6 int wordhash (char *word); … … 23 23 PhotCode *PhotcodeValue; 24 24 25 time_t TimeReference; 26 int TimeFormat; 27 28 GetTimeFormat (&TimeReference, &TimeFormat); 29 25 30 WITH_MOSAIC = FALSE; 26 31 if ((N = get_argument (argc, argv, "+mosaic"))) { … … 71 76 remove_argument (N, &argc, argv); 72 77 mode = MIN_UBERCAL; 78 } 79 if ((N = get_argument (argc, argv, "-min-time"))) { 80 remove_argument (N, &argc, argv); 81 mode = MIN_TIME; 82 } 83 if ((N = get_argument (argc, argv, "-max-time"))) { 84 remove_argument (N, &argc, argv); 85 mode = MAX_TIME; 73 86 } 74 87 if ((N = get_argument (argc, argv, "-min-dmag-sys"))) { … … 231 244 case MIN_DMAG_SYS: 232 245 case MIN_MCAL: 233 V[ys*Nx + xs] = 1E6; 246 case MIN_TIME: 247 V[ys*Nx + xs] = 1E9; 234 248 break; 235 249 case MAX_MCAL: 236 V[ys*Nx + xs] = -1E6; 250 case MAX_TIME: 251 V[ys*Nx + xs] = -1E9; 237 252 break; 238 253 } … … 247 262 case MIN_MCAL: 248 263 case MAX_MCAL: 264 case MIN_TIME: 265 case MAX_TIME: 249 266 V[ys*Nx + xs] = NAN; 250 267 break; … … 323 340 V[ys*Nx + xs] = MAX(V[ys*Nx + xs], image[i].Mcal); 324 341 break; 342 case MIN_TIME: { 343 double timeVal = TimeValue (image[i].tzero, TimeReference, TimeFormat); 344 V[ys*Nx + xs] = MIN(V[ys*Nx + xs], timeVal); 345 break; } 346 case MAX_TIME: { 347 double timeVal = TimeValue (image[i].tzero, TimeReference, TimeFormat); 348 V[ys*Nx + xs] = MAX(V[ys*Nx + xs], timeVal); 349 break; } 325 350 } 326 351 } -
trunk/Ohana/src/opihi/include/dvoshell.h
r33662 r33963 99 99 dbValue dbExtractImages PROTO((Image *image, off_t Nimage, off_t N, dbField *field)); 100 100 101 int HostTableLaunchJobs PROTO((HostTable *table, char *basecmd, char *options ));101 int HostTableLaunchJobs PROTO((HostTable *table, char *basecmd, char *options, int VERBOSE)); 102 102 int HostTableParallelOps PROTO((int argc, char **argv, char *ResultFile, int Nelements, int VERBOSE)); 103 # endif 103 int HostTableReloadResults PROTO((char *uniquer, int VERBOSE)); 104 105 # endif // DVOSHELL_H -
trunk/Ohana/src/opihi/lib.shell/ListOps.c
r33662 r33963 116 116 117 117 status = !strcmp (comm, "for"); 118 free (comm); 119 return (status); 120 } 121 122 int is_foreach_loop (char *line) { 123 124 int status; 125 char *comm; 126 127 comm = thisword (line); 128 if (comm == (char *) NULL) return (FALSE); 129 130 status = !strcmp (comm, "foreach"); 118 131 free (comm); 119 132 return (status); … … 266 279 status |= is_macro_create (line); 267 280 status |= is_for_loop (line); 281 status |= is_foreach_loop (line); 268 282 status |= is_list_data (line); 269 283 status |= is_loop (line); -
trunk/Ohana/src/opihi/lib.shell/VectorIO.c
r33662 r33963 20 20 } 21 21 if (f == (FILE *) NULL) { 22 gprint (GP_ERR, "can't open file for write \n");22 gprint (GP_ERR, "can't open file for write : %s\n", filename); 23 23 return (FALSE); 24 24 } -
trunk/Ohana/src/opihi/lib.shell/startup.c
r27998 r33963 138 138 if (is_script) { 139 139 /* first argument in input script, rest are argv */ 140 set_str_variable ("SCRIPT_NAME", argv[1]); 140 141 list[Nlist] = strcreate (argv[1]); 141 142 Nlist ++;
Note:
See TracChangeset
for help on using the changeset viewer.
