[yt-svn] commit/yt: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Dec 19 18:57:29 PST 2016


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/88e4005be561/
Changeset:   88e4005be561
Branch:      yt
User:        qobilidop
Date:        2016-12-16 17:35:56+00:00
Summary:     Move `add_smoothed_particle_field` back to `Dataset`

See https://bitbucket.org/trident-project/trident/issues/10. Currently the quick solution is to move the method back. An overrode version is kept in `SPHDataset` to use the instance-wide kernel name setting.
Affected #:  2 files

diff -r dcfa4d3f885f3a2c907acb32431c47cff2c6b561 -r 88e4005be561a5f8647e4efcf3bd8467b39671c8 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -51,6 +51,8 @@
     ValidateSpatial
 from yt.fields.fluid_fields import \
     setup_gradient_fields
+from yt.fields.particle_fields import \
+    add_volume_weighted_smoothed_field
 from yt.data_objects.particle_filters import \
     filter_registry
 from yt.data_objects.particle_unions import \
@@ -1221,6 +1223,62 @@
             validators=[ValidateSpatial()])
         return ("deposit", field_name)
 
+    def add_smoothed_particle_field(self, smooth_field,
+                                    method="volume_weighted", nneighbors=64,
+                                    kernel_name="cubic"):
+        """Add a new smoothed particle field
+
+        Creates a new smoothed field based on the particle *smooth_field*.
+
+        Parameters
+        ----------
+
+        smooth_field : tuple
+           The field name tuple of the particle field the smoothed field will
+           be created from.  This must be a field name tuple so yt can
+           appropriately infer the correct particle type.
+        method : string, default 'volume_weighted'
+           The particle smoothing method to use. Can only be 'volume_weighted'
+           for now.
+        nneighbors : int, default 64
+            The number of neighbors to examine during the process.
+        kernel_name : string, default `cubic`
+            This is the name of the smoothing kernel to use. Current supported
+            kernel names include `cubic`, `quartic`, `quintic`, `wendland2`,
+            `wendland4`, and `wendland6`.
+
+        Returns
+        -------
+
+        The field name tuple for the newly created field.
+        """
+        # The magical step
+        self.index
+
+        # Parse arguments
+        if isinstance(smooth_field, tuple):
+            ptype, smooth_field = smooth_field[0], smooth_field[1]
+        else:
+            raise RuntimeError("smooth_field must be a tuple, received %s" %
+                               smooth_field)
+        if method != "volume_weighted":
+            raise NotImplementedError("method must be 'volume_weighted'")
+
+        # Prepare field names and registry to be used later
+        coord_name = "particle_position"
+        mass_name = "particle_mass"
+        smoothing_length_name = "smoothing_length"
+        if (ptype, smoothing_length_name) not in self.derived_field_list:
+            raise ValueError("%s not in derived_field_list" %
+                             ((ptype, smoothing_length_name),))
+        density_name = "density"
+        registry = self.field_info
+
+        # Do the actual work
+        return add_volume_weighted_smoothed_field(ptype, coord_name, mass_name,
+                   smoothing_length_name, density_name, smooth_field, registry,
+                   nneighbors=nneighbors, kernel_name=kernel_name)[0]
+
     def add_gradient_fields(self, input_field):
         """Add gradient fields.
 

diff -r dcfa4d3f885f3a2c907acb32431c47cff2c6b561 -r 88e4005be561a5f8647e4efcf3bd8467b39671c8 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -17,8 +17,6 @@
 
 from yt.data_objects.static_output import \
     ParticleDataset
-from yt.fields.particle_fields import \
-    add_volume_weighted_smoothed_field
 
 
 class SPHDataset(ParticleDataset):
@@ -68,31 +66,9 @@
 
         The field name tuple for the newly created field.
         """
-        # The magical step
-        self.index
-
-        # Parse arguments
-        if isinstance(smooth_field, tuple):
-            ptype, smooth_field = smooth_field[0], smooth_field[1]
-        else:
-            raise RuntimeError("smooth_field must be a tuple, received %s" %
-                               smooth_field)
-        if method != "volume_weighted":
-            raise NotImplementedError("method must be 'volume_weighted'")
         if kernel_name is None:
             kernel_name = self.kernel_name
-
-        # Prepare field names and registry to be used later
-        coord_name = "particle_position"
-        mass_name = "particle_mass"
-        smoothing_length_name = "smoothing_length"
-        if (ptype, smoothing_length_name) not in self.derived_field_list:
-            raise ValueError("%s not in derived_field_list" %
-                             ((ptype, smoothing_length_name),))
-        density_name = "density"
-        registry = self.field_info
-
-        # Do the actual work
-        return add_volume_weighted_smoothed_field(ptype, coord_name, mass_name,
-                   smoothing_length_name, density_name, smooth_field, registry,
-                   nneighbors=nneighbors, kernel_name=kernel_name)[0]
+        super(SPHDataset, self).add_smoothed_particle_field(
+            smooth_field=smooth_field, method=method, nneighbors=nneighbors,
+            kernel_name=kernel_name
+        )


https://bitbucket.org/yt_analysis/yt/commits/1d045b790ab4/
Changeset:   1d045b790ab4
Branch:      yt
User:        ngoldbaum
Date:        2016-12-20 02:57:00+00:00
Summary:     Merged in qobilidop/yt (pull request #2475)

Move `add_smoothed_particle_field` back to `Dataset`
Affected #:  2 files

diff -r 97ae0cc375fb2ec473e7c95e2afe27c4b152a53a -r 1d045b790ab412f6670023e97f420691a657443f yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -51,6 +51,8 @@
     ValidateSpatial
 from yt.fields.fluid_fields import \
     setup_gradient_fields
+from yt.fields.particle_fields import \
+    add_volume_weighted_smoothed_field
 from yt.data_objects.particle_filters import \
     filter_registry
 from yt.data_objects.particle_unions import \
@@ -1221,6 +1223,62 @@
             validators=[ValidateSpatial()])
         return ("deposit", field_name)
 
+    def add_smoothed_particle_field(self, smooth_field,
+                                    method="volume_weighted", nneighbors=64,
+                                    kernel_name="cubic"):
+        """Add a new smoothed particle field
+
+        Creates a new smoothed field based on the particle *smooth_field*.
+
+        Parameters
+        ----------
+
+        smooth_field : tuple
+           The field name tuple of the particle field the smoothed field will
+           be created from.  This must be a field name tuple so yt can
+           appropriately infer the correct particle type.
+        method : string, default 'volume_weighted'
+           The particle smoothing method to use. Can only be 'volume_weighted'
+           for now.
+        nneighbors : int, default 64
+            The number of neighbors to examine during the process.
+        kernel_name : string, default `cubic`
+            This is the name of the smoothing kernel to use. Current supported
+            kernel names include `cubic`, `quartic`, `quintic`, `wendland2`,
+            `wendland4`, and `wendland6`.
+
+        Returns
+        -------
+
+        The field name tuple for the newly created field.
+        """
+        # The magical step
+        self.index
+
+        # Parse arguments
+        if isinstance(smooth_field, tuple):
+            ptype, smooth_field = smooth_field[0], smooth_field[1]
+        else:
+            raise RuntimeError("smooth_field must be a tuple, received %s" %
+                               smooth_field)
+        if method != "volume_weighted":
+            raise NotImplementedError("method must be 'volume_weighted'")
+
+        # Prepare field names and registry to be used later
+        coord_name = "particle_position"
+        mass_name = "particle_mass"
+        smoothing_length_name = "smoothing_length"
+        if (ptype, smoothing_length_name) not in self.derived_field_list:
+            raise ValueError("%s not in derived_field_list" %
+                             ((ptype, smoothing_length_name),))
+        density_name = "density"
+        registry = self.field_info
+
+        # Do the actual work
+        return add_volume_weighted_smoothed_field(ptype, coord_name, mass_name,
+                   smoothing_length_name, density_name, smooth_field, registry,
+                   nneighbors=nneighbors, kernel_name=kernel_name)[0]
+
     def add_gradient_fields(self, input_field):
         """Add gradient fields.
 

diff -r 97ae0cc375fb2ec473e7c95e2afe27c4b152a53a -r 1d045b790ab412f6670023e97f420691a657443f yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -17,8 +17,6 @@
 
 from yt.data_objects.static_output import \
     ParticleDataset
-from yt.fields.particle_fields import \
-    add_volume_weighted_smoothed_field
 
 
 class SPHDataset(ParticleDataset):
@@ -68,31 +66,9 @@
 
         The field name tuple for the newly created field.
         """
-        # The magical step
-        self.index
-
-        # Parse arguments
-        if isinstance(smooth_field, tuple):
-            ptype, smooth_field = smooth_field[0], smooth_field[1]
-        else:
-            raise RuntimeError("smooth_field must be a tuple, received %s" %
-                               smooth_field)
-        if method != "volume_weighted":
-            raise NotImplementedError("method must be 'volume_weighted'")
         if kernel_name is None:
             kernel_name = self.kernel_name
-
-        # Prepare field names and registry to be used later
-        coord_name = "particle_position"
-        mass_name = "particle_mass"
-        smoothing_length_name = "smoothing_length"
-        if (ptype, smoothing_length_name) not in self.derived_field_list:
-            raise ValueError("%s not in derived_field_list" %
-                             ((ptype, smoothing_length_name),))
-        density_name = "density"
-        registry = self.field_info
-
-        # Do the actual work
-        return add_volume_weighted_smoothed_field(ptype, coord_name, mass_name,
-                   smoothing_length_name, density_name, smooth_field, registry,
-                   nneighbors=nneighbors, kernel_name=kernel_name)[0]
+        super(SPHDataset, self).add_smoothed_particle_field(
+            smooth_field=smooth_field, method=method, nneighbors=nneighbors,
+            kernel_name=kernel_name
+        )

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list