aboutsummaryrefslogtreecommitdiff
path: root/tools/process_rawcap/process_to_points.c
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2017-01-24 00:56:18 -0500
committercnlohr <lohr85@gmail.com>2017-01-24 00:56:18 -0500
commit868619e659518aec41b2092ed4050dbb9339130f (patch)
treed083b484bf3d6c18d1abe8ec96c2c2acab2e92a8 /tools/process_rawcap/process_to_points.c
parenteb9893e94aa555fab569ffe6fe16153652125d50 (diff)
downloadlibsurvive-868619e659518aec41b2092ed4050dbb9339130f.tar.gz
libsurvive-868619e659518aec41b2092ed4050dbb9339130f.tar.bz2
Much better processing, including point culling.
Diffstat (limited to 'tools/process_rawcap/process_to_points.c')
-rw-r--r--tools/process_rawcap/process_to_points.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/tools/process_rawcap/process_to_points.c b/tools/process_rawcap/process_to_points.c
index 35589ec..8a48bae 100644
--- a/tools/process_rawcap/process_to_points.c
+++ b/tools/process_rawcap/process_to_points.c
@@ -119,23 +119,60 @@ int main( int argc, char ** argv )
double sumlentime = 0;
int count = 0;
+
+ //First make a rough histogram to find the peak, discard points not anywhere close to peak.
+#define MAX_LENTIME 200000 //800000/4
+#define MAX_PERMISSABLE_TO_PEAK 40
+
+ int biggesttime = 0;
+ int biggesttimeplace = -1;
+
+ {
+ int bincounts[MAX_LENTIME];
+ for( i = 0; i < dpmax; i++ )
+ {
+ int sweeptime = DATASWEEP[dev][sen][swe][i]/4;
+ if( sweeptime < 0 || sweeptime > MAX_LENTIME )
+ {
+ DATASWEEP[dev][sen][swe][i] = -1;
+ continue;
+ }
+ int rc = bincounts[sweeptime]++;
+ if( rc > biggesttime )
+ {
+ biggesttime = rc;
+ biggesttimeplace = sweeptime;
+ }
+ }
+ }
+
for( i = 0; i < dpmax; i++ )
{
int sweeptime = DATASWEEP[dev][sen][swe][i];
int datalen = DATALENGTH[dev][sen][swe][i];
+ int dist_to_peak = sweeptime/4 - biggesttimeplace ;
+
+ if( sweeptime < 0 ) continue;
+ if( dist_to_peak > MAX_PERMISSABLE_TO_PEAK || dist_to_peak < -MAX_PERMISSABLE_TO_PEAK )
+ {
+ DATASWEEP[dev][sen][swe][i] = -1;
+ continue;
+ }
sumsweeptime += sweeptime;
sumlentime += datalen;
count++;
}
+ if( count < 50 ) continue;
+
double avgsweep = sumsweeptime / count;
double avglen = sumlentime / count;
double stddevtim = 0;
double stddevlen = 0;
- #define HISTOGRAMSIZE 65
+ #define HISTOGRAMSIZE 31
int histo[HISTOGRAMSIZE];
memset( histo, 0, sizeof( histo ) );
@@ -145,6 +182,8 @@ int main( int argc, char ** argv )
int sweeptime = DATASWEEP[dev][sen][swe][i];
int datalen = DATALENGTH[dev][sen][swe][i];
+ if( sweeptime < 0 ) continue;
+
double Sdiff = sweeptime - avgsweep;
double Ldiff = datalen - avglen;
@@ -159,9 +198,16 @@ int main( int argc, char ** argv )
histo[llm]++;
}
+
stddevtim /= count;
stddevlen /= count;
+ if( stddevtim > 55 )
+ {
+ fprintf( stderr, "Warning: %s%s%02d dropped because stddev (%f) was too high.\n", Devices[dev], DevMap[swe], sen, stddevtim );
+ continue;
+ }
+
fprintf( hists, "%s%s%02d, ", Devices[dev], DevMap[swe], sen );
for( i = 0; i < HISTOGRAMSIZE; i++ )