Changeset 41891 for trunk/Ohana/src/opihi/cmd.data/vstats.c
- Timestamp:
- Nov 4, 2021, 6:02:11 PM (5 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/opihi/cmd.data/vstats.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-dev-20210817/Ohana (added) merged: 41800,41802,41818-41820,41824,41830,41835,41850,41869,41874-41875,41886
- Property svn:mergeinfo changed
-
trunk/Ohana/src/opihi/cmd.data/vstats.c
r38441 r41891 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; 66 if (!finite (*X)) continue; 67 if (Ignore && (*X == IgnoreValue)) continue; 68 mask[i] = 0; 88 mask[i] = 0; // do not mask unless we have a reason below 89 if (tvec) { 90 // note the logical vector is 0 == bad (ignore) while mask[i] has the opposite sense (0 is good) 91 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0); 92 } 93 if (!finite (*X)) { mask[i] = 1; } 94 if (Ignore && (*X == IgnoreValue)) { mask[i] = 1; } 69 95 } 70 96 } else { 71 97 opihi_int *X = vec[0].elements.Int; 72 98 for (i = 0; i < vec[0].Nelements; i++, X++) { 73 mask[i] = 1; 74 if (!finite (*X)) continue; 75 if (Ignore && (*X == IgnoreValue)) continue; 76 mask[i] = 0; 99 mask[i] = 0; // do not mask unless we have a reason below 100 if (tvec) { 101 // note the logical vector is 0 == bad (ignore) while mask[i] has the opposite sense (0 is good) 102 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0); 103 } 104 if (!finite (*X)) { mask[i] = 1; } 105 if (Ignore && (*X == IgnoreValue)) { mask[i] = 1; } 77 106 } 78 107 }
Note:
See TracChangeset
for help on using the changeset viewer.
