Changeset 41819
- Timestamp:
- Sep 27, 2021, 11:14:16 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-dev-20210817/Ohana/src/opihi/cmd.data/vstats.c
r38441 r41819 48 48 } 49 49 50 if (argc != 2) { 51 gprint (GP_ERR, "USAGE: vstat (vector) [-ignore value] [-q] [-quiet] [-iter Niter] [-sigma-clip Nsigma]\n"); 50 int valid = (argc == 2); 51 valid |= (argc > 3) && !strcmp (argv[2], "where"); 52 if (!valid) { 53 gprint (GP_ERR, "USAGE: vstat (vector) [-ignore value] [-q] [-quiet] [-iter Niter] [-sigma-clip Nsigma] [where (logical expression)]\n"); 52 54 gprint (GP_ERR, " default is 1 iteration without sigma clipping or 3 with sigma clipping\n"); 53 55 return (FALSE); … … 58 60 /* we need two passes, one for max, min, mean, sum, one for median, stdev, etc */ 59 61 60 // set a good / bad mask 62 // tvec is used for logical test (truth vector) 63 Vector *tvec = NULL; 64 if (argc > 3) { 65 int size; 66 char *out = dvomath (argc - 3, &argv[3], &size, 1); 67 if (out == NULL) { 68 print_error (); 69 return FALSE; 70 } 71 if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) { 72 gprint (GP_ERR, " invalid logic result\n"); 73 DeleteNamedVector (out); 74 free (out); 75 return (FALSE); 76 } 77 if (tvec->Nelements != vec->Nelements) { 78 gprint (GP_ERR, "logical vector does not match in length\n"); 79 return FALSE; 80 } 81 } 82 83 // set a good / bad mask (mask == 1 means 'bad') 61 84 ALLOCATE (mask, char, vec[0].Nelements); 62 85 if (vec[0].type == OPIHI_FLT) { 63 86 opihi_flt *X = vec[0].elements.Flt; 64 87 for (i = 0; i < vec[0].Nelements; i++, X++) { 65 mask[i] = 1; 88 if (tvec) { 89 // note the logical vector is 0 == bad (ignore) 90 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0); 91 } else { 92 mask[i] = 1; 93 } 66 94 if (!finite (*X)) continue; 67 95 if (Ignore && (*X == IgnoreValue)) continue; … … 71 99 opihi_int *X = vec[0].elements.Int; 72 100 for (i = 0; i < vec[0].Nelements; i++, X++) { 73 mask[i] = 1; 101 if (tvec) { 102 // note the logical vector is 0 == bad (ignore) 103 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0); 104 } else { 105 mask[i] = 1; 106 } 74 107 if (!finite (*X)) continue; 75 108 if (Ignore && (*X == IgnoreValue)) continue;
Note:
See TracChangeset
for help on using the changeset viewer.
