h5py

Error in reading hdf file using h5py package for python

爷,独闯天下 提交于 2019-12-22 10:21:42
问题 I want to extract data from hdf files that I downloaded from MODIS website. A sample file is provided in the link. I am reading the hdf file by using the following lines of code: >>> import h5py >>> f = h5py.File( 'MYD08_M3.A2002182.051.2008334061251.psgscs_000500751197.hdf', 'r' ) The error I am getting: Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> f = h5py.File( 'MYD08_M3.A2002182.051.2008334061251.psgscs_000500751197.hdf', 'r' ) File "C:\Python27\lib\site

h5py: how to read selected rows of an hdf5 file?

纵饮孤独 提交于 2019-12-21 20:28:18
问题 Is it possible to read a given set of rows from an hdf5 file without loading the whole file? I have quite big hdf5 files with loads of datasets, here is an example of what I had in mind to reduce time and memory usage: #! /usr/bin/env python import numpy as np import h5py infile = 'field1.87.hdf5' f = h5py.File(infile,'r') group = f['Data'] mdisk = group['mdisk'].value val = 2.*pow(10.,10.) ind = np.where(mdisk>val)[0] m = group['mcold'][ind] print m ind doesn't give consecutive rows but

How to share memory from an HDF5 dataset with a NumPy ndarray

ぃ、小莉子 提交于 2019-12-21 20:01:41
问题 I am writing an application for streaming data from a sensor, and then processing the data in various ways. These processing components include visualizing the data, some number crunching (linear algebra), and also writing the data to disk in an HDF5 format. Ideally each of these components will be its own module, all run in the same Python process so that IPC is not an issue. This leads me to the question of how to efficiently store the streaming data. The datasets are quite large (~5Gb),

how to import .mat-v7.3 file using h5py

梦想与她 提交于 2019-12-20 04:51:17
问题 I have .mat file which have 3 matrixes A, B, C. Actually I used scipy.io to import this mat file as below. data = sio.loadmat('/data.mat') A = data['A'] B = data['B'] C = data['C'] But, v7.3 file cannot import using this way. So, I tried to import using h5py but I don't know how to use h5py. My code is as below. f = h5py.File('/data.mat', 'r') A = f.get('/A') A = np.array('A') Which part is wrong? Thank you! 回答1: In Octave >> A = [1,2,3;4,5,6]; >> B = [1,2,3,4]; >> save -hdf5 abc.h5 A B In

how to import .mat-v7.3 file using h5py

有些话、适合烂在心里 提交于 2019-12-20 04:51:09
问题 I have .mat file which have 3 matrixes A, B, C. Actually I used scipy.io to import this mat file as below. data = sio.loadmat('/data.mat') A = data['A'] B = data['B'] C = data['C'] But, v7.3 file cannot import using this way. So, I tried to import using h5py but I don't know how to use h5py. My code is as below. f = h5py.File('/data.mat', 'r') A = f.get('/A') A = np.array('A') Which part is wrong? Thank you! 回答1: In Octave >> A = [1,2,3;4,5,6]; >> B = [1,2,3,4]; >> save -hdf5 abc.h5 A B In

Read or Write a compound datatype with h5py in python

徘徊边缘 提交于 2019-12-20 03:28:11
问题 I want to use hdf5 file among some C++, matlab, and python code. My h5 file works well in C++ and matlab, but cannot be read with h5py. Is data types like H5T_STD_B64LE not well supported by h5py? Thanks! In [2]: f = h5py.File('art.mips.log.h5', 'r') In [3]: f.keys() Out[3]: [u'mem'] In [4]: f['mem'] Out[4]: <repr(<h5py._hl.dataset.Dataset at 0x29f70d0>) failed: TypeError: No NumPy equivalent for TypeBitfieldID exists> The hdf5 file format is as follows: $ h5dump -H art.mips.log.h5 HDF5 "art

Installing h5py on OS X

。_饼干妹妹 提交于 2019-12-19 18:29:15
问题 I've spent the day trying to get the h5py module of python working, but without success. I've installed HDF5 shared libraries, followed the instructions I could find on the web to get it right. But it doesn't work, below is the error message I get when trying to import the module into python. I tried installing through MacPorts too but again it wouldnt work. I'm using Python27 32 bits (had too for another module, and thus installed the i386 HDF5 library... if that's right?) Any help very

How to differentiate between HDF5 datasets and groups with h5py?

核能气质少年 提交于 2019-12-18 12:23:51
问题 I use the Python package h5py (version 2.5.0) to access my hdf5 files. I want to traverse the content of a file and do something with every dataset. Using the visit method: import h5py def print_it(name): dset = f[name] print(dset) print(type(dset)) with h5py.File('test.hdf5', 'r') as f: f.visit(print_it) for a test file I obtain: <HDF5 group "/x" (1 members)> <class 'h5py._hl.group.Group'> <HDF5 dataset "y": shape (100, 100, 100), type "<f8"> <class 'h5py._hl.dataset.Dataset'> which tells me

Writing to compound dataset with variable length string via h5py (HDF5)

社会主义新天地 提交于 2019-12-18 09:29:12
问题 I've been able to create a compound dataset consisting of an unsigned int and a variable-length string in my HDF5 file using h5py, but I can't write to it. dt = h5py.special_dtype(vlen=str) dset = fout.create_dataset(ver, (1,), dtype=np.dtype([("time", np.uint64),("value", dt)])) I've written to other compound datasets fairly easily, by setting the specific column(s) of the compound dataset as equal to an existing numpy array. Now where I run into trouble is with writing to the compound

Python HDF5 H5Py issues opening multiple files

China☆狼群 提交于 2019-12-18 08:48:20
问题 I am usint the 64-bit version of Enthought Python to process data across multiple HDF5 files. I'm using h5py version 1.3.1 (HDF5 1.8.4) on 64-bit Windows. I have an object that provides a convenient interface to my specific data heirarchy, but testing the h5py.File(fname, 'r') independently yields the same results. I am iterating through a long list (~100 files at a time) and attempting to pull out specific pieces of information from the files. The problem I'm having is that I'm getting the