stream discharging battery data crop utility
crop_vbat.awk reads numeric voltage samples from standard input or files and extracts (crops) discharge segments based on monotonic voltage behavior. It is designed as a UNIX-style stream filter that can be composed with small tools.
crop_vbat.awk
[-v v_start=V]
[-v v_term=V]
[-v v_delta=V]
[-v v_abn=V]
[-v cont=N]
[-v myname=NAME]
[FILE ...]
Input must contain one numeric value per line. Non-numeric lines are rejected and reported to stderr. All computations are done numerically, but output preserves the original text format.
Start and termination of a discharge segment are detected using either delta-based or absolute threshold criteria. Multiple segments can be extracted from one stream when continuation mode is enabled.
Accepted examples:
+01.234
0.98
3.01E+00
.75
2.
Start condition (output enabled):
v_start not specified: current < previous - v_deltav_start specified: current < v_startTermination condition (output disabled):
v_term not specified: current - previous > v_deltav_term specified: current < v_termAll options are given via awk -v variables.
Cropped samples are written to stdout unchanged. Diagnostic messages are written to stderr with the program label prefix.
Extract a voltage column and crop one discharge segment:
cut -f 4 data.tsv | crop_vbat.awk
Use explicit thresholds:
crop_vbat.awk -v v_start=1.25 -v v_term=0.95 log.txt
Allow three discharge segments:
crop_vbat.awk -v cont=3 log.txt
Capacity estimate with fixed interval and load:
cut -f 4 sample1.dat \
| crop_vbat.awk \
| stats.awk -v out=tsv \
| grep sum \
| awk -v r=2.5 -v dt=10 '{print $2 * dt / r / 3600 * 1000}'
Download
crop_vbat.awk-1.01.tar.gz — SPDX-License-Identifier: BSD-3-Clause
Archive contains SHA256 and MD5 hash files.
SHA256 (crop_vbat.awk) = 25c3aa6c3ff62ad085f3c4cf19bfea486810f7fe6faec62a0429ccb402bd9a7f
MD5 (crop_vbat.awk) = 83c3400f7ca388c1e81f7745bec8cfab
Users can verify the distributed crop_vbat.awk using:
sha256 crop_vbat.awk
md5 crop_vbat.awk



© 2000 Takayuki HOSODA.