- Timestamp:
- Feb 4, 2023, 7:36:15 AM (3 years ago)
- Location:
- branches/eam_branches/ipp-20220316/Ohana
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/opihi/cmd.data/threshold.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20220316/Ohana
- Property svn:mergeinfo changed
/tags/ipp-ops-20220303-rc/Ohana (added) merged: 42123 /trunk/Ohana merged: 42277-42278,42285,42311,42332
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/threshold.c
r42156 r42361 1 1 # include "data.h" 2 3 int QUIET = FALSE; 4 5 void _threshold_set_values (double value, int Nbin, double level, int thresherr) { 6 7 set_variable ("threshval", value); 8 set_int_variable ("threshbin", Nbin); 9 set_variable ("threshold", level); 10 set_int_variable ("thresherr", thresherr); 11 12 if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", level, Nbin, value); 13 return; 14 } 2 15 3 16 int threshold (int argc, char **argv) { … … 6 19 Vector *vecx, *vecy; 7 20 8 int QUIET = FALSE;9 21 if ((N = get_argument (argc, argv, "-q"))) { 10 22 QUIET = TRUE; 23 remove_argument (N, &argc, argv); 24 } 25 26 int SATURATE = FALSE; 27 if ((N = get_argument (argc, argv, "-saturate"))) { 28 SATURATE = TRUE; 29 remove_argument (N, &argc, argv); 30 } 31 if ((N = get_argument (argc, argv, "-sat"))) { 32 SATURATE = TRUE; 11 33 remove_argument (N, &argc, argv); 12 34 } … … 95 117 // this algorithm assumes vecy[BinMax] > threshold, vecy[BinMin] < threshold 96 118 if (vecy[0].elements.Flt[BinMin] > value) { 97 if (!QUIET) gprint (GP_ERR, "ERROR: all values above threshold\n"); 98 set_int_variable ("threshbin", BinMin); 99 set_variable ("threshval", vecy[0].elements.Flt[BinMin]); 100 set_variable ("threshold", vecx[0].elements.Flt[BinMin]); 101 set_int_variable ("thresherr", 1); 102 if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", 103 vecx[0].elements.Flt[BinMin], BinMin, 104 vecy[0].elements.Flt[BinMin]); 105 return TRUE; 119 if (SATURATE) { 120 _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin], 1); 121 return TRUE; 122 } else { 123 gprint (GP_ERR, "ERROR: all values above threshold\n"); 124 _threshold_set_values (NAN, -1, NAN, 1); 125 return FALSE; 126 } 106 127 } 107 128 if (vecy[0].elements.Flt[BinMax] < value) { 108 if (!QUIET) gprint (GP_ERR, "ERROR: all values below threshold\n"); 109 set_int_variable ("threshbin", BinMax); 110 set_variable ("threshval", vecy[0].elements.Flt[BinMax]); 111 set_variable ("threshold", vecx[0].elements.Flt[BinMax]); 112 set_int_variable ("thresherr", 1); 113 if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", 114 vecx[0].elements.Flt[BinMax], BinMax, 115 vecy[0].elements.Flt[BinMax]); 116 return TRUE; 129 if (SATURATE) { 130 _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax], 1); 131 return TRUE; 132 } else { 133 gprint (GP_ERR, "ERROR: all values below threshold\n"); 134 _threshold_set_values (NAN, -1, NAN, 1); 135 return FALSE; 136 } 117 137 } 118 138 while (Nhi - Nlo > 10) { … … 136 156 // this algorithm assumes vecy[BinMin] > threshold, vecy[BinMax] < threshold 137 157 if (vecy[0].elements.Flt[BinMin] < value) { 138 if (!QUIET) gprint (GP_ERR, "ERROR: all values below threshold\n"); 139 set_int_variable ("threshbin", BinMin); 140 set_variable ("threshval", vecy[0].elements.Flt[BinMin]); 141 set_variable ("threshold", vecx[0].elements.Flt[BinMin]); 142 set_int_variable ("thresherr", 1); 143 if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", 144 vecx[0].elements.Flt[BinMin], BinMin, 145 vecy[0].elements.Flt[BinMin]); 146 return TRUE; 158 if (SATURATE) { 159 _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin], 1); 160 return TRUE; 161 } else { 162 gprint (GP_ERR, "ERROR: all values below threshold\n"); 163 _threshold_set_values (NAN, -1, NAN, 1); 164 return FALSE; 165 } 147 166 } 148 167 if (vecy[0].elements.Flt[BinMax] > value) { 149 if (!QUIET) gprint (GP_ERR, "ERROR: all values above threshold\n"); 150 set_int_variable ("threshbin", BinMax); 151 set_variable ("threshval", vecy[0].elements.Flt[BinMax]); 152 set_variable ("threshold", vecx[0].elements.Flt[BinMax]); 153 set_int_variable ("thresherr", 1); 154 if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", 155 vecx[0].elements.Flt[BinMax], BinMax, 156 vecy[0].elements.Flt[BinMax]); 157 return TRUE; 168 if (SATURATE) { 169 _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax], 1); 170 return TRUE; 171 } else { 172 gprint (GP_ERR, "ERROR: all values above threshold\n"); 173 _threshold_set_values (NAN, -1, NAN, 1); 174 return FALSE; 175 } 158 176 } 159 177 while (Nhi - Nlo > 10) { … … 202 220 } 203 221 204 set_variable ("threshval", y1); 205 set_variable ("threshold", Xvalue); 206 set_int_variable ("threshbin", Nhi); 207 set_int_variable ("thresherr", 0); 208 209 if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", Xvalue, Nhi, y1); 210 222 _threshold_set_values (y1, Nhi, Xvalue, 0); 211 223 return (TRUE); 212 224 }
Note:
See TracChangeset
for help on using the changeset viewer.
