Changeset 34461 for trunk/Ohana/src/opihi
- Timestamp:
- Sep 25, 2012, 6:39:11 AM (14 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 6 edited
-
cmd.data/read_vectors.c (modified) (5 diffs)
-
cmd.data/reindex.c (modified) (5 diffs)
-
cmd.data/subset.c (modified) (1 diff)
-
dvo/Makefile (modified) (1 diff)
-
dvo/avmatch.c (modified) (1 diff)
-
dvo/init.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/read_vectors.c
r33662 r34461 22 22 23 23 // vector types 24 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME };24 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR}; 25 25 26 26 int read_vectors (int argc, char **argv) { … … 101 101 if (!strcasecmp(ptr, "float")) { coltype[i] = COLTYPE_FLT; } 102 102 if (!strcasecmp(ptr, "int")) { coltype[i] = COLTYPE_INT; } 103 if (!strcasecmp(ptr, "char")) { coltype[i] = COLTYPE_CHAR; } 103 104 if (!strcasecmp(ptr, "time")) { coltype[i] = COLTYPE_TIME; } 104 105 if (!coltype[i]) goto bad_colname; … … 143 144 NELEM = 1000; 144 145 for (i = 0; i < Nvec; i++) { 145 if ( coltype[i] == COLTYPE_INT) {146 if ((coltype[i] == COLTYPE_INT) || (coltype[i] == COLTYPE_CHAR)) { 146 147 ResetVector (vec[i], OPIHI_INT, NELEM); 147 148 } else { … … 195 196 for (i = 0; i < Nvec; i++) { 196 197 int ivalue; 198 char cvalue; 197 199 double dvalue; 198 200 time_t tvalue; … … 203 205 readStatus = IsCSV ? iparse_csv (&ivalue, col[i], c0) : iparse (&ivalue, col[i], c0); 204 206 vec[i][0].elements.Int[Nelem] = readStatus ? ivalue : 0; 207 break; 208 case COLTYPE_CHAR: 209 readStatus = IsCSV ? charparse_csv (&cvalue, col[i], c0) : charparse (&cvalue, col[i], c0); 210 vec[i][0].elements.Int[Nelem] = readStatus ? cvalue : 0; 205 211 break; 206 212 case COLTYPE_FLT: -
trunk/Ohana/src/opihi/cmd.data/reindex.c
r33662 r34461 5 5 int reindex (int argc, char **argv) { 6 6 7 int i, N pts, Nmax;7 int i, Nmax, N; 8 8 Vector *ivec, *ovec, *xvec; 9 9 10 10 ivec = ovec = xvec = NULL; 11 Npts = 0; 11 int Npts = 0; 12 13 int KEEP_UNMATCH = FALSE; 14 if ((N = get_argument (argc, argv, "-keep-unmatched"))) { 15 remove_argument (N, &argc, argv); 16 KEEP_UNMATCH = TRUE; 17 } 12 18 13 19 if (argc != 6) goto usage; … … 22 28 23 29 // ovec matches ivec in type and xvec in size (xvec need not have all ivec elements, and may have duplicates 30 int NPTS = xvec[0].Nelements; 24 31 ResetVector (ovec, ivec->type, xvec[0].Nelements); 25 32 … … 31 38 opihi_int *vx = xvec[0].elements.Int; 32 39 for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) { 33 if (*vx == -1) continue; 34 if (*vx < 0) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i); 40 if (Npts >= NPTS) { 41 NPTS += 2000; 42 REALLOCATE (ovec[0].elements.Flt, opihi_flt, NPTS); 43 } 44 if (*vx < 0) { 45 if (KEEP_UNMATCH) { 46 ovec[0].elements.Flt[Npts] = NAN; 47 Npts++; 48 } 49 continue; 50 } 35 51 if (*vx > Nmax) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i); 36 52 ovec[0].elements.Flt[Npts] = vi[*vx]; … … 42 58 opihi_int *vx = xvec[0].elements.Int; 43 59 for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) { 44 if (*vx == -1) continue; 45 if (*vx < 0) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i); 60 if (Npts >= NPTS) { 61 NPTS += 2000; 62 REALLOCATE (ovec[0].elements.Int, opihi_int, NPTS); 63 } 64 if (*vx < 0) { 65 if (KEEP_UNMATCH) { 66 ovec[0].elements.Flt[Npts] = -1; 67 Npts++; 68 } 69 continue; 70 } 46 71 if (*vx > Nmax) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i); 47 72 ovec[0].elements.Int[Npts] = vi[*vx]; … … 60 85 usage: 61 86 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"); 87 gprint (GP_ERR, " Creates a new vector (out) from (in) based on sequence in (index)\n"); 88 gprint (GP_ERR, " output[i] = input[index[i]]\n"); 89 gprint (GP_ERR, " If -keep-unmatched is provided, elements of index with negative values will be set to NaN / -1,\n"); 90 gprint (GP_ERR, " otherwise they will be skipped in the output.\n"); 91 gprint (GP_ERR, " The output vector has the type of the input vector and the length of the index (if -keep-unmatched).\n"); 92 gprint (GP_ERR, " The index vector may have duplicates\n"); 63 93 return (FALSE); 64 94 } -
trunk/Ohana/src/opihi/cmd.data/subset.c
r30610 r34461 13 13 Npts = 0; 14 14 15 if (argc < 6) { 16 gprint (GP_ERR, "SYNTAX: subset vec = vec [if/where] (logic expression)\n"); 17 return (FALSE); 18 } 19 15 20 valid = TRUE; 16 valid &= (argc >= 6);17 21 valid &= !strcmp(argv[2], "="); 18 22 valid &= !strcmp(argv[4], "if") || !strcmp (argv[4], "where"); -
trunk/Ohana/src/opihi/dvo/Makefile
r33662 r34461 67 67 $(SRC)/lightcurve.$(ARCH).o \ 68 68 $(SRC)/mextract.$(ARCH).o \ 69 $(SRC)/mmatch.$(ARCH).o \ 69 70 $(SRC)/mmextract.$(ARCH).o \ 70 71 $(SRC)/objectcoverage.$(ARCH).o \ -
trunk/Ohana/src/opihi/dvo/avmatch.c
r34405 r34461 203 203 Npts = j; 204 204 205 if (Ncat == -1) continue; 206 if (Ncat == -2) continue; 205 if (Ncat == -1) continue; // this point is not in this catalog file 206 if (Ncat == -2) continue; // no matches to this point 207 207 208 208 m = catalog.average[Ncat].measureOffset; -
trunk/Ohana/src/opihi/dvo/init.c
r33662 r34461 42 42 int lightcurve PROTO((int, char **)); 43 43 int mextract PROTO((int, char **)); 44 int mmatch PROTO((int, char **)); 44 45 int mmextract PROTO((int, char **)); 45 46 int objectcoverage PROTO((int, char **)); … … 97 98 {1, "lightcurve", lightcurve, "extract lightcurve for a star"}, 98 99 {1, "mextract", mextract, "extract measure data values"}, 100 {1, "mmatch", mmatch, "extract measure data values matched to RA,DEC points"}, 99 101 {1, "mmextract", mmextract, "extract joined measurements"}, 100 102 {1, "objectcoverage", objectcoverage, "plot catalog boundaries"},
Note:
See TracChangeset
for help on using the changeset viewer.
