netallocation.io module¶
Created on Mon Dec 16 12:58:09 2019
@author: fabian
- netallocation.io.dense_to_h5(array, file, name)[source]¶
Store dense data in hdf5 format.
Fast way to store arrays, helpful for datasets with stacked multindex.
- Parameters
coo (spare.COO) – Data array which will be stored.
file (str) – Name of the h5 file in which the data should be stored.
name (str) – Variable name of the data under which is will be stored in the h5 file.
- Returns
- Return type
None.
- netallocation.io.load_dataset(folder)[source]¶
Import xarray.Dataset with sparse Dataarrays.
Use this to load an xarray.Dataset stored via the function store_dataset.
- Parameters
folder (str) – Directory name of the stored data.
- Returns
Allocation dataset with sparse data arrays.
- Return type
xarray.Dataset
- netallocation.io.read_dense_h5(file, name)[source]¶
Load the a dense data array stored via dense_to_h5.
- Parameters
file (str) – Name of the h5 file from where the data should be loaded.
name (str) – Name of the variable stored in the h5 file.
- Returns
Loaded dense array.
- Return type
dense.COO
- netallocation.io.read_sparse_h5(file, name, shape)[source]¶
Load the a sparse data array stored via sparse_to_h5.
- Parameters
file (str) – Name of the h5 file from where the data should be loaded.
name (str) – Name of the variable stored in the h5 file.
- Returns
Loaded sparse array.
- Return type
sparse.COO
- netallocation.io.sparse_to_h5(coo, file, name)[source]¶
Store sparse data in hdf5 format.
Fast way to store sparse.COO arrays.
- Parameters
coo (spare.COO) – Data array which will be stored.
file (str) – Name of the h5 file in which the data should be stored.
name (str) – Variable name of the data under which is will be stored in the h5 file.
- Returns
- Return type
None.
- netallocation.io.store_dataset(ds, folder)[source]¶
Export xarray.Dataset with mixed sparse and dense Dataarrays.
This is an extention to the normal exporter functions of xarray. Use this to write out xarray.Datsets with sparse and/or dense arrays and/or stacked multiindex. Those will be stored as h5 files in a new created directory.
- Parameters
ds (xarray.Dataset) – Dataset with sparse variables to be written
folder (str) – Name of the directory to where to data is stored.
- Returns
- Return type
None.