コード例 #1
0
 def process_chunk(self,
                   data,
                   use_gas=True,
                   use_particles=True,
                   particle_type="nbody"):
     if use_particles and particle_type not in self.data_source.ds.particle_types:
         raise YTParticleTypeNotFound(particle_type, self.data_source.ds)
     use_gas &= ("gas", "mass") in self.data_source.ds.field_info
     use_particles &= (
         particle_type,
         "particle_mass",
     ) in self.data_source.ds.field_info
     e = data.ds.quan(0.0, "erg")
     j = data.ds.quan(0.0, "g*cm**2/s")
     m = data.ds.quan(0.0, "g")
     if use_gas:
         e += (data["gas", "kinetic_energy_density"] *
               data["gas", "volume"]).sum(dtype=np.float64)
         j += data["gas",
                   "angular_momentum_magnitude"].sum(dtype=np.float64)
         m += data["gas", "mass"].sum(dtype=np.float64)
     if use_particles:
         e += (data[particle_type, "particle_velocity_magnitude"]**2 *
               data[particle_type, "particle_mass"]).sum(dtype=np.float64)
         j += data[particle_type,
                   "particle_angular_momentum_magnitude"].sum(
                       dtype=np.float64)
         m += data[particle_type, "particle_mass"].sum(dtype=np.float64)
     return (e, j, m)
コード例 #2
0
 def count_values(self, use_gas=True, use_particles=False, particle_type="nbody"):
     if use_particles and particle_type not in self.data_source.ds.particle_types:
         raise YTParticleTypeNotFound(particle_type, self.data_source.ds)
     # This is a list now
     self.num_vals = 0
     if use_gas:
         self.num_vals += 4
     if use_particles and "nbody" in self.data_source.ds.particle_types:
         self.num_vals += 4
コード例 #3
0
 def count_values(self,
                  use_gas=True,
                  use_particles=False,
                  particle_type="all"):
     if use_particles and particle_type not in self.data_source.ds.particle_types:
         raise YTParticleTypeNotFound(particle_type, self.data_source.ds)
     use_gas &= \
       (("gas", "cell_mass") in self.data_source.ds.field_info)
     use_particles &= \
       ((particle_type, "particle_mass") in self.data_source.ds.field_info)
     self.num_vals = 0
     if use_gas:
         self.num_vals += 4
     if use_particles:
         self.num_vals += 4
コード例 #4
0
 def count_values(self, use_gas=True, use_particles=True, particle_type="all"):
     if use_particles and particle_type not in self.data_source.ds.particle_types:
         raise YTParticleTypeNotFound(particle_type, self.data_source.ds)
     num_vals = 0
     # create the index if it doesn't exist yet
     self.data_source.ds.index
     self.particle_type = particle_type
     self.use_gas = use_gas & (("gas", "mass") in self.data_source.ds.field_info)
     self.use_particles = use_particles & (
         (self.particle_type, "particle_mass") in self.data_source.ds.field_info
     )
     if self.use_gas:
         num_vals += 4
     if self.use_particles:
         num_vals += 4
     self.num_vals = num_vals