h5py

How can I solve this 3D regular grid interpolation problem

℡╲_俬逩灬. 提交于 2020-03-05 06:01:07
问题 I am a new python user. I have a h5 file, which is a snapshot of gravitational potential at a fixed redshift. I have read the h5 file in python and now I want to write a code which will give the value of the gravitational potential for given values of (x, y, z) by using trilinear interpolation. Can anyone of you please help me to do that? For your kind consideration, the code is given below: In [1]: import numpy as np In [2]: import h5py In [3]: from scipy.interpolate import

How to inspect .h5 file in Python

妖精的绣舞 提交于 2020-03-03 05:39:31
问题 How do I see what variables, datasets, etc. a given .h5 file has in Python? I can read the file by running this import h5py f = h5py.File(filename, 'r') How can I now see which variables my .h5 file have? Running f.keys() outputs the non-informative KeysView(<HDF5 file filename (mode r)>) In Matlab I simply call h5disp(filename) but would like to know how to do it in Python 回答1: Did you try? print(list(f.keys())) That should give you all the group inside your hdf5 file. You can do the same

Creating HDF5 compound attributes using h5py

最后都变了- 提交于 2020-02-23 07:06:41
问题 I'm trying to create some simple HDF5 datasets that contain attributes with a compound datatype using h5py. The goal is an attribute that has two integers. Here are two example of attributes I'd like to create. My attempts end up with an array of two values such as How can I code this using h5py and get a single value that contains two integers? Current code looks something like dt_type = np.dtype({"names": ["val1"],"formats": [('<i4', 2)]}) # also tried np.dtype({"names": ["val1", "val2"],

Corrupt files when creating HDF5 files without closing them (h5py)

丶灬走出姿态 提交于 2020-02-14 05:50:08
问题 I am using h5py to store experiment data in an HDF5 container. In an interactive session I open the file using: measurement_data = h5py.File('example.hdf5', 'a') Then I write data to the file using some self-written functions (can be many GB of data from a couple of days experiment). At the end of the experiment I usually would close the file using measurement_data.close() Unfortunately, from time to time it happens, that the interactive session ends without me explicitly closing the file

Compressing HDF5 files with H5Py

送分小仙女□ 提交于 2020-02-05 03:48:32
问题 I'm passing thousands of .csv containing time and amplitude to a .hdf5 file. To give an example I used a small amount of .csv files which correspond to a total of ~11MB. After passing all the .csv to hdf5, the latter has a size of ~36MB (without using compression="gzip" ). By using compression="gzip" the file size is around 38MB. I understand that hdf5 is compressing the dataset only, that is, the numpy array in my case (~500 rows with float number). To make a comparison, I was saving all the

Writing Data to h5py on SSD disk appears slow: What can I do to speed it up

做~自己de王妃 提交于 2020-01-24 22:42:29
问题 I'm trying to write data to a h5py dataset but using a high memory 12 core GCE instance to write to an SSD disk but it runs for 13 hours with no end in sight. I'm running Jupyter Notebook on the GCE instance to unpickle a large number of small files (stored on a 2nd non-ssd disk) before adding them to a h5py dataset in a file stored on the ssd disk Max shape= (29914, 251328) Chunks = (59, 982) compression = gzip dtype = float64 My code is listed below #Get a sample minsample = 13300

Inserting Many HDF5 Datasets Very Slow

折月煮酒 提交于 2020-01-24 20:30:28
问题 There is a dramatic slowdown when inserting many datasets into a group. I have found that the slowdown point is proportional to the length of the name and number of datasets. A larger dataset does take a bit longer to insert but it didn't affect when the slowdown occurred. The following example exaggerates the length of the name just to illustrate the point without waiting a long time. Python 3 HDF5 Version 1.8.15 (1.10.1 gets even slower) h5py version: 2.6.0 Example: import numpy as np

How to list dataset in h5py file?

强颜欢笑 提交于 2020-01-24 02:14:31
问题 I have a h5py file storing numpy arrays, but I got Object doesn't exist error when trying to open it with the dataset name I remember, so is there a way I can list what datasets the file has? with h5py.File('result.h5','r') as hf: #How can I list all dataset I have saved in hf? 回答1: You have to use the keys method. This will give you a List of unicode strings of your dataset and group names. For example: Datasetnames=hf.keys() Another gui based method would be to use HDFView. https://support

Storing string datasets in hdf5 with unicode

别等时光非礼了梦想. 提交于 2020-01-15 10:14:35
问题 I am trying to store variable string expressions from a file which contains special characters, like ø, æ , and å . Here is my code: import h5py as h5 file = h5.File('deleteme.hdf5','a') dt = h5.special_dtype(vlen=str) dset = file.create_dataset("text",(1,),dtype=dt) dset.attrs[str(1)] = "some text with ø, æ, å" However the text is not stored properly. The data stored contains text: "some text with \37777777703\37777777670, \37777777703\37777777646,\37777777703\37777777645" How can I store

Open .h5 file in Python

情到浓时终转凉″ 提交于 2020-01-14 08:05:42
问题 I am trying to read a h5 file in Python. The file can be found in this link and it is called 'vstoxx_data_31032014.h5'. The code I am trying to run is from the book Python for Finance, by Yves Hilpisch and goes like this: import pandas as pd h5 = pd.HDFStore('path.../vstoxx_data_31032014.h5', 'r') futures_data = h5['futures_data'] # VSTOXX futures data options_data = h5['options_data'] # VSTOXX call option data h5.close() I am getting the following error: h5 = pd.HDFStore('path.../vstoxx_data