Hi all, I'm trying to modify the particle_type of some particles in a hdf5 data file extract0062.cpu0000 in yt, typing the following command: for g in pf.h.grids: lbhs = np.logical_and(np.logical_and(g['particle_type']==1,g['particle_index']>=256**3),g['ParticleMassMsun']>1) # These two lines are to pick out bhs = np.where(lbhs)[0] # particles that I wanted to modify if(np.any(g['particle_type'])): g['particle_type'][bhs]=9 f=h5py.File(g.filename) ff = f['/Grid%08i'%g.id]['particle_type'] ff.write_direct(g['particle_type']) f.close() It spited out following error information: ReadingError Traceback (most recent call last) /home/cshi31/yt-x86_64/src/yt-hg/yt/mods.pyc in <module>() 1 for g in pf.h.grids: ----> 2 lbhs = np.logical_and(np.logical_and(g['particle_type']==1,g['particle_index']>=256**3),g['ParticleMassMsun']>1) 3 bhs = np.where(lbhs)[0] 4 if(np.any(g['particle_type'])): 5 g['particle_type'][bhs]=9 /home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in __getitem__(self, key) 155 """ 156 if not self.field_data.has_key(key): --> 157 self.get_data(key) 158 return self.field_data[key] 159 /home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in get_data(self, field, convert) 188 return self.field_data[field] 189 try: --> 190 temp = self.hierarchy.io.pop(self, field) 191 self[field] = na.multiply(temp, conv_factor, temp) 192 except self.hierarchy.io._read_exception, exc: /home/cshi31/yt-x86_64/src/yt-hg/yt/utilities/io_handler.pyc in pop(self, grid, field) 59 else: 60 # We only read the one set and do not store it if it isn't pre-loaded ---> 61 return self._read_data_set(grid, field) 62 63 def peek(self, grid, field): /home/cshi31/yt-x86_64/src/yt-hg/yt/frontends/enzo/io.pyc in _read_data_set(self, grid, field) 183 def _read_data_set(self, grid, field): 184 return self.modify(hdf5_light_reader.ReadData(grid.filename, --> 185 "/Grid%08i/%s" % (grid.id, field))) 186 187 def _read_data_slice(self, grid, field, axis, coord): ReadingError: ReadHDF5DataSet: Unable to open /home/cshi31/research/SG256-RP/extract0062 So I tried to look where the loop stopped, typed g in the command: In [37]: g Out[37]: EnzoGrid_0056 so it stopped at the 56th grid in that file. I tried to see what particles is contained in this grid, typing g['particle_type'], it turned out this is what caused the problem: In [31]: g['particle_type'] --------------------------------------------------------------------------- ReadingError Traceback (most recent call last) /home/cshi31/yt-x86_64/src/yt-hg/yt/mods.pyc in <module>() ----> 1 g['particle_type'] /home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in __getitem__(self, key) 155 """ 156 if not self.field_data.has_key(key): --> 157 self.get_data(key) 158 return self.field_data[key] 159 /home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in get_data(self, field, convert) 188 return self.field_data[field] 189 try: --> 190 temp = self.hierarchy.io.pop(self, field) 191 self[field] = na.multiply(temp, conv_factor, temp) 192 except self.hierarchy.io._read_exception, exc: /home/cshi31/yt-x86_64/src/yt-hg/yt/utilities/io_handler.pyc in pop(self, grid, field) 59 else: 60 # We only read the one set and do not store it if it isn't pre-loaded ---> 61 return self._read_data_set(grid, field) 62 63 def peek(self, grid, field): /home/cshi31/yt-x86_64/src/yt-hg/yt/frontends/enzo/io.pyc in _read_data_set(self, grid, field) 183 def _read_data_set(self, grid, field): 184 return self.modify(hdf5_light_reader.ReadData(grid.filename, --> 185 "/Grid%08i/%s" % (grid.id, field))) 186 187 def _read_data_slice(self, grid, field, axis, coord): ReadingError: ReadHDF5DataSet: Unable to open /home/cshi31/research/SG256-RP/extract0062.cpu0000 Can anyone help me on this? Thanks very much. Chao
Is this an Enzo sim? It is conceivable to have no particles in that grid. I've seen others encounter some grids where the hdf5 file is missing Dark_Matter_Density field because there were no DM particles in that particular grid. You can confirm if the particle_type or Dark_Matter_Density field is missing by typing
h5ls extract0062.cpu####/Grid######## where the #'s correspond to the file number which has the EnzoGrid_0056 From G.S. On Mon, Oct 8, 2012 at 8:23 PM, Chao Shi <shichao116@gmail.com> wrote:
Hi all,
I'm trying to modify the particle_type of some particles in a hdf5 data file extract0062.cpu0000 in yt, typing the following command:
for g in pf.h.grids: lbhs = np.logical_and(np.logical_and(g['particle_type']==1,g['particle_index']>=256**3),g['ParticleMassMsun']>1) # These two lines are to pick out bhs = np.where(lbhs)[0]
# particles that I wanted to modify if(np.any(g['particle_type'])): g['particle_type'][bhs]=9 f=h5py.File(g.filename) ff = f['/Grid%08i'%g.id]['particle_type'] ff.write_direct(g['particle_type']) f.close()
It spited out following error information:
ReadingError Traceback (most recent call last) /home/cshi31/yt-x86_64/src/yt-hg/yt/mods.pyc in <module>() 1 for g in pf.h.grids: ----> 2 lbhs = np.logical_and(np.logical_and(g['particle_type']==1,g['particle_index']>=256**3),g['ParticleMassMsun']>1) 3 bhs = np.where(lbhs)[0] 4 if(np.any(g['particle_type'])): 5 g['particle_type'][bhs]=9
/home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in __getitem__(self, key) 155 """ 156 if not self.field_data.has_key(key): --> 157 self.get_data(key) 158 return self.field_data[key] 159
/home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in get_data(self, field, convert) 188 return self.field_data[field] 189 try: --> 190 temp = self.hierarchy.io.pop(self, field) 191 self[field] = na.multiply(temp, conv_factor, temp) 192 except self.hierarchy.io._read_exception, exc:
/home/cshi31/yt-x86_64/src/yt-hg/yt/utilities/io_handler.pyc in pop(self, grid, field) 59 else: 60 # We only read the one set and do not store it if it isn't pre-loaded ---> 61 return self._read_data_set(grid, field) 62 63 def peek(self, grid, field):
/home/cshi31/yt-x86_64/src/yt-hg/yt/frontends/enzo/io.pyc in _read_data_set(self, grid, field) 183 def _read_data_set(self, grid, field): 184 return self.modify(hdf5_light_reader.ReadData(grid.filename, --> 185 "/Grid%08i/%s" % (grid.id, field))) 186 187 def _read_data_slice(self, grid, field, axis, coord):
ReadingError: ReadHDF5DataSet: Unable to open /home/cshi31/research/SG256-RP/extract0062
So I tried to look where the loop stopped, typed g in the command:
In [37]: g Out[37]: EnzoGrid_0056
so it stopped at the 56th grid in that file. I tried to see what particles is contained in this grid, typing g['particle_type'], it turned out this is what caused the problem:
In [31]: g['particle_type'] --------------------------------------------------------------------------- ReadingError Traceback (most recent call last) /home/cshi31/yt-x86_64/src/yt-hg/yt/mods.pyc in <module>() ----> 1 g['particle_type']
/home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in __getitem__(self, key) 155 """ 156 if not self.field_data.has_key(key): --> 157 self.get_data(key) 158 return self.field_data[key] 159
/home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in get_data(self, field, convert) 188 return self.field_data[field] 189 try: --> 190 temp = self.hierarchy.io.pop(self, field) 191 self[field] = na.multiply(temp, conv_factor, temp) 192 except self.hierarchy.io._read_exception, exc:
/home/cshi31/yt-x86_64/src/yt-hg/yt/utilities/io_handler.pyc in pop(self, grid, field) 59 else: 60 # We only read the one set and do not store it if it isn't pre-loaded ---> 61 return self._read_data_set(grid, field) 62 63 def peek(self, grid, field):
/home/cshi31/yt-x86_64/src/yt-hg/yt/frontends/enzo/io.pyc in _read_data_set(self, grid, field) 183 def _read_data_set(self, grid, field): 184 return self.modify(hdf5_light_reader.ReadData(grid.filename, --> 185 "/Grid%08i/%s" % (grid.id, field))) 186 187 def _read_data_slice(self, grid, field, axis, coord):
ReadingError: ReadHDF5DataSet: Unable to open /home/cshi31/research/SG256-RP/extract0062.cpu0000
Can anyone help me on this? Thanks very much.
Chao
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (2)
-
Chao Shi
-
Geoffrey So