wanna_code_perl has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I have an accelerometer with onboard firmware that generates CSV files with records at 80Hz but only when there is activity. Empirical analysis suggests the mean rate is around 6.0Hz. The CSV has records like this:
17077.395763,-739,1059,-16734If you want to see a sample data file, you can download a <5 hour sample here: accel.csv (3.0MB CSV).
The columns are seconds (since recording began), and x,y,z accelerometer values in 16384*g signed 16-bit precision.
Now, the problem is these files are a rather inefficient use of space. To the extent that disk is (not) cheap in my application, I need to reduce their size.
As a first cut, I post-process the files with pack('fsss',...), which gives about 3:1 reduction. Note that the last two digits of the timestamp are spurious, so it can be converted to a single-precision float.
Further compressing the output with xz or bzip2 brings that up to about 5.5:1 (compression alone without pack() was about 4:1).
Finally I started conditionally storing the time as 8-bit delta 1/10000 second values if the delta from the previous record is sufficiently small (at 80Hz, it is), otherwise I store a (magic) 0 followed by unsigned 32-bit 1/10000 seconds. Hence, the record is either Csss (98.5% of records) or CLsss (1.5% of records). This brought the ratio up to 6.5:1 after compression with xz, at the cost of a little more complexity.
Can I improve significantly on 6.5:1 before I move on to lossy methods, such as reducing the frequency and resolution?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Specialized data compression
by GrandFather (Saint) on Sep 11, 2012 at 08:50 UTC | |
by wanna_code_perl (Friar) on Sep 16, 2012 at 16:12 UTC | |
|
Re: Specialized data compression
by salva (Canon) on Sep 11, 2012 at 09:28 UTC | |
by wanna_code_perl (Friar) on Sep 16, 2012 at 16:37 UTC | |
|
Re: Specialized data compression
by Anonymous Monk on Sep 11, 2012 at 01:26 UTC | |
by wanna_code_perl (Friar) on Sep 11, 2012 at 01:53 UTC | |
|
Re: Specialized data compression
by Kenosis (Priest) on Sep 11, 2012 at 19:36 UTC | |
|
Re: Specialized data compression
by danaj (Friar) on Sep 17, 2012 at 17:45 UTC | |
|
Re: Specialized data compression
by QM (Parson) on Oct 04, 2012 at 09:34 UTC |