Hey there! I'm having some issues with the loadSubhalo() function.
import illustris_python as il
basePath='./TNG100-3/output'
snapNum, galid=99, 100
data=il.snapshot.loadSubhalo(basePath, snapNum, galid, 'gas')
returns the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/media/jacob/B6F04BDBF04BA08B/TNG/illustris_python/snapshot.py", line 196, in loadSubhalo
return loadSubset(basePath, snapNum, partType, fields, subset=subset)
File "/media/jacob/B6F04BDBF04BA08B/TNG/illustris_python/snapshot.py", line 54, in loadSubset
nPart = getNumPart(header)
File "/media/jacob/B6F04BDBF04BA08B/TNG/illustris_python/snapshot.py", line 26, in getNumPart
nPart[j] = header['NumPart_Total'][j] | (header['NumPart_Total_HighWord'][j] << 32)
KeyError: 'NumPart_Total'
looking into the function loadSubset I see that it passes "dict(f['Header'].attrs.items())" to getNumPart, with f=h5py.File(snapPath(basePath, snapNum), 'r'). If I do
I see that this object does not contain the 'NumPart_Total' keyword expected by the function getNumPart().
How do I handle this?
PS: Also, perhaps related, say I wanted to create my own hdf5 file that contains only particles I have decided I am interested in. I would load snapshots/chunks one at a time, take the info on the particles I want, and put them into their own combined hdf5 file that has the same structure as regular TNG files. I'd need to keep the Header consistent as well. How do I edit the header? If not related I can post separately.
Jacob Morgan
22 Sep '20
I just noticed that the header object also doesn't have 'NumPart_Total_HighWord', which I'd need next
Dylan Nelson
23 Sep '20
Hi Jacob,
This works fine on the original data files (e.g. if you run these commands on the Lab). You must have different files: where are they from? Did you download just a subset of the data?
What is the output of the command h5dump -g Header snap_099.0.hdf5? For me this produces:
For your second question, the info in the Header is made up of "attributes" (see h5py docs), rather than "datasets" (for large arrays). You can edit/create/delete these in h5py.
Jacob Morgan
27 Sep '20
So I'm embarrassed to say that after looking into it I was basically loading a groupcat file like a snapshot file-- long story short I didn't realize how many different types of file there were and didn't keep them properly separated.
Hey there! I'm having some issues with the loadSubhalo() function.
returns the error:
looking into the function loadSubset I see that it passes "dict(f['Header'].attrs.items())" to getNumPart, with f=h5py.File(snapPath(basePath, snapNum), 'r'). If I do
I see that this object does not contain the 'NumPart_Total' keyword expected by the function getNumPart().
How do I handle this?
PS: Also, perhaps related, say I wanted to create my own hdf5 file that contains only particles I have decided I am interested in. I would load snapshots/chunks one at a time, take the info on the particles I want, and put them into their own combined hdf5 file that has the same structure as regular TNG files. I'd need to keep the Header consistent as well. How do I edit the header? If not related I can post separately.
I just noticed that the header object also doesn't have 'NumPart_Total_HighWord', which I'd need next
Hi Jacob,
This works fine on the original data files (e.g. if you run these commands on the Lab). You must have different files: where are they from? Did you download just a subset of the data?
What is the output of the command
h5dump -g Header snap_099.0.hdf5
? For me this produces:where you see the
NumPart*
entries.For your second question, the info in the
Header
is made up of "attributes" (see h5py docs), rather than "datasets" (for large arrays). You can edit/create/delete these in h5py.So I'm embarrassed to say that after looking into it I was basically loading a groupcat file like a snapshot file-- long story short I didn't realize how many different types of file there were and didn't keep them properly separated.
Thank you for the help!