Feature extraction pipeline for battery cycling, BDS exports, and LLM-ready battery diagnostics.
Project description
BFL: Battery Feature Lab
BFL extracts battery cycling features from BDS-style exports and common cycler tables. It turns raw time-series data into feature tables for SOH/RUL modeling, feature screening, explainability, and compact diagnostic summaries.
Features
- Cycle summaries: capacity, energy, efficiency, C-rate, voltage, temperature, and rest time.
- Early-life curve features:
Delta Q(V)variance, norms, quantiles, and related statistics. - ICA/DVA features:
dQ/dVanddV/dQpeaks, locations, widths, heights, and areas. - Relaxation features: voltage drop, slopes, interpolated voltages, and exponential fits.
- Stress features: SOC, voltage, current, C-rate, temperature histograms, and high-SOC rest time.
- EIS descriptors when impedance columns are available.
- Rule-based degradation tags for LLI, LAM_PE, LAM_NE, resistance growth, and related evidence.
- LLM-ready JSONL summaries for downstream review or diagnostic workflows.
Installation
From PyPI:
pip install battery-feature-lab
From a local checkout:
python -m pip install -e ".[dev]"
Quick Start
Python:
from pathlib import Path
import bfl
result = bfl.extract(
"/content/25-LFP-1.csv",
output_dir="/content/bfl_outputs",
nominal_capacity_ah=1.2,
reference_cycle=2,
target_cycle=5,
)
print(result.llm_context_path)
for path in result.files:
print(path.name)
CLI:
bfl extract input.csv --output-dir out --cell-id cell_001 --nominal-capacity-ah 1.1
The longer command name is also available:
battery-features extract input.csv --output-dir out --cell-id cell_001 --nominal-capacity-ah 1.1
Diagnostic thresholds are configurable:
bfl extract input.csv \
--output-dir out \
--nominal-capacity-ah 1.1 \
--datasheet-max-discharge-c-rate 5 \
--high-soc-rest-threshold 0.25
Input Data
BFL accepts CSV, TSV, JSON, JSONL, and Parquet files. Input data can use common cycler/BDS column names. The reader normalizes aliases to:
time_s, voltage_v, current_a, temperature_c, charge_capacity_ah,
discharge_capacity_ah, cycle_index, step_index, step_type
At minimum, the input should contain time, voltage, current, and enough cycle/step information
to identify charge, discharge, and rest periods. If cell_id, cycle_index, or step_type is
missing, BFL can infer or fill parts of the schema from the file name, current sign, and command
line options.
Optional EIS columns are:
frequency_hz, z_real_ohm, z_imag_ohm
Outputs
BFL writes non-empty tables to the selected output directory:
out/
normalized_timeseries.parquet
cycle_features.parquet
delta_q_features.parquet
ica_dva_features.parquet
relaxation_features.parquet
stress_features.parquet
degradation_tags.parquet
llm_context.jsonl
run_metadata.json
Validation
Run the offline self-test:
python scripts/validate_on_dataset.py --synthetic 12
Run validation on a folder of per-cell CSV files:
python scripts/validate_on_dataset.py --data-dir path/to/cells --nominal-capacity-ah 1.1
Python Usage
from pathlib import Path
from battery_feature_lab.pipeline import FeaturePipeline, PipelineConfig
from battery_feature_lab.schemas import ExportConfig, FeatureConfig, ReaderConfig
pipeline = FeaturePipeline(
PipelineConfig(
reader=ReaderConfig(cell_id="cell_001"),
features=FeatureConfig(nominal_capacity_ah=1.1),
export=ExportConfig(output_dir=Path("out")),
)
)
tables = pipeline.run("input.csv")
Development
python -m pip install -e ".[dev]"
python -m pytest
python -m ruff check .
License
MIT License. See LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file battery_feature_lab-0.1.2.tar.gz.
File metadata
- Download URL: battery_feature_lab-0.1.2.tar.gz
- Upload date:
- Size: 34.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4dcf5f2bafe9aad67dba03853f5ffa1f7a55bcb4e4489d7d5ba4d4c75588609
|
|
| MD5 |
91fe4329093b0e95cfc0577947af39a1
|
|
| BLAKE2b-256 |
cb4dcd6f5ba8c14c41fdec0ee0634fa9351ac2b3ff6621fe9cd200972b7ec9b6
|
File details
Details for the file battery_feature_lab-0.1.2-py3-none-any.whl.
File metadata
- Download URL: battery_feature_lab-0.1.2-py3-none-any.whl
- Upload date:
- Size: 42.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11b673cc889d943fd4a667505bcf15cb93f749196abfc29df4a5bc1a89849eee
|
|
| MD5 |
3b58625b96b4d10daba755f4df740fd4
|
|
| BLAKE2b-256 |
dbac7d4cc60f7032b5029544dd9c6d15bd1d6145d4e8aa575f13b376a2ce3260
|