Changeset 31667
- Timestamp:
- Jun 22, 2011, 12:40:23 AM (15 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 17 edited
- 2 copied
-
cmd.astro/czplot.c (modified) (3 diffs)
-
cmd.basic/cd.c (modified) (2 diffs)
-
cmd.basic/list.c (modified) (2 diffs)
-
cmd.basic/run_for.c (modified) (2 diffs)
-
cmd.basic/run_if.c (modified) (2 diffs)
-
cmd.basic/run_while.c (modified) (2 diffs)
-
cmd.data/init.c (modified) (2 diffs)
-
cmd.data/read_vectors.c (modified) (8 diffs)
-
cmd.data/test/csv.dat (copied) (copied from branches/eam_branches/ipp-20110505/Ohana/src/opihi/cmd.data/test/csv.dat )
-
cmd.data/test/csv1.dat (copied) (copied from branches/eam_branches/ipp-20110505/Ohana/src/opihi/cmd.data/test/csv1.dat )
-
cmd.data/tvcolors.c (modified) (2 diffs)
-
cmd.data/zplot.c (modified) (1 diff)
-
dvo/gstar.c (modified) (1 diff)
-
include/pantasks.h (modified) (2 diffs)
-
include/shell.h (modified) (1 diff)
-
lib.shell/CommandOps.c (modified) (2 diffs)
-
lib.shell/macro_create.c (modified) (2 diffs)
-
lib.shell/opihi.c (modified) (2 diffs)
-
lib.shell/string.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/czplot.c
r20936 r31667 3 3 int czplot (int argc, char **argv) { 4 4 5 int i, kapa ;5 int i, kapa, Npts, status; 6 6 double min, range, Rmin, Rmax; 7 7 opihi_flt *out, *r, *d, *x, *y; … … 18 18 min = atof(argv[4]); 19 19 range = atof(argv[5]) - min; 20 Rmin = graphmode.coords.crval1 - 18 0.0;21 Rmax = graphmode.coords.crval1 + 18 0.0;20 Rmin = graphmode.coords.crval1 - 182.0; 21 Rmax = graphmode.coords.crval1 + 182.0; 22 22 23 23 /* find vectors */ … … 46 46 x = Xvec.elements.Flt; 47 47 y = Yvec.elements.Flt; 48 for (i = 0; i < Zvec.Nelements; i++, r++, d++, x++, y++) { 48 out = Zvec.elements.Flt; 49 50 Npts = 0; 51 for (i = 0; i < xvec[0].Nelements; i++, r++, d++) { 49 52 *r = ohana_normalize_angle (*r); 50 RD_to_XY (x, y, *r, *d, &graphmode.coords); 53 while (*r < Rmin) *r += 360.0; 54 while (*r > Rmax) *r -= 360.0; 55 56 status = RD_to_XY (x, y, *r, *d, &graphmode.coords); 57 if (!status) continue; 58 59 if (zvec->type == OPIHI_FLT) { 60 opihi_flt *in = zvec[0].elements.Flt; 61 *out = MIN (1.0, MAX (0.01, (in[i] - min) / range)); 62 } else { 63 opihi_int *in = zvec[0].elements.Int; 64 *out = MIN (1.0, MAX (0.01, (in[i] - min) / range)); 65 } 66 x++; 67 y++; 68 out++; 69 Npts++; 51 70 } 52 53 out = Zvec.elements.Flt; 54 if (zvec->type == OPIHI_FLT) { 55 opihi_flt *in = zvec[0].elements.Flt; 56 for (i = 0; i < Zvec.Nelements; i++, in++, out++) { 57 *out = MIN (1.0, MAX (0.01, (*in - min) / range)); 58 } 59 } else { 60 opihi_int *in = zvec[0].elements.Int; 61 for (i = 0; i < Zvec.Nelements; i++, in++, out++) { 62 *out = MIN (1.0, MAX (0.01, (*in - min) / range)); 63 } 64 } 71 Xvec.Nelements = Npts; 72 Yvec.Nelements = Npts; 73 Zvec.Nelements = Npts; 65 74 66 75 graphmode.style = 2; -
trunk/Ohana/src/opihi/cmd.basic/cd.c
r27435 r31667 24 24 } 25 25 if (VERBOSE) gprint (GP_LOG, "cwd: %s\n", cwd); 26 ohana_memregister (cwd); 27 free (cwd); 26 real_free (cwd); 28 27 return (TRUE); 29 28 } … … 62 61 free (var); 63 62 } 64 ohana_memregister (cwd); 65 free (cwd); 63 real_free (cwd); 66 64 return (TRUE); 67 65 -
trunk/Ohana/src/opihi/cmd.basic/list.c
r27587 r31667 223 223 /* get the next line (from correct place) */ 224 224 if (ThisList == 0) { 225 input = readline (prompt);225 input = opihi_readline (prompt); 226 226 } else { 227 227 input = get_next_listentry (ThisList); … … 236 236 input = strcreate ("end"); 237 237 } 238 if (ThisList == 0) ohana_memregister (input);239 238 240 239 stripwhite (input); -
trunk/Ohana/src/opihi/cmd.basic/run_for.c
r27798 r31667 48 48 /* get the next line (from correct place) */ 49 49 if (ThisList == 0) 50 input = readline (prompt);50 input = opihi_readline (prompt); 51 51 else 52 52 input = get_next_listentry (ThisList); … … 67 67 } 68 68 } 69 if (ThisList == 0) ohana_memregister (input);70 69 71 70 /* test for new macro (or other list, in the future?) */ -
trunk/Ohana/src/opihi/cmd.basic/run_if.c
r23583 r31667 66 66 /* get the next line (from correct place) */ 67 67 if (ThisList == 0) { 68 input = readline (prompt);68 input = opihi_readline (prompt); 69 69 } else { 70 70 input = get_next_listentry (ThisList); … … 79 79 input = strcreate ("end"); 80 80 } 81 if (ThisList == 0) ohana_memregister (input);82 81 83 82 stripwhite (input); -
trunk/Ohana/src/opihi/cmd.basic/run_while.c
r27491 r31667 25 25 /* get the next line (from correct place) */ 26 26 if (ThisList == 0) 27 input = readline (prompt);27 input = opihi_readline (prompt); 28 28 else 29 29 input = get_next_listentry (ThisList); … … 44 44 } 45 45 } 46 if (ThisList == 0) ohana_memregister (input);47 46 48 47 /* test for new macro (or other list, in the future?) */ -
trunk/Ohana/src/opihi/cmd.data/init.c
r31450 r31667 137 137 int zap PROTO((int, char **)); 138 138 int zplot PROTO((int, char **)); 139 int zcplot PROTO((int, char **)); 139 140 140 141 static Command cmds[] = { … … 284 285 {1, "zap", zap, "assign values to pixel regions"}, 285 286 {1, "zplot", zplot, "plot x y with size scaled by z"}, 287 {1, "zcplot", zcplot, "plot x y with color scaled by z"}, 286 288 }; 287 289 -
trunk/Ohana/src/opihi/cmd.data/read_vectors.c
r29938 r31667 2 2 3 3 FILE *f = (FILE *) NULL; 4 char filename[2 56];4 char filename[2048]; 5 5 6 6 int datafile (int argc, char **argv) { … … 23 23 int read_vectors (int argc, char **argv) { 24 24 25 int i, j, Nskip, Nvec, *col, done, status ;25 int i, j, Nskip, Nvec, *col, done, status, IsCSV; 26 26 int Nbytes, nbytes, Nstart, NELEM, N, nread; 27 27 char *colstr, *c0, *c1, *buffer, *extname; … … 47 47 } 48 48 49 IsCSV = FALSE; 50 if ((N = get_argument (argc, argv, "-csv"))) { 51 remove_argument (N, &argc, argv); 52 IsCSV = TRUE; 53 } 54 49 55 if ((argc < 3) || !(argc % 2)) { 50 56 gprint (GP_ERR, "USAGE: read name N name N ...\n"); … … 58 64 } 59 65 fseeko (f, 0LL, SEEK_SET); 66 67 // if (IsCSV) { 68 // status = read_vectors_csv (argc, argv, Nskip, f); 69 // return status; 70 // } 60 71 61 72 Nvec = (argc - 1) / 2; … … 73 84 colstr = argv[2*i+2]; 74 85 for (j = 0; j < strlen (colstr); j++) { 75 if (!isdigit(colstr[j])) { 76 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 77 free (vec); 78 free (col); 79 return (FALSE); 80 } 81 } 82 col[i] = atof (colstr); 86 if (isdigit(colstr[j])) { 87 col[i] = atof (colstr); 88 continue; 89 } 90 // allow 'excel' columns names of the form A-Z, AA-AZ, BA-BZ, .. ZA-ZZ 91 if (strlen(colstr) >= 3) goto bad_colname; 92 if (colstr[0] < 'A') goto bad_colname; 93 if (colstr[0] > 'Z') goto bad_colname; 94 if (colstr[1] && colstr[1] < 'A') goto bad_colname; 95 if (colstr[1] && colstr[1] > 'Z') goto bad_colname; 96 97 col[i] = colstr[0] - 'A' + 1; 98 if (colstr[1]) { 99 col[i] *= 26; 100 col[i] += colstr[1] - 'A' + 1; 101 } 102 continue; 103 104 bad_colname: 105 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 106 free (vec); 107 free (col); 108 return (FALSE); 109 } 83 110 } 84 111 … … 94 121 scan_line (f, buffer); 95 122 } 123 124 int Nfield = 0; 125 int Nline = 0; 96 126 97 127 Nstart = 0; … … 122 152 if ((*c0 != '#') && (*c0 != '!')) { 123 153 for (i = 0; (i < Nvec) && status; i++) { 124 status = dparse (&value, col[i], c0); 154 if (IsCSV) { 155 status = dparse_csv (&value, col[i], c0); 156 } else { 157 status = dparse (&value, col[i], c0); 158 } 125 159 vec[i][0].elements.Flt[N] = value; 160 if (status) { 161 Nfield ++; 162 } 126 163 if (!status) vec[i][0].elements.Flt[N] = NAN; 127 164 } 128 165 if (status) N++; 129 166 } 167 Nline ++; 168 if (c1) { 169 // fprintf (stderr, "line %d, chars %ld, fields %d\n", Nline, (c1 - c0), Nfield); 170 } 171 Nfield = 0; 130 172 c0 = c1 + 1; 131 173 if (N == NELEM) { … … 341 383 return (TRUE); 342 384 } 385 386 # if (0) 387 int read_vectors_csv (int argc, char **argv, int Nskip, FILE *f) { 388 389 int i, j, Nvec, *col, done, status; 390 int Nbytes, nbytes, Nstart, NELEM, N, nread; 391 char *colstr, *c0, *c1, *buffer, *extname; 392 double value; 393 Vector **vec; 394 395 Nvec = (argc - 1) / 2; 396 ALLOCATE (vec, Vector *, Nvec); 397 ALLOCATE (col, int, Nvec); 398 399 for (i = 0; i < Nvec; i++) { 400 if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) { 401 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 402 free (vec); 403 free (col); 404 return (FALSE); 405 } 406 // XXX we could allow flags (eg, N.i) to specify INT vs FLT types vectors... 407 colstr = argv[2*i+2]; 408 for (j = 0; j < strlen (colstr); j++) { 409 if (!isdigit(colstr[j])) { 410 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 411 free (vec); 412 free (col); 413 return (FALSE); 414 } 415 } 416 col[i] = atof (colstr); 417 } 418 419 // currently, all read vectors are forced to be type FLT 420 NELEM = 1000; 421 for (i = 0; i < Nvec; i++) { 422 ResetVector (vec[i], OPIHI_FLT, NELEM); 423 } 424 425 ALLOCATE (buffer, char, 0x10001); 426 bzero (buffer, 0x10001); 427 for (i = 0; i < Nskip; i++) { 428 scan_line (f, buffer); 429 } 430 431 Nstart = 0; 432 N = 0; 433 done = FALSE; 434 while (!done) { 435 Nbytes = 0x10000 - Nstart; 436 bzero (&buffer[Nstart], Nbytes); 437 nread = fread (&buffer[Nstart], 1, Nbytes, f); 438 if (ferror (f)) { 439 perror ("error reading data file"); 440 break; 441 } 442 if (nread == 0) break; 443 nbytes = nread + Nstart; 444 445 status = TRUE; 446 c0 = buffer; 447 while (status) { 448 c1 = strchr (c0, '\n'); 449 if (c1 == (char *) NULL) { 450 Nstart = strlen (c0); 451 memmove (buffer, c0, Nstart); 452 status = FALSE; 453 } else { 454 *c1 = 0; 455 } 456 if ((*c0 != '#') && (*c0 != '!')) { 457 for (i = 0; (i < Nvec) && status; i++) { 458 status = dparse_csv (&value, col[i], c0); 459 vec[i][0].elements.Flt[N] = value; 460 if (!status) vec[i][0].elements.Flt[N] = NAN; 461 } 462 if (status) N++; 463 } 464 c0 = c1 + 1; 465 if (N == NELEM) { 466 NELEM += 1000; 467 for (i = 0; i < Nvec; i++) { 468 REALLOCATE (vec[i][0].elements.Flt, opihi_flt, NELEM); 469 } 470 } 471 472 } 473 } 474 for (i = 0; i < Nvec; i++) { 475 REALLOCATE (vec[i][0].elements.Flt, opihi_flt, MAX (N,1)); 476 vec[i][0].Nelements = N; 477 } 478 479 free (vec); 480 free (col); 481 free (buffer); 482 return (TRUE); 483 484 } 485 486 # endif -
trunk/Ohana/src/opihi/cmd.data/tvcolors.c
r25757 r31667 5 5 int N, kapa; 6 6 char *name; 7 KapaImageData data;7 // KapaImageData data; 8 8 9 9 name = NULL; … … 13 13 remove_argument (N, &argc, argv); 14 14 } 15 if (!Get Image (&data, &kapa, name)) return (FALSE);15 if (!GetGraph (NULL, &kapa, name)) return (FALSE); 16 16 FREE (name); 17 17 -
trunk/Ohana/src/opihi/cmd.data/zplot.c
r20936 r31667 58 58 } 59 59 60 int zcplot (int argc, char **argv) { 61 62 int i, kapa; 63 opihi_flt *out; 64 double min, range; 65 Graphdata graphmode; 66 Vector *xvec, *yvec, *zvec, Zvec; 60 67 68 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 69 70 if (argc != 6) { 71 gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n"); 72 return (FALSE); 73 } 74 75 min = atof(argv[4]); 76 range = atof(argv[5]) - min; 77 78 /* find vectors */ 79 if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 80 if ((yvec = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE); 81 if ((zvec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE); 82 if (xvec[0].Nelements != yvec[0].Nelements) { 83 gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[2]); 84 return (FALSE); 85 } 86 if (xvec[0].Nelements != zvec[0].Nelements) { 87 gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]); 88 return (FALSE); 89 } 90 SetVector (&Zvec, OPIHI_FLT, zvec[0].Nelements); 91 out = Zvec.elements.Flt; 92 93 if (zvec[0].type == OPIHI_FLT) { 94 opihi_flt *in = zvec[0].elements.Flt; 95 for (i = 0; i < Zvec.Nelements; i++, in++, out++) { 96 *out = MIN (1.0, MAX (0.01, (*in - min) / range)); 97 } 98 } else { 99 opihi_int *in = zvec[0].elements.Int; 100 for (i = 0; i < Zvec.Nelements; i++, in++, out++) { 101 *out = MIN (1.0, MAX (0.01, (*in - min) / range)); 102 } 103 } 104 105 /* point size determined by Zvec */ 106 graphmode.style = 2; /* plot points */ 107 graphmode.color = -1; /* point color determined by Zvec */ 108 graphmode.etype = 0; /* no errorbars */ 109 PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode); 110 111 free (Zvec.elements.Ptr); 112 113 return (TRUE); 114 115 } 116 117 -
trunk/Ohana/src/opihi/dvo/gstar.c
r30612 r31667 155 155 if (dec1 < DEC[i]) found = TRUE; 156 156 157 r = SQ(Dec - DEC[i]) + SQ( Ra - RA[i]);157 r = SQ(Dec - DEC[i]) + SQ((Ra - RA[i])*cos(Dec*RAD_DEG)); 158 158 if (r < Radius2) { 159 159 k = N1[i]; -
trunk/Ohana/src/opihi/include/pantasks.h
r27435 r31667 108 108 int Nfailure; 109 109 int Ntimeout; 110 int Nskipexec; 110 111 111 112 double dtimeAve_alljobs, dtimeMin_alljobs, dtimeMax_alljobs; … … 216 217 int DeleteJob (Job *job); 217 218 void FreeJob (Job *job); 219 char *JobStateToString (JobStat state); 218 220 219 221 float CheckJobs (void); -
trunk/Ohana/src/opihi/include/shell.h
r31635 r31667 163 163 char *strip_version PROTO((char *input)); 164 164 165 // wrap readline in ohana mem functions: 166 char *opihi_readline PROTO((char *prompt)); 167 165 168 /* gprint functions */ 166 169 void gprintInit PROTO((void)); -
trunk/Ohana/src/opihi/lib.shell/CommandOps.c
r16888 r31667 106 106 } 107 107 108 /* we need a strcreate function that does NOT use the ohana memory management 109 * system to interact with some external libraries (which themselves free the memory) 110 */ 111 char *strcreate_sans_ohana (char *string) { 112 113 char *line; 114 115 if (string == (char *) NULL) return ((char *) NULL); 116 117 line = malloc (MAX (1, strlen(string)) + 1); 118 line = strcpy (line, string); 119 120 return (line); 121 } 122 108 123 /* generate a command completion list for readline */ 109 124 /**** these probably do not interact well with OHANA memory!!! ****/ … … 122 137 for (i++; i < Ncommands; i++) { 123 138 if (!len) 124 return (strcreate(commands[i].name)); 139 140 141 return (strcreate_sans_ohana(commands[i].name)); 125 142 if (!strncmp (commands[i].name, text, len)) { 126 return (strcreate (commands[i].name));143 return (strcreate_sans_ohana(commands[i].name)); 127 144 } 128 145 } -
trunk/Ohana/src/opihi/lib.shell/macro_create.c
r16444 r31667 68 68 69 69 /* get the next line (from correct place) */ 70 if (ThisList == 0) 71 input = readline (prompt);72 else70 if (ThisList == 0) { 71 input = opihi_readline (prompt); 72 } else { 73 73 input = get_next_listentry (ThisList); 74 } 74 75 75 76 if ((ThisList == 0) && (input == (char *) NULL)) { … … 77 78 continue; 78 79 } 79 if (ThisList == 0) ohana_memregister (input);80 80 81 81 if ((ThisList > 0) && (input == (char *) NULL)) { -
trunk/Ohana/src/opihi/lib.shell/opihi.c
r16473 r31667 19 19 if (Nbad == 10) exit (20); 20 20 21 line = readline (prompt);21 line = opihi_readline (prompt); 22 22 23 23 if (line == NULL) { … … 36 36 37 37 Nbad = 0; 38 ohana_memregister (line);39 38 40 39 stripwhite (line); -
trunk/Ohana/src/opihi/lib.shell/string.c
r15878 r31667 276 276 } 277 277 278 char *opihi_readline (char *prompt) { 279 280 # ifdef OHANA_MEMORY 281 char *raw = readline (prompt); 282 char *line = strcreate (raw); 283 real_free (raw); 284 return line; 285 # else 286 char *line = readline (prompt); 287 return line; 288 # endif 289 } 290 278 291 /* replace all instances of \A with A in line */ 279 292 void interpolate_slash (char *line) {
Note:
See TracChangeset
for help on using the changeset viewer.
