Battify
Standardize battery data

# Python # pandas # React # Fastapi # PostgreSQL

Video

Abstract

Battify is a Python project designed to clean, standardize, and efficiently store battery data in a database. It includes a user-friendly web interface for easy access and management. The project ensures high data integrity through thorough testing.


Key Features

  • Supports multiple file formats, including .mat, .csv, and .json
  • Cleans and processes raw battery data
  • Standardizes data formats for consistency
  • Loads data into a database
  • Provides web interface for seamless user interaction

User Interface

We developed the frontend using React, with Material UI for components and Tailwind CSS for styling.

Challenges & Solutions

1. Handling Charging/Discharging Transitions

Used shift() to compare the current and previous SoC values, but cannot recognize idle states.
  • Addressed momentary idle states by ignoring short idle durations and tracking state transitions efficiently.
  • Updating several previous rows marked as idle when a transition occurs, like idle to charging/discharging and idle state are short. (Checking current state is charging/discharging)
  • Resetting idle_count when battery starts charging or discharging
  • Increasing idle_count when the battery remains idle

2. Performance Optimization

Initially used iterrows() but found it slow for large datasets.

Switched to df.apply(lambda row: function(), axis=1), significantly improving speed.

3. Cycle Counting

description: Increased the cycle number with every charging/discharging transition.

Initially planned to increase the cycle number during state recognition. However, due to idle states, previous cycle numbers need adjustment. Since lambda function cannot update past rows, I handled it after setting all state. Using shift() to find the transitions and define cycles.

Key limitation of lambda

  • Unlike iterrows(), lambda cannot modify previously processed rows in the DataFrame.
  • To work around this, stored necessary updates in a dictionary and applied them in a separate step.

Acknowledgements

We thank Prof. David Beck for his constructive advice on this project.
Battify is sponsored by Astrolabe Analystics.