From 868619e659518aec41b2092ed4050dbb9339130f Mon Sep 17 00:00:00 2001 From: cnlohr Date: Tue, 24 Jan 2017 00:56:18 -0500 Subject: Much better processing, including point culling. --- tools/process_rawcap/process_to_points.c | 48 +++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'tools/process_rawcap/process_to_points.c') 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++ ) -- cgit v1.2.3