Tip

An interactive online version of this notebook is available, which can be accessed via Open this notebook in Google Colab


Alternatively, you may download this notebook and run it offline.

PyBaMM DataLoader#

This notebook is a reference for using pybamm.DataLoader module for using and fetching data files from the pybamm-data registry. Checkout the documentation for further implementation details on this module.

The following steps provide an example for using pybamm.DataLoader to download data files from PyBaMM data registry upstream at pybamm-data.

1. Creating DataLoader instance and listing data files present in the registry.#

[1]:
%pip install "pybamm[plot,cite]" -q    # install PyBaMM if it is not installed
import pybamm

data_loader = pybamm.DataLoader()
data_loader.show_registry()
Note: you may need to restart the kernel to use updated packages.
An NVIDIA GPU may be present on this machine, but a CUDA-enabled jaxlib is not installed. Falling back to cpu.
[1]:
['comsol_01C.json',
 'comsol_05C.json',
 'comsol_1C.json',
 'comsol_1plus1D_3C.json',
 'comsol_2C.json',
 'comsol_3C.json',
 'Ecker_1C.csv',
 'Ecker_5C.csv',
 '0.1C_discharge_U.txt',
 '0.1C_discharge_displacement.txt',
 '0.5C_discharge_T.txt',
 '0.5C_discharge_U.txt',
 '0.5C_discharge_displacement.txt',
 '1C_discharge_T.txt',
 '1C_discharge_U.txt',
 '1C_discharge_displacement.txt',
 '2C_discharge_T.txt',
 '2C_discharge_U.txt',
 '2C_discharge_displacement.txt',
 'stn_2C.txt',
 'stp_2C.txt',
 'UDDS.csv',
 'US06.csv',
 'WLTC.csv',
 'car_current.csv']

2. Listing data files along with their checksums#

[2]:
data_loader.files
[2]:
{'comsol_01C.json': 'sha256:bc5136fe961e269453bdc31fcaa97376d6f8c347d570fd30ce4b7660c68ae22c',
 'comsol_05C.json': 'sha256:3b044135ad88bdb88959304a33fe42b654d5ef7ef79d1271dd909cec55b257fb',
 'comsol_1C.json': 'sha256:d45e3ab482c497c37ebbc68898da22bab0b0263992d8f2302502028bfd5ba0e9',
 'comsol_1plus1D_3C.json': 'sha256:cdd5759202f9c7887d2ea6032f82212f2ca89297191fe5282b8812e1a09b1e1f',
 'comsol_2C.json': 'sha256:15c2637f54bf1639621c58795db859cb08611c8182b7b20ade10e4c3e2839a5b',
 'comsol_3C.json': 'sha256:11d5afccb70be85d4ac7e61d413c6e0f5e318e1635b1347c9a3c6784119711e6',
 'Ecker_1C.csv': 'sha256:428dc5113a6430492f430fb9e895f67d3e20f5643dc49a1cc0a922b92a5a8e01',
 'Ecker_5C.csv': 'sha256:a89f8bf6e305b2a4195e1fae5e803277a40ed7557d263ef726f621803dcbb495',
 '0.1C_discharge_U.txt': 'sha256:7b9fcd137441eea4ab686faee8d57fe242c5544400939ef358ccd99c63c9579d',
 '0.1C_discharge_displacement.txt': 'sha256:f1329731ead5a82a2be9851cf80e4c6d68dd0774e07aee5361e2af3ab420d7be',
 '0.5C_discharge_T.txt': 'sha256:2140b2f6bd698135d09a25b1f04c271d35a3a02999ace118b10389e01defa2ae',
 '0.5C_discharge_U.txt': 'sha256:9ed8368b2c6149d2a69218e7df6aaade2511c9f7f6fc7932cda153d9a3a10f39',
 '0.5C_discharge_displacement.txt': 'sha256:8098565ff99bc938864797b402f483c1c64a583d6db85d086f39ab0e7b638dd1',
 '1C_discharge_T.txt': 'sha256:97308dfd7f7dd6c434e30f6c00fb6707c43c963855bb0800e0336809d5cc3756',
 '1C_discharge_U.txt': 'sha256:8fc19de45172215d65c56522c224e6fc700ee443db236b814238a829b7a14c3a',
 '1C_discharge_displacement.txt': 'sha256:c2e8617ac48a20921da1b40bbebac479a0a143edf16b12b2e1ff9aaaf1a32ff4',
 '2C_discharge_T.txt': 'sha256:4bd688fb7653539701fe3df61857474b4d54e8b142c84fdc4c8b92b9573fa5d0',
 '2C_discharge_U.txt': 'sha256:7b3c24b5e6df377075002abc2f62bab7c88b27d826812ba5a4c8385a1a12e723',
 '2C_discharge_displacement.txt': 'sha256:2b11513d80827c762325c819a084b87b3a239af7d112f234c9871481760a0013',
 'stn_2C.txt': 'sha256:bb2f90ccfd2cd86ad589287caae13470e554df2f4f47f0f583a5a7e3e6bd9d4c',
 'stp_2C.txt': 'sha256:6fe73b3a18e5fcfb95151dfd7d34c3cbe929792631447ed3ec88c047c9778223',
 'UDDS.csv': 'sha256:9fe6558c17aad3cc08109186923aeb7459cd3097a381c44e854bf22dd12a5a2a',
 'US06.csv': 'sha256:5909eb2ec7983fae86a050ff3b35a2041d0ab698710a6b0f95d5816e348077ba',
 'WLTC.csv': 'sha256:bb2f95018a44ac1425cb9c787c34721192af502c7385f1358f28e4f75df11fd8',
 'car_current.csv': 'sha256:4305b91b9df073cb048c25dd3fae725e06a94fe200e322e5c08db290d6799e36'}

3. Fetching a file from upstream and storing it in local cache folder#

[3]:
data_loader.get_data("Ecker_1C.csv")
[3]:
PosixPath('/home/santa/.cache/pybamm/v1.0.0/Ecker_1C.csv')

4. Loading a file from cache into python code#

[4]:
import pandas as pd

pd.read_csv(data_loader.get_data("Ecker_1C.csv"))
[4]:
20.3084233101775 4.10984760218981
0 137.255118 4.061710
1 247.454889 4.020866
2 393.638258 3.981480
3 530.825727 3.940636
4 670.262171 3.911462
5 820.943489 3.874994
6 955.881984 3.845819
7 1097.567403 3.812269
8 1243.750772 3.790388
9 1383.187216 3.761213
10 1529.370585 3.736415
11 1666.558054 3.724745
12 1808.243473 3.705782
13 1947.679917 3.698488
14 2087.116361 3.688277
15 2231.050755 3.675149
16 2379.483099 3.660562
17 2521.168518 3.635763
18 2658.355987 3.600754
19 2802.290381 3.554075
20 2939.477850 3.510313
21 3081.163269 3.473845
22 3225.097663 3.430084
23 3344.293333 3.381946
24 3470.235928 3.307551
25 3553.447999 3.212734
26 3616.419296 3.115000
27 3652.402895 3.018724
28 3688.386493 2.899109
29 3715.374192 2.766366
[ ]: