Vícerozměrná pole

Parallel Programming with Dask in Python

James Fulton

Climate Informatics Researcher

Typy vícerozměrných dat

  • Předpovědi/záznamy počasí
  • 3D biomedicínské skeny
  • Satelitní snímky
  • Data z vědeckých přístrojů
Parallel Programming with Dask in Python

HDF5

Logo HDF

  • Hierarchický datový formát
  • Uložen hierarchicky – podobně jako (pod)adresáře
Parallel Programming with Dask in Python

Jak vypadá soubor HDF5?

Jedna prázdná složka

Parallel Programming with Dask in Python

Jak vypadá soubor HDF5?

Složka obsahující čtyři datové sady a metadata.

Parallel Programming with Dask in Python

Navigace v souborech HDF5 pomocí 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']>
Parallel Programming with Dask in Python

Navigace v souborech HDF5 pomocí 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">
Parallel Programming with Dask in Python

Načítání z 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>
Parallel Programming with Dask in Python

Zarr

  • Hierarchický formát jako HDF5
  • Navržen pro rozdělení na bloky (chunky)
  • Vhodný pro streamování přes cloudové služby (AWS, Google Cloud atd.)
  • Přehledná struktura souboru
Parallel Programming with Dask in Python

Načítání ze 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>
Parallel Programming with Dask in Python

Pojďme si procvičit!

Parallel Programming with Dask in Python

Preparing Video For Download...