Changeset 38406 for branches/eam_branches/ohana.20150429/src/opihi/cmd.data
- Timestamp:
- Jun 6, 2015, 10:03:56 AM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/opihi/cmd.data
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/cast.c
r36489 r38406 17 17 // out type 18 18 char outType = OPIHI_NOTYPE; 19 if (!strcasecmp(argv[5], "int")) outType = OPIHI_INT; 20 if (!strcasecmp(argv[5], "float")) outType = OPIHI_FLT; 19 if (!strcasecmp(argv[5], "int")) outType = OPIHI_INT; 20 if (!strcasecmp(argv[5], "float")) outType = OPIHI_FLT; 21 if (!strcasecmp(argv[5], "single")) outType = OPIHI_FLT; 22 if (!strcasecmp(argv[5], "int64")) outType = OPIHI_FLT; 21 23 if (outType == OPIHI_NOTYPE) goto usage; 24 25 int ForceSingle = FALSE; 26 if (!strcasecmp(argv[5], "single")) ForceSingle = TRUE; 27 28 int ForceI64 = FALSE; 29 if (!strcasecmp(argv[5], "int64")) ForceI64 = TRUE; 22 30 23 31 if ((ovec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto error; … … 32 40 opihi_flt *vo = ovec[0].elements.Flt; 33 41 for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) { 34 *vo = *vi; 42 if (ForceSingle) { 43 float tmp = *vi; 44 *vo = tmp; 45 } else if (ForceI64) { 46 int64_t tmp = *vi; 47 *vo = tmp; 48 } else { 49 *vo = *vi; 50 } 35 51 } 36 52 return (TRUE); … … 48 64 opihi_flt *vo = ovec[0].elements.Flt; 49 65 for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) { 50 *vo = *vi; 66 if (ForceSingle) { 67 float tmp = *vi; 68 *vo = tmp; 69 } else { 70 *vo = *vi; 71 } 51 72 } 52 73 return (TRUE); … … 66 87 67 88 usage: 68 gprint (GP_ERR, "SYNTAX: cast vec = vec as (int/float)\n"); 89 gprint (GP_ERR, "SYNTAX: cast vec = vec as (int/float/single)\n"); 90 gprint (GP_ERR, " note: (single) forces vector to have single precision\n"); 69 91 return (FALSE); 70 92 } -
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/read_vectors.c
r38367 r38406 487 487 } 488 488 if (start < 0) ESCAPE ("invalid range: start < 0\n"); 489 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny ( %d)\n", header.Naxis[1]);489 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny ("OFF_T_FMT")\n", header.Naxis[1]); 490 490 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n"); 491 491 492 492 // just a warning: 493 493 if (start + Nrows > header.Naxis[1]) { 494 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %drows\n", header.Naxis[1] - start);494 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only "OFF_T_FMT" rows\n", header.Naxis[1] - start); 495 495 } 496 496 … … 555 555 556 556 vecType = OPIHI_INT; 557 if (!strcmp (type, "double") || !strcmp (type, "float") ) {557 if (!strcmp (type, "double") || !strcmp (type, "float") || !strcmp (type, "int64_t")) { 558 558 vecType = OPIHI_FLT; 559 559 } -
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/vstats.c
r35109 r38406 121 121 goto skip; 122 122 } 123 // we can hit inf if pmax and pmin are close to the max range 124 if (isinf(dx)) dx = DBL_MAX / Nbin; 123 125 124 126 ALLOCATE (Nval, int, Nbin + 2);
Note:
See TracChangeset
for help on using the changeset viewer.
