Tableaux multidimensionnels

Programmation parallèle avec Dask en Python

James Fulton

Climate Informatics Researcher

Types de données multidimensionnelles

  • Prévisions/observations météo
  • Examens biomédicaux 3D
  • Images satellitaires
  • Données d'autres instruments scientifiques
Programmation parallèle avec Dask en Python

HDF5

Le logo HDF

  • Hierarchical Data Format
  • Stocké de façon hiérarchique, comme des (sous-)répertoires
Programmation parallèle avec Dask en Python

À quoi ressemble un fichier HDF5 ?

Un seul dossier

Programmation parallèle avec Dask en Python

À quoi ressemble un fichier HDF5 ?

Un seul dossier contenant quatre ensembles de données et des métadonnées.

Programmation parallèle avec Dask en Python

Navigation dans les fichiers HDF5 avec h5py

import h5py

# Open the HDF5 file
file = h5py.File('data.hdf5')


# Print the available datasets inside the file print(file.keys())
<KeysViewHDF5 ['A', 'B', 'C', 'D']}>
Programmation parallèle avec Dask en Python

Navigation dans les fichiers HDF5 avec h5py

import h5py

# Open the HDF5 file
file = h5py.File('data.hdf5')


# Select dataset A dataset_a = file['/A']
print(dataset_a)
<HDF5 dataset "A": shape (10000, 100, 100), type "<f4">
Programmation parallèle avec Dask en Python

Chargement depuis HDF5

import dask.array as da

# Load dataset into a Dask array a = da.from_array(dataset_a, chunks=(100, 20, 20))
print(a)
dask.array<array, shape=(10000, 100, 100), dtype=float32, chunksize=(100, 20, 20),
    chunktype=numpy.ndarray>
Programmation parallèle avec Dask en Python

Zarr

  • Ensemble hiérarchique comme HDF5
  • Conçu pour être en blocs (chunked)
  • Idéal pour la diffusion en continu sur AWS, Google Cloud, etc.
  • Structure de fichiers navigable
Programmation parallèle avec Dask en Python

Chargement depuis Zarr

import dask.array as da

a = da.from_zarr("dataset.zarr", component="A")


print(a)
dask.array<from-zarr, shape=(10000, 100, 100), dtype=float32,
    chunksize=(100, 20, 20), chunktype=numpy.ndarray>
Programmation parallèle avec Dask en Python

Passons à la pratique !

Programmation parallèle avec Dask en Python

Preparing Video For Download...