Changeset 42277 for trunk/Ohana/src/opihi/cmd.data/threshold.c
- Timestamp:
- Sep 2, 2022, 11:27:31 AM (4 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/threshold.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/threshold.c
r41341 r42277 1 1 # include "data.h" 2 3 int QUIET = FALSE; 4 5 void _threshold_set_values (double value, int Nbin, double level) { 6 7 set_variable ("threshval", value); 8 set_int_variable ("threshbin", Nbin); 9 set_variable ("threshold", level); 10 11 if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", level, Nbin, value); 12 return; 13 } 2 14 3 15 int threshold (int argc, char **argv) { … … 6 18 Vector *vecx, *vecy; 7 19 8 int QUIET = FALSE;9 20 if ((N = get_argument (argc, argv, "-q"))) { 10 21 QUIET = TRUE; 22 remove_argument (N, &argc, argv); 23 } 24 25 int SATURATE = FALSE; 26 if ((N = get_argument (argc, argv, "-saturate"))) { 27 SATURATE = TRUE; 28 remove_argument (N, &argc, argv); 29 } 30 if ((N = get_argument (argc, argv, "-sat"))) { 31 SATURATE = TRUE; 11 32 remove_argument (N, &argc, argv); 12 33 } … … 95 116 // this algorithm assumes vecy[BinMax] > threshold, vecy[BinMin] < threshold 96 117 if (vecy[0].elements.Flt[BinMin] > value) { 97 gprint (GP_ERR, "ERROR: all values above threshold\n"); 98 return FALSE; 118 if (SATURATE) { 119 _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin]); 120 return TRUE; 121 } else { 122 gprint (GP_ERR, "ERROR: all values above threshold\n"); 123 _threshold_set_values (NAN, -1, NAN); 124 return FALSE; 125 } 99 126 } 100 127 if (vecy[0].elements.Flt[BinMax] < value) { 101 gprint (GP_ERR, "ERROR: all values below threshold\n"); 102 return FALSE; 128 if (SATURATE) { 129 _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax]); 130 return TRUE; 131 } else { 132 gprint (GP_ERR, "ERROR: all values below threshold\n"); 133 _threshold_set_values (NAN, -1, NAN); 134 return FALSE; 135 } 103 136 } 104 137 while (Nhi - Nlo > 10) { … … 122 155 // this algorithm assumes vecy[BinMin] > threshold, vecy[BinMax] < threshold 123 156 if (vecy[0].elements.Flt[BinMin] < value) { 124 gprint (GP_ERR, "ERROR: all values below threshold\n"); 125 return FALSE; 157 if (SATURATE) { 158 _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin]); 159 return TRUE; 160 } else { 161 gprint (GP_ERR, "ERROR: all values below threshold\n"); 162 _threshold_set_values (NAN, -1, NAN); 163 return FALSE; 164 } 126 165 } 127 166 if (vecy[0].elements.Flt[BinMax] > value) { 128 gprint (GP_ERR, "ERROR: all values above threshold\n"); 129 return FALSE; 167 if (SATURATE) { 168 _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax]); 169 return TRUE; 170 } else { 171 gprint (GP_ERR, "ERROR: all values above threshold\n"); 172 _threshold_set_values (NAN, -1, NAN); 173 return FALSE; 174 } 130 175 } 131 176 while (Nhi - Nlo > 10) { … … 174 219 } 175 220 176 set_variable ("threshval", y1); 177 set_int_variable ("threshbin", Nhi); 178 set_variable ("threshold", Xvalue); 179 180 if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", Xvalue, Nhi, y1); 181 221 _threshold_set_values (y1, Nhi, Xvalue); 182 222 return (TRUE); 183 223 }
Note:
See TracChangeset
for help on using the changeset viewer.
