Skip to main content

A collection of helpful functions and doodads.

Project description

Load data from v7.3 *.mat files. Only reading is supported, no writing.

Usage

Provides a class Hdf5Matfile and a convience function load_hdf5mat.

To load all the variables from the file, use Hdf5Matfile.load_file:

with Hdf5Matfile(filename) as file:
    data = file.load_file()

To load a specific variable, use Hdf5Matfile.load_variable:

with Hdf5Matfile(filename) as file:
    results = file.load_variable('results')

If you’re not using a context manager, make sure to close the file after you’re done:

file = Hdf5Matfile(filename)
data = file.load_file()
file.close()

By default, arrays are not squeezed; since MATLAB represents even scalars as 2-D arrays, this means that something you expect to be a scalar will in fact be a 1-by-1 np.ndarray. You can change this by passing squeeze=True to the constructor:

with Hdf5Matfile(filename, squeeze=True) as file:
    data = file.load_file()

Supported data types

Data type support is pretty limited; this isn’t a terribly fancy class. Supported MATLAB data types, and the Python objects or NumPy dtypes they map to:

MATLAB type

Python object

NumPy dtype

cell

np.ndarray

object

char

str

n/a

double

np.ndarray

np.double

int8

np.ndarray

np.byte

int16

np.ndarray

np.short

int32

np.ndarray

np.intc

int64

np.ndarray

np.int_

logical

np.ndarray

bool8

single

np.ndarray

single

struct (scalar)

dict

n/a

struct (array)

np.ndarray

object (dict)

uint8

np.ndarray

np.ubyte

uint16

np.ndarray

np.ushort

uint32

np.ndarray

np.uintc

uint64

np.ndarray

np.uint

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hdf5matfile-0.2.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

hdf5matfile-0.2.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file hdf5matfile-0.2.1.tar.gz.

File metadata

  • Download URL: hdf5matfile-0.2.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for hdf5matfile-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b9aeedeec00a9e6872836e73b3a510b8467180319c9e0feeedc92f06c784e934
MD5 8e617e4038797d4379224707fae0852e
BLAKE2b-256 61c1c9a9a88d98cf62fe0198a5261a30295ac43400c73e640db8ac02ea2865a3

See more details on using hashes here.

File details

Details for the file hdf5matfile-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: hdf5matfile-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for hdf5matfile-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5dba8a2c54e4ce4d8fbfb83802c6ffa365bf9442440e4bb47e45aa335420f95
MD5 f839f4137ed83126f16d4cca7058b250
BLAKE2b-256 e3faf1a864eceb9a480c769ecb572c0e80aad1786e78120d40b4e2ab572be982

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page