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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Oct 26 12:00:39 PDT 2015


11 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/a01f58e0945f/
Changeset:   a01f58e0945f
Branch:      yt
User:        qobilidop
Date:        2015-09-25 00:37:30+00:00
Summary:     add Dataset.add_smoothed_particle_field
Affected #:  1 file

diff -r d70d717bcd116621c0d30808a495b905a4046f58 -r a01f58e0945faca1ab731f20a047c08e6193d389 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -37,6 +37,8 @@
     FieldInfoContainer, NullFunc
 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 \
@@ -969,6 +971,52 @@
             validators=[ValidateSpatial()])
         return ("deposit", field_name)
 
+    def add_smoothed_particle_field(self, smooth_field,
+            method="volume_weighted", nneighbors=None, kernel_name='cubic'):
+        """Add a new deposited particle field
+
+        Creates a new deposited field based on the particle *deposit_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. Could only be
+           'volume_weighted' for now.
+        nneighbors : int, default None
+            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.
+        """
+        self.index
+        if isinstance(smooth_field, tuple):
+            ptype, smooth_field = smooth_field[0], smooth_field[1]
+        else:
+            raise RuntimeError
+        if method != "volume_weighted":
+            raise NotImplementedError
+
+        coord_name = "particle_position"
+        mass_name = "particle_mass"
+        smoothing_length_name = "smoothing_length"
+        density_name = "density"
+        registry = self.field_info
+
+        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.
 


https://bitbucket.org/yt_analysis/yt/commits/381895c5ab5f/
Changeset:   381895c5ab5f
Branch:      yt
User:        qobilidop
Date:        2015-09-25 00:51:55+00:00
Summary:     use double quotes consistently
Affected #:  1 file

diff -r a01f58e0945faca1ab731f20a047c08e6193d389 -r 381895c5ab5f9c2612a9b432599e50e8cdb633ac yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -972,7 +972,7 @@
         return ("deposit", field_name)
 
     def add_smoothed_particle_field(self, smooth_field,
-            method="volume_weighted", nneighbors=None, kernel_name='cubic'):
+            method="volume_weighted", nneighbors=None, kernel_name="cubic"):
         """Add a new deposited particle field
 
         Creates a new deposited field based on the particle *deposit_field*.


https://bitbucket.org/yt_analysis/yt/commits/2431c2b65565/
Changeset:   2431c2b65565
Branch:      yt
User:        qobilidop
Date:        2015-09-25 02:00:08+00:00
Summary:     improvements according to Nathan's comments
Affected #:  1 file

diff -r 381895c5ab5f9c2612a9b432599e50e8cdb633ac -r 2431c2b655657f62a89421298c1ac7fb4bac706a yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -971,11 +971,11 @@
             validators=[ValidateSpatial()])
         return ("deposit", field_name)
 
-    def add_smoothed_particle_field(self, smooth_field,
-            method="volume_weighted", nneighbors=None, kernel_name="cubic"):
-        """Add a new deposited particle field
+    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 deposited field based on the particle *deposit_field*.
+        Creates a new smoothed field based on the particle *smooth_field*.
 
         Parameters
         ----------
@@ -985,9 +985,9 @@
            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. Could only be
-           'volume_weighted' for now.
-        nneighbors : int, default None
+           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
@@ -1003,13 +1003,16 @@
         if isinstance(smooth_field, tuple):
             ptype, smooth_field = smooth_field[0], smooth_field[1]
         else:
-            raise RuntimeError
+            raise RuntimeError("smooth_field must be a tuple, received %s" %
+                               smooth_field)
         if method != "volume_weighted":
-            raise NotImplementedError
+            raise NotImplementedError("method must be 'volume_weighted'")
 
         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")
         density_name = "density"
         registry = self.field_info
 


https://bitbucket.org/yt_analysis/yt/commits/e378c4214d2f/
Changeset:   e378c4214d2f
Branch:      yt
User:        qobilidop
Date:        2015-09-25 02:05:12+00:00
Summary:     add test_add_smoothed_particle_field
Affected #:  1 file

diff -r 2431c2b655657f62a89421298c1ac7fb4bac706a -r e378c4214d2f1da815de96ad76e70cf2094bc38e yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -183,7 +183,14 @@
 
 def test_add_deposited_particle_field():
     fn = base_ds.add_deposited_particle_field(('io', 'particle_ones'), 'count')
-    assert_equal(fn, ('deposit', 'io_count_ones'))
+    assert_equal(fn, ('deposit', 'io_smoothed_ones'))
+    ad = base_ds.all_data()
+    ret = ad[fn]
+    assert_equal(ret.sum(), ad['particle_ones'].sum())
+
+def test_add_smoothed_particle_field():
+    fn = base_ds.add_smoothed_particle_field(('io', 'particle_ones'))
+    assert_equal(fn, ('deposit', 'io_smoothed_particle_ones'))
     ad = base_ds.all_data()
     ret = ad[fn]
     assert_equal(ret.sum(), ad['particle_ones'].sum())


https://bitbucket.org/yt_analysis/yt/commits/896c718c61ea/
Changeset:   896c718c61ea
Branch:      yt
User:        qobilidop
Date:        2015-09-25 02:15:58+00:00
Summary:     fix mistake
Affected #:  1 file

diff -r e378c4214d2f1da815de96ad76e70cf2094bc38e -r 896c718c61eacb2b8fc0b1ddd6f299b2783d66c7 yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -183,7 +183,7 @@
 
 def test_add_deposited_particle_field():
     fn = base_ds.add_deposited_particle_field(('io', 'particle_ones'), 'count')
-    assert_equal(fn, ('deposit', 'io_smoothed_ones'))
+    assert_equal(fn, ('deposit', 'io_count_ones'))
     ad = base_ds.all_data()
     ret = ad[fn]
     assert_equal(ret.sum(), ad['particle_ones'].sum())


https://bitbucket.org/yt_analysis/yt/commits/476f6872c1aa/
Changeset:   476f6872c1aa
Branch:      yt
User:        qobilidop
Date:        2015-09-25 02:33:46+00:00
Summary:     complete the error message
Affected #:  1 file

diff -r 896c718c61eacb2b8fc0b1ddd6f299b2783d66c7 -r 476f6872c1aa73729381b4c6002c29fb37e8fd85 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -1012,7 +1012,8 @@
         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")
+            raise ValueError("%s not in derived_field_list" %
+                             ((ptype, smoothing_length_name),))
         density_name = "density"
         registry = self.field_info
 


https://bitbucket.org/yt_analysis/yt/commits/b7dea247e4b6/
Changeset:   b7dea247e4b6
Branch:      yt
User:        qobilidop
Date:        2015-09-25 06:33:49+00:00
Summary:     correct test_add_smoothed_particle_field
Affected #:  1 file

diff -r 476f6872c1aa73729381b4c6002c29fb37e8fd85 -r b7dea247e4b66adfaa37c41b3dc238c5c2201869 yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -5,7 +5,8 @@
     assert_equal, \
     assert_array_almost_equal_nulp, \
     assert_array_equal, \
-    assert_raises
+    assert_raises, \
+    requires_file
 from yt.utilities.cosmology import \
     Cosmology
 from yt.frontends.stream.fields import \
@@ -188,10 +189,12 @@
     ret = ad[fn]
     assert_equal(ret.sum(), ad['particle_ones'].sum())
 
+ at requires_file('GadgetDiskGalaxy/snapshot_200.hdf5')
 def test_add_smoothed_particle_field():
-    fn = base_ds.add_smoothed_particle_field(('io', 'particle_ones'))
-    assert_equal(fn, ('deposit', 'io_smoothed_particle_ones'))
-    ad = base_ds.all_data()
+    ds = yt.load('GadgetDiskGalaxy/snapshot_200.hdf5')
+    fn = ds.add_smoothed_particle_field(('PartType0', 'particle_ones'))
+    assert_equal(fn, ('deposit', 'PartType0_smoothed_particle_ones'))
+    ad = ds.all_data()
     ret = ad[fn]
     assert_equal(ret.sum(), ad['particle_ones'].sum())
 


https://bitbucket.org/yt_analysis/yt/commits/303dda281678/
Changeset:   303dda281678
Branch:      yt
User:        qobilidop
Date:        2015-09-25 16:45:57+00:00
Summary:     import yt.load
Affected #:  1 file

diff -r b7dea247e4b66adfaa37c41b3dc238c5c2201869 -r 303dda281678baf795d38fcc8505cd168649ef11 yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -1,5 +1,7 @@
 import numpy as np
 
+from yt import \
+    load
 from yt.testing import \
     fake_random_ds, \
     assert_equal, \
@@ -191,7 +193,7 @@
 
 @requires_file('GadgetDiskGalaxy/snapshot_200.hdf5')
 def test_add_smoothed_particle_field():
-    ds = yt.load('GadgetDiskGalaxy/snapshot_200.hdf5')
+    ds = load('GadgetDiskGalaxy/snapshot_200.hdf5')
     fn = ds.add_smoothed_particle_field(('PartType0', 'particle_ones'))
     assert_equal(fn, ('deposit', 'PartType0_smoothed_particle_ones'))
     ad = ds.all_data()


https://bitbucket.org/yt_analysis/yt/commits/76a89bfee360/
Changeset:   76a89bfee360
Branch:      yt
User:        qobilidop
Date:        2015-10-13 01:02:57+00:00
Summary:     fix test (temporary solution)
Affected #:  1 file

diff -r 303dda281678baf795d38fcc8505cd168649ef11 -r 76a89bfee360f3da33f1fcca59f153a484676229 yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -198,7 +198,7 @@
     assert_equal(fn, ('deposit', 'PartType0_smoothed_particle_ones'))
     ad = ds.all_data()
     ret = ad[fn]
-    assert_equal(ret.sum(), ad['particle_ones'].sum())
+    assert_almost_equal(ret.sum(), 3824750.912653606)
 
 def test_add_gradient_fields():
     gfields = base_ds.add_gradient_fields(("gas","density"))


https://bitbucket.org/yt_analysis/yt/commits/a3ffe4a1ef70/
Changeset:   a3ffe4a1ef70
Branch:      yt
User:        qobilidop
Date:        2015-10-14 22:39:29+00:00
Summary:     import assert_almost_equal
Affected #:  1 file

diff -r 76a89bfee360f3da33f1fcca59f153a484676229 -r a3ffe4a1ef7059583a2c44455437d150663452ac yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -4,6 +4,7 @@
     load
 from yt.testing import \
     fake_random_ds, \
+    assert_almost_equal, \
     assert_equal, \
     assert_array_almost_equal_nulp, \
     assert_array_equal, \


https://bitbucket.org/yt_analysis/yt/commits/9a49e5d6da9f/
Changeset:   9a49e5d6da9f
Branch:      yt
User:        brittonsmith
Date:        2015-10-26 19:00:24+00:00
Summary:     Merged in qobilidop/yt (pull request #1769)

Add add_smoothed_particle_field
Affected #:  2 files

diff -r 0de661aae1faf32e535097b8f4557ac5e7f2a5a9 -r 9a49e5d6da9fc23bc7a2858bb5a304b9c4f5537b yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -37,6 +37,8 @@
     FieldInfoContainer, NullFunc
 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 \
@@ -968,6 +970,56 @@
             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.
+        """
+        self.index
+        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'")
+
+        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
+
+        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 0de661aae1faf32e535097b8f4557ac5e7f2a5a9 -r 9a49e5d6da9fc23bc7a2858bb5a304b9c4f5537b yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -1,11 +1,15 @@
 import numpy as np
 
+from yt import \
+    load
 from yt.testing import \
     fake_random_ds, \
+    assert_almost_equal, \
     assert_equal, \
     assert_array_almost_equal_nulp, \
     assert_array_equal, \
-    assert_raises
+    assert_raises, \
+    requires_file
 from yt.utilities.cosmology import \
     Cosmology
 from yt.frontends.stream.fields import \
@@ -188,6 +192,15 @@
     ret = ad[fn]
     assert_equal(ret.sum(), ad['particle_ones'].sum())
 
+ at requires_file('GadgetDiskGalaxy/snapshot_200.hdf5')
+def test_add_smoothed_particle_field():
+    ds = load('GadgetDiskGalaxy/snapshot_200.hdf5')
+    fn = ds.add_smoothed_particle_field(('PartType0', 'particle_ones'))
+    assert_equal(fn, ('deposit', 'PartType0_smoothed_particle_ones'))
+    ad = ds.all_data()
+    ret = ad[fn]
+    assert_almost_equal(ret.sum(), 3824750.912653606)
+
 def test_add_gradient_fields():
     gfields = base_ds.add_gradient_fields(("gas","density"))
     gfields += base_ds.add_gradient_fields(("index", "ones"))

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