Skip to content

esiealab/android-runner-data

Repository files navigation

android_runner_data

A Python module for extracting, analyzing, and visualizing temporal energy consumption data from Android experiments generated by Android Runner. The module is designed to be extensible, robust, and easy to use for research and engineering purposes.

Features

  • Unified Data Abstraction: Abstract base class (BaseEnergyDataSource) for all energy data sources, with standard columns and methods.
  • Source-Specific Subclasses: Easily extendable for new data sources (e.g., BatteryManager, Wattometer).
  • Automatic Experiment Loading: Load single or batch experiments from JSON-like configuration.
  • Computation of Key Metrics: Calculates energy (Wh, Joules), average power, standard deviation, min/max power, experiment duration, and start time.
  • Plotting: Visualize power curves and compare multiple experiments using the integrated plotting class.
  • Logging: Built-in logger for debug, info, and error messages.

Main Classes

  • BaseEnergyDataSource: Abstract base class for all energy data sources. Handles loading, parsing, and computing metrics from time series data.
  • BatteryManagerEnergyDataSource: Subclass for BatteryManager CSV data.
  • WattoMeterEnergyDataSource: Subclass for Wattometer CSV data.
  • DataSourcePlotter: Class for plotting power curves and comparing experiments.

Usage Example

from android_runner_data import BaseEnergyDataSource
from android_runner_data.plotter import DataSourcePlotter

EXPERIMENTS = [
    {
        "name": "BatteryManager TikTok",
        "source_type": "batterymanager",
        "data_path": "experience/data/Pixel3W/com-zhiliaoapp-musically/batterymanager"
    },
    {
        "name": "WattoMeter TikTok",
        "source_type": "wattometer",
        "data_path_global": "Resultat_campagne_Pixel3_avec_stalkerware/TikTok/output",
        "data_path": "data/Pixel3W/com-zhiliaoapp-musically/wattometer"
    }
]

data_sources = BaseEnergyDataSource.load_experiments(EXPERIMENTS)
for ds in data_sources:
    print(f"Name: {ds.name}")
    print(f"Source: {ds.source}")
    print(f"File: {ds.data_file_name}")
    print(f"Start Time: {ds.start_time}")
    print(f"Duration (s): {ds.duration_seconds}")
    print(f"Energy (Wh): {ds.energy_wh}")
    print(f"Average Power (W): {ds.power_avg}")
    print(f"Min Power (W): {ds.power_min}")
    print(f"Max Power (W): {ds.power_max}")
    print(f"Std Power (W): {ds.power_std}")

# Plotting
plotter = DataSourcePlotter(data_sources)
plotter.plot_power(title="Comparison of measured power")

Extending the Module

To add a new data source, create a subclass of BaseEnergyDataSource and implement the _load_data_impl method to parse your specific format. Register your class in the SOURCE_CLASS_MAP in __init__.py.

Requirements

  • Python 3.8+
  • pandas
  • numpy
  • matplotlib

License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •