Reading h5 file
up vote
0
down vote
favorite
I am a new python user and I want to read the data from a h5 file. The code that I have used to read the data is given below:
>>> import numpy as np
>>> import h5py
>>> f = h5py.File('file.h5', 'r')
>>> list(f.keys())
[u'data']
>>> dset = f[u'data']
>>> dset.shape
(64, 64, 64)
>>> dset.dtype
dtype(('<f8', (3,)))
Can anyone help me to understand these commands? My questions are:
1. What can I understand by the terms [u'data'] and dtype(('
python-3.x numpy h5py
New contributor
Photon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
favorite
I am a new python user and I want to read the data from a h5 file. The code that I have used to read the data is given below:
>>> import numpy as np
>>> import h5py
>>> f = h5py.File('file.h5', 'r')
>>> list(f.keys())
[u'data']
>>> dset = f[u'data']
>>> dset.shape
(64, 64, 64)
>>> dset.dtype
dtype(('<f8', (3,)))
Can anyone help me to understand these commands? My questions are:
1. What can I understand by the terms [u'data'] and dtype(('
python-3.x numpy h5py
New contributor
Photon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Don't know why I can't view the full post...the missing points are given below: Can anyone help me to understand these commands? My questions are: 1. What can I understand by the terms [u'data'] and dtype(('<f8', (3,)))? 2. If I want to view the full data shape (e.g, 64,64,64) then what command I need to use in python script? 3. What is the difference between the commands, 'dset[0:63]' ,'dset[0,63]' and 'dset[0:63, 0:63]'?
– Photon
Nov 21 at 1:57
If you are new to Python it's hard to know where there are gaps in your knowledge. To me theh5pydocs are clear enough. docs.h5py.org/en/latest/high/dataset.html#reading-writing-data. I'd suggest also looking at some of the otherh5pytagged questions. Beyond that you need to some basic knowledge ofnumpyalong withpython.
– hpaulj
Nov 21 at 3:08
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am a new python user and I want to read the data from a h5 file. The code that I have used to read the data is given below:
>>> import numpy as np
>>> import h5py
>>> f = h5py.File('file.h5', 'r')
>>> list(f.keys())
[u'data']
>>> dset = f[u'data']
>>> dset.shape
(64, 64, 64)
>>> dset.dtype
dtype(('<f8', (3,)))
Can anyone help me to understand these commands? My questions are:
1. What can I understand by the terms [u'data'] and dtype(('
python-3.x numpy h5py
New contributor
Photon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I am a new python user and I want to read the data from a h5 file. The code that I have used to read the data is given below:
>>> import numpy as np
>>> import h5py
>>> f = h5py.File('file.h5', 'r')
>>> list(f.keys())
[u'data']
>>> dset = f[u'data']
>>> dset.shape
(64, 64, 64)
>>> dset.dtype
dtype(('<f8', (3,)))
Can anyone help me to understand these commands? My questions are:
1. What can I understand by the terms [u'data'] and dtype(('
python-3.x numpy h5py
python-3.x numpy h5py
New contributor
Photon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Photon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Nov 21 at 3:10
hpaulj
108k673137
108k673137
New contributor
Photon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 21 at 1:52
Photon
1
1
New contributor
Photon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Photon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Photon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Don't know why I can't view the full post...the missing points are given below: Can anyone help me to understand these commands? My questions are: 1. What can I understand by the terms [u'data'] and dtype(('<f8', (3,)))? 2. If I want to view the full data shape (e.g, 64,64,64) then what command I need to use in python script? 3. What is the difference between the commands, 'dset[0:63]' ,'dset[0,63]' and 'dset[0:63, 0:63]'?
– Photon
Nov 21 at 1:57
If you are new to Python it's hard to know where there are gaps in your knowledge. To me theh5pydocs are clear enough. docs.h5py.org/en/latest/high/dataset.html#reading-writing-data. I'd suggest also looking at some of the otherh5pytagged questions. Beyond that you need to some basic knowledge ofnumpyalong withpython.
– hpaulj
Nov 21 at 3:08
add a comment |
Don't know why I can't view the full post...the missing points are given below: Can anyone help me to understand these commands? My questions are: 1. What can I understand by the terms [u'data'] and dtype(('<f8', (3,)))? 2. If I want to view the full data shape (e.g, 64,64,64) then what command I need to use in python script? 3. What is the difference between the commands, 'dset[0:63]' ,'dset[0,63]' and 'dset[0:63, 0:63]'?
– Photon
Nov 21 at 1:57
If you are new to Python it's hard to know where there are gaps in your knowledge. To me theh5pydocs are clear enough. docs.h5py.org/en/latest/high/dataset.html#reading-writing-data. I'd suggest also looking at some of the otherh5pytagged questions. Beyond that you need to some basic knowledge ofnumpyalong withpython.
– hpaulj
Nov 21 at 3:08
Don't know why I can't view the full post...the missing points are given below: Can anyone help me to understand these commands? My questions are: 1. What can I understand by the terms [u'data'] and dtype(('<f8', (3,)))? 2. If I want to view the full data shape (e.g, 64,64,64) then what command I need to use in python script? 3. What is the difference between the commands, 'dset[0:63]' ,'dset[0,63]' and 'dset[0:63, 0:63]'?
– Photon
Nov 21 at 1:57
Don't know why I can't view the full post...the missing points are given below: Can anyone help me to understand these commands? My questions are: 1. What can I understand by the terms [u'data'] and dtype(('<f8', (3,)))? 2. If I want to view the full data shape (e.g, 64,64,64) then what command I need to use in python script? 3. What is the difference between the commands, 'dset[0:63]' ,'dset[0,63]' and 'dset[0:63, 0:63]'?
– Photon
Nov 21 at 1:57
If you are new to Python it's hard to know where there are gaps in your knowledge. To me the
h5py docs are clear enough. docs.h5py.org/en/latest/high/dataset.html#reading-writing-data. I'd suggest also looking at some of the other h5py tagged questions. Beyond that you need to some basic knowledge of numpy along with python.– hpaulj
Nov 21 at 3:08
If you are new to Python it's hard to know where there are gaps in your knowledge. To me the
h5py docs are clear enough. docs.h5py.org/en/latest/high/dataset.html#reading-writing-data. I'd suggest also looking at some of the other h5py tagged questions. Beyond that you need to some basic knowledge of numpy along with python.– hpaulj
Nov 21 at 3:08
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
As @hpaulj mentions, the h5py doc is a good reference. You also need to understand basic HDF5 file concepts. It's a big topic. To get started, review the Learning HDF5 pages from The HDF Group. I know (from personal experience) that you will struggle if you don't understand how to navigate the hierarchy. Learn the differences between Group and Dataset objects.
Here's an explanation of the output in your OP.
Note that these are all h5py functions (not numpy).
>>> list(f.keys())
[u'data']
The “keys” are the names of group members, and the “values” are the members (Group and Dataset objects). This is a list of the Node names at the root level of the file. Nodes can be Groups or Datasets. In your case, you have one dataset named data. (The only group in this HDF5 file is the root group: '/', there are no groups below the root.)
The next step accesses the data in the data dataset.
>>> dset = f[u'data']
The shape attribute gives you the dimensions of the dataset:
>>> dset.shape
(64, 64, 64)
The dtype attribute gives you the data types of the dataset (just like numpy):
>>> dset.dtype
type(('<f8', (3,)))
So, you have an array of floats. If you want to see the data, you can enter this (I would only do this for small datasets, or slice to print a few rows):
>>> for row in dset:
print (row)
From here, what you do with the data is up to you.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
As @hpaulj mentions, the h5py doc is a good reference. You also need to understand basic HDF5 file concepts. It's a big topic. To get started, review the Learning HDF5 pages from The HDF Group. I know (from personal experience) that you will struggle if you don't understand how to navigate the hierarchy. Learn the differences between Group and Dataset objects.
Here's an explanation of the output in your OP.
Note that these are all h5py functions (not numpy).
>>> list(f.keys())
[u'data']
The “keys” are the names of group members, and the “values” are the members (Group and Dataset objects). This is a list of the Node names at the root level of the file. Nodes can be Groups or Datasets. In your case, you have one dataset named data. (The only group in this HDF5 file is the root group: '/', there are no groups below the root.)
The next step accesses the data in the data dataset.
>>> dset = f[u'data']
The shape attribute gives you the dimensions of the dataset:
>>> dset.shape
(64, 64, 64)
The dtype attribute gives you the data types of the dataset (just like numpy):
>>> dset.dtype
type(('<f8', (3,)))
So, you have an array of floats. If you want to see the data, you can enter this (I would only do this for small datasets, or slice to print a few rows):
>>> for row in dset:
print (row)
From here, what you do with the data is up to you.
add a comment |
up vote
0
down vote
As @hpaulj mentions, the h5py doc is a good reference. You also need to understand basic HDF5 file concepts. It's a big topic. To get started, review the Learning HDF5 pages from The HDF Group. I know (from personal experience) that you will struggle if you don't understand how to navigate the hierarchy. Learn the differences between Group and Dataset objects.
Here's an explanation of the output in your OP.
Note that these are all h5py functions (not numpy).
>>> list(f.keys())
[u'data']
The “keys” are the names of group members, and the “values” are the members (Group and Dataset objects). This is a list of the Node names at the root level of the file. Nodes can be Groups or Datasets. In your case, you have one dataset named data. (The only group in this HDF5 file is the root group: '/', there are no groups below the root.)
The next step accesses the data in the data dataset.
>>> dset = f[u'data']
The shape attribute gives you the dimensions of the dataset:
>>> dset.shape
(64, 64, 64)
The dtype attribute gives you the data types of the dataset (just like numpy):
>>> dset.dtype
type(('<f8', (3,)))
So, you have an array of floats. If you want to see the data, you can enter this (I would only do this for small datasets, or slice to print a few rows):
>>> for row in dset:
print (row)
From here, what you do with the data is up to you.
add a comment |
up vote
0
down vote
up vote
0
down vote
As @hpaulj mentions, the h5py doc is a good reference. You also need to understand basic HDF5 file concepts. It's a big topic. To get started, review the Learning HDF5 pages from The HDF Group. I know (from personal experience) that you will struggle if you don't understand how to navigate the hierarchy. Learn the differences between Group and Dataset objects.
Here's an explanation of the output in your OP.
Note that these are all h5py functions (not numpy).
>>> list(f.keys())
[u'data']
The “keys” are the names of group members, and the “values” are the members (Group and Dataset objects). This is a list of the Node names at the root level of the file. Nodes can be Groups or Datasets. In your case, you have one dataset named data. (The only group in this HDF5 file is the root group: '/', there are no groups below the root.)
The next step accesses the data in the data dataset.
>>> dset = f[u'data']
The shape attribute gives you the dimensions of the dataset:
>>> dset.shape
(64, 64, 64)
The dtype attribute gives you the data types of the dataset (just like numpy):
>>> dset.dtype
type(('<f8', (3,)))
So, you have an array of floats. If you want to see the data, you can enter this (I would only do this for small datasets, or slice to print a few rows):
>>> for row in dset:
print (row)
From here, what you do with the data is up to you.
As @hpaulj mentions, the h5py doc is a good reference. You also need to understand basic HDF5 file concepts. It's a big topic. To get started, review the Learning HDF5 pages from The HDF Group. I know (from personal experience) that you will struggle if you don't understand how to navigate the hierarchy. Learn the differences between Group and Dataset objects.
Here's an explanation of the output in your OP.
Note that these are all h5py functions (not numpy).
>>> list(f.keys())
[u'data']
The “keys” are the names of group members, and the “values” are the members (Group and Dataset objects). This is a list of the Node names at the root level of the file. Nodes can be Groups or Datasets. In your case, you have one dataset named data. (The only group in this HDF5 file is the root group: '/', there are no groups below the root.)
The next step accesses the data in the data dataset.
>>> dset = f[u'data']
The shape attribute gives you the dimensions of the dataset:
>>> dset.shape
(64, 64, 64)
The dtype attribute gives you the data types of the dataset (just like numpy):
>>> dset.dtype
type(('<f8', (3,)))
So, you have an array of floats. If you want to see the data, you can enter this (I would only do this for small datasets, or slice to print a few rows):
>>> for row in dset:
print (row)
From here, what you do with the data is up to you.
edited Nov 21 at 19:22
answered Nov 21 at 15:08
user10462884
438
438
add a comment |
add a comment |
Photon is a new contributor. Be nice, and check out our Code of Conduct.
Photon is a new contributor. Be nice, and check out our Code of Conduct.
Photon is a new contributor. Be nice, and check out our Code of Conduct.
Photon is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404251%2freading-h5-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Don't know why I can't view the full post...the missing points are given below: Can anyone help me to understand these commands? My questions are: 1. What can I understand by the terms [u'data'] and dtype(('<f8', (3,)))? 2. If I want to view the full data shape (e.g, 64,64,64) then what command I need to use in python script? 3. What is the difference between the commands, 'dset[0:63]' ,'dset[0,63]' and 'dset[0:63, 0:63]'?
– Photon
Nov 21 at 1:57
If you are new to Python it's hard to know where there are gaps in your knowledge. To me the
h5pydocs are clear enough. docs.h5py.org/en/latest/high/dataset.html#reading-writing-data. I'd suggest also looking at some of the otherh5pytagged questions. Beyond that you need to some basic knowledge ofnumpyalong withpython.– hpaulj
Nov 21 at 3:08