The main method uses the estimated percentage of battery remaining to predict when the percentage left will be a given value.
The input is a time series NetCDF with at least two columns:
- time a CF compliant time of the observation
- m_lithium_battery_relative_charge as defined by Slocum masterdata file
A compatible input NetCDF file is generated from my Slocum_DataHarvester in the sensors files.
A linear regression is done to:
m_lithium_battery_relative_charge = a + b (time - min(time))/86400
so the slope is in days.
pip install .This also installs a recover-by console command.
For development (includes ruff, mypy, pytest, pre-commit):
pip install ".[dev]"
pre-commit install
pre-commit install --hook-type pre-pushBasic usage:
recover-by sensor_data.ncWith plotting enabled:
recover-by --plot sensor_data.ncSave plot to a file (useful on headless/remote servers):
recover-by --output recovery.png sensor_data.ncMachine-readable JSON output:
recover-by --json sensor_data.ncUsing only the last N days of data:
recover-by --ndays 7 sensor_data.ncSpecifying a custom threshold:
recover-by --threshold 10 sensor_data.ncUsing a custom confidence level (default is 0.95):
recover-by --confidence 0.99 sensor_data.ncUsing a specific time range:
recover-by --start "2025-01-01" --stop "2025-01-15" sensor_data.ncFor verbose output:
recover-by --verbose sensor_data.ncThe script can also be run directly:
./SlocumBatteryPercentageDuration.py sensor_data.nc