Commits

Matthew Turk  committed f31b767

Fixing some issues with the Particle Generator.

Stream needs field types.

  • Participants
  • Parent commits 10bd9a4

Comments (0)

Files changed (4)

File yt/frontends/stream/data_structures.py

         """
         
         particle_types = set_particle_types(data[0])
+        ftype = "all"
 
         for key in data[0].keys() :
             if key is "number_of_particles": continue
         for i, grid in enumerate(self.grids) :
             if data[i].has_key("number_of_particles") :
                 grid.NumberOfParticles = data[i].pop("number_of_particles")
-            for key in data[i].keys() :
-                if key in grid.keys() : grid.field_data.pop(key, None)
-                self.stream_handler.fields[grid.id][key] = data[i][key]
+            for fname in data[i]:
+                if fname in grid.field_data:
+                    grid.field_data.pop(fname, None)
+                elif (ftype, fname) in grid.field_data:
+                    grid.field_data.pop( ("all", fname) )
+                self.stream_handler.fields[grid.id][fname] = data[i][fname]
             
         self._detect_fields()
         self._setup_unknown_fields()

File yt/frontends/stream/fields.py

 StreamFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
 add_field = StreamFieldInfo.add_field
 
+add_stream_field("particle_position_x", function = NullFunc, particle_type=True)
+add_stream_field("particle_position_y", function = NullFunc, particle_type=True)
+add_stream_field("particle_position_z", function = NullFunc, particle_type=True)
+add_stream_field("particle_index", function = NullFunc, particle_type=True)
+add_stream_field("particle_gas_density", function = NullFunc, particle_type=True)
+add_stream_field("particle_gas_temperature", function = NullFunc, particle_type=True)

File yt/frontends/stream/io.py

             for g in chunk.objs:
                 if g.NumberOfParticles == 0: continue
                 size += g.count_particles(selector, 
-                    self.fields[g.id][pfields[0]],
-                    self.fields[g.id][pfields[1]],
-                    self.fields[g.id][pfields[2]])
+                    self.fields[g.id][pfields[0][1]],
+                    self.fields[g.id][pfields[1][1]],
+                    self.fields[g.id][pfields[2][1]])
         for field in fields:
             # TODO: figure out dataset types
             rv[field] = np.empty(size, dtype='float64')
             for g in chunk.objs:
                 if g.NumberOfParticles == 0: continue
                 mask = g.select_particles(selector,
-                    self.fields[g.id][pfields[0]],
-                    self.fields[g.id][pfields[1]],
-                    self.fields[g.id][pfields[2]])
+                    self.fields[g.id][pfields[0][1]],
+                    self.fields[g.id][pfields[1][1]],
+                    self.fields[g.id][pfields[2][1]])
                 if mask is None: continue
                 for field in set(fields):
-                    gdata = self.fields[g.id][field][mask]
+                    gdata = self.fields[g.id][field[1]][mask]
                     rv[field][ind:ind+gdata.size] = gdata
                 ind += gdata.size
         return rv

File yt/utilities/particle_generator.py

                                 self.particles[start:end,field_index],
                                 np.int64(self.NumberOfParticles[i]),
                                 cube[gfield], le, dims,
-                                np.float64(grid['dx']))
+                                grid.dds[0])
         pbar.finish()
 
     def apply_to_stream(self, clobber=False) :