Hi all,<div><br></div><div>I'm trying to modify the particle_type of some particles in a hdf5 data file extract0062.cpu0000 in yt, typing the following command:</div><div><br></div><div><div><font color="#006600">for g in pf.h.grids:</font></div>
<div><font color="#006600">    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</font></div>
<div><font color="#006600">    bhs  = np.where(lbhs)[0]                                                                                                                                     # particles that I wanted to modify</font></div>
<div><font color="#006600">    if(np.any(g['particle_type'])):</font></div><div><font color="#006600">        g['particle_type'][bhs]=9</font></div><div><font color="#006600">        f=h5py.File(g.filename)</font></div>
<div><font color="#006600">        ff = f['/Grid%08i'%<a href="http://g.id">g.id</a>]['particle_type']</font></div><div><font color="#006600">        ff.write_direct(g['particle_type'])</font></div>
<div><font color="#006600">        f.close()</font></div><div>           </div></div><div>It spited out following error information:</div><div><br></div><div><div><font color="#006600">ReadingError                              Traceback (most recent call last)</font></div>
<div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/mods.pyc in <module>()</font></div><div><font color="#006600">      1 for g in pf.h.grids:</font></div><div><font color="#006600">----> 2     lbhs = np.logical_and(np.logical_and(g['particle_type']==1,g['particle_index']>=256**3),g['ParticleMassMsun']>1)</font></div>
<div><font color="#006600">      3     bhs  = np.where(lbhs)[0]</font></div><div><font color="#006600">      4     if(np.any(g['particle_type'])):</font></div><div><font color="#006600">      5         g['particle_type'][bhs]=9</font></div>
<div><font color="#006600"><br></font></div><div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in __getitem__(self, key)</font></div><div><font color="#006600">    155         """</font></div>
<div><font color="#006600">    156         if not self.field_data.has_key(key):</font></div><div><font color="#006600">--> 157             self.get_data(key)</font></div><div><font color="#006600">    158         return self.field_data[key]</font></div>
<div><font color="#006600">    159 </font></div><div><font color="#006600"><br></font></div><div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in get_data(self, field, convert)</font></div>
<div><font color="#006600">    188                     return self.field_data[field]</font></div><div><font color="#006600">    189                 try:</font></div><div><font color="#006600">--> 190                     temp = self.hierarchy.io.pop(self, field)</font></div>
<div><font color="#006600">    191                     self[field] = na.multiply(temp, conv_factor, temp)</font></div><div><font color="#006600">    192                 except self.hierarchy.io._read_exception, exc:</font></div>
<div><font color="#006600"><br></font></div><div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/utilities/io_handler.pyc in pop(self, grid, field)</font></div><div><font color="#006600">     59         else:</font></div>
<div><font color="#006600">     60             # We only read the one set and do not store it if it isn't pre-loaded</font></div><div><font color="#006600">---> 61             return self._read_data_set(grid, field)</font></div>
<div><font color="#006600">     62 </font></div><div><font color="#006600">     63     def peek(self, grid, field):</font></div><div><font color="#006600"><br></font></div><div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/frontends/enzo/io.pyc in _read_data_set(self, grid, field)</font></div>
<div><font color="#006600">    183     def _read_data_set(self, grid, field):</font></div><div><font color="#006600">    184         return self.modify(hdf5_light_reader.ReadData(grid.filename,</font></div><div><font color="#006600">--> 185                 "/Grid%08i/%s" % (<a href="http://grid.id">grid.id</a>, field)))</font></div>
<div><font color="#006600">    186 </font></div><div><font color="#006600">    187     def _read_data_slice(self, grid, field, axis, coord):</font></div><div><br></div><div><font color="#ff0000">ReadingError: ReadHDF5DataSet: Unable to open /home/cshi31/research/SG256-RP/extract0062</font></div>
</div><div><br></div><div><br></div><div>So I tried to look where the loop stopped, typed g in the command:</div><div><br></div><div><div><font color="#006600">In [37]: g</font></div><div><font color="#006600">Out[37]: EnzoGrid_0056</font></div>
</div><div><br></div><div>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'],</div><div>it turned out this is what caused the problem:</div>
<div><br></div><div><br></div><div><div><font color="#006600">In [31]: g['particle_type']</font></div><div><font color="#006600">---------------------------------------------------------------------------</font></div>
<div><font color="#006600">ReadingError                              Traceback (most recent call last)</font></div><div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/mods.pyc in <module>()</font></div><div>
<font color="#006600">----> 1 g['particle_type']</font></div><div><font color="#006600"><br></font></div><div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in __getitem__(self, key)</font></div>
<div><font color="#006600">    155         """</font></div><div><font color="#006600">    156         if not self.field_data.has_key(key):</font></div><div><font color="#006600">--> 157             self.get_data(key)</font></div>
<div><font color="#006600">    158         return self.field_data[key]</font></div><div><font color="#006600">    159 </font></div><div><font color="#006600"><br></font></div><div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in get_data(self, field, convert)</font></div>
<div><font color="#006600">    188                     return self.field_data[field]</font></div><div><font color="#006600">    189                 try:</font></div><div><font color="#006600">--> 190                     temp = self.hierarchy.io.pop(self, field)</font></div>
<div><font color="#006600">    191                     self[field] = na.multiply(temp, conv_factor, temp)</font></div><div><font color="#006600">    192                 except self.hierarchy.io._read_exception, exc:</font></div>
<div><font color="#006600"><br></font></div><div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/utilities/io_handler.pyc in pop(self, grid, field)</font></div><div><font color="#006600">     59         else:</font></div>
<div><font color="#006600">     60             # We only read the one set and do not store it if it isn't pre-loaded</font></div><div><font color="#006600">---> 61             return self._read_data_set(grid, field)</font></div>
<div><font color="#006600">     62 </font></div><div><font color="#006600">     63     def peek(self, grid, field):</font></div><div><font color="#006600"><br></font></div><div><font color="#006600">/home/cshi31/yt-x86_64/src/yt-hg/yt/frontends/enzo/io.pyc in _read_data_set(self, grid, field)</font></div>
<div><font color="#006600">    183     def _read_data_set(self, grid, field):</font></div><div><font color="#006600">    184         return self.modify(hdf5_light_reader.ReadData(grid.filename,</font></div><div><font color="#006600">--> 185                 "/Grid%08i/%s" % (<a href="http://grid.id">grid.id</a>, field)))</font></div>
<div><font color="#006600">    186 </font></div><div><font color="#006600">    187     def _read_data_slice(self, grid, field, axis, coord):</font></div><div><font color="#006600"><br></font></div><div><font color="#006600">ReadingError: ReadHDF5DataSet: Unable to open /home/cshi31/research/SG256-RP/extract0062.cpu0000</font></div>
</div><div><br></div><div>Can anyone help me on this? Thanks very much.</div><div><br></div><div>Chao</div><div><br></div><div><br></div><div><br></div>