다차원 배열

Python에서 Dask로 병렬 프로그래밍

James Fulton

Climate Informatics Researcher

다차원 데이터 유형

  • 일기예보/관측
  • 3D 생의학 스캔
  • 위성 이미지
  • 기타 과학 장비 데이터
Python에서 Dask로 병렬 프로그래밍

HDF5

HDF 로고

  • Hierarchical Data Format
  • (서브)디렉터리처럼 계층 구조로 저장
Python에서 Dask로 병렬 프로그래밍

HDF5 파일은 어떻게 보이나요?

단일 폴더

Python에서 Dask로 병렬 프로그래밍

HDF5 파일은 어떻게 보이나요?

하나의 폴더에 네 개의 데이터셋과 메타데이터가 있음.

Python에서 Dask로 병렬 프로그래밍

h5py로 HDF5 탐색

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']>
Python에서 Dask로 병렬 프로그래밍

h5py로 HDF5 탐색

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">
Python에서 Dask로 병렬 프로그래밍

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>
Python에서 Dask로 병렬 프로그래밍

Zarr

  • HDF5와 같은 계층형 데이터셋
  • 청크 단위 저장에 최적화
  • AWS, Google Cloud 등 클라우드 스트리밍에 적합
  • 탐색 가능한 파일 구조
Python에서 Dask로 병렬 프로그래밍

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>
Python에서 Dask로 병렬 프로그래밍

연습해 봅시다!

Python에서 Dask로 병렬 프로그래밍

Preparing Video For Download...