[yt-svn] commit/yt: MatthewTurk: Merged in brittonsmith/yt (pull request #2406)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Oct 14 06:32:04 PDT 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/76b0b074f3cb/
Changeset:   76b0b074f3cb
Branch:      yt
User:        MatthewTurk
Date:        2016-10-14 13:31:37+00:00
Summary:     Merged in brittonsmith/yt (pull request #2406)

Allow GadgetFOF frontend to use ptype other than all for index
Affected #:  2 files

diff -r fe99e1de08bab01d351c03cd3d2439f2612dbaf8 -r 76b0b074f3cb157f5ed5e114b985ffb48cc48efc yt/frontends/gadget_fof/data_structures.py
--- a/yt/frontends/gadget_fof/data_structures.py
+++ b/yt/frontends/gadget_fof/data_structures.py
@@ -138,10 +138,11 @@
     _field_info_class = GadgetFOFFieldInfo
 
     def __init__(self, filename, dataset_type="gadget_fof_hdf5",
-                 n_ref=16, over_refine_factor=1,
+                 n_ref=16, over_refine_factor=1, index_ptype="all",
                  unit_base=None, units_override=None, unit_system="cgs"):
         self.n_ref = n_ref
         self.over_refine_factor = over_refine_factor
+        self.index_ptype = index_ptype
         if unit_base is not None and "UnitLength_in_cm" in unit_base:
             # We assume this is comoving, because in the absence of comoving
             # integration the redshift will be zero.

diff -r fe99e1de08bab01d351c03cd3d2439f2612dbaf8 -r 76b0b074f3cb157f5ed5e114b985ffb48cc48efc yt/frontends/gadget_fof/io.py
--- a/yt/frontends/gadget_fof/io.py
+++ b/yt/frontends/gadget_fof/io.py
@@ -113,7 +113,12 @@
                         yield (ptype, field), data
 
     def _initialize_index(self, data_file, regions):
-        pcount = sum(data_file.total_particles.values())
+        if self.index_ptype == "all":
+            ptypes = self.ds.particle_types_raw
+            pcount = sum(data_file.total_particles.values())
+        else:
+            ptypes = [self.index_ptype]
+            pcount = data_file.total_particles[self.index_ptype]
         morton = np.empty(pcount, dtype='uint64')
         if pcount == 0: return morton
         mylog.debug("Initializing index % 5i (% 7i particles)",
@@ -124,12 +129,12 @@
             dx = np.finfo(f["Group"]["GroupPos"].dtype).eps
             dx = 2.0*self.ds.quan(dx, "code_length")
 
-            for ptype in data_file.ds.particle_types_raw:
+            for ptype in ptypes:
                 if data_file.total_particles[ptype] == 0: continue
                 pos = f[ptype]["%sPos" % ptype].value.astype("float64")
                 pos = np.resize(pos, (data_file.total_particles[ptype], 3))
                 pos = data_file.ds.arr(pos, "code_length")
-                
+
                 # These are 32 bit numbers, so we give a little lee-way.
                 # Otherwise, for big sets of particles, we often will bump into the
                 # domain edges.  This helps alleviate that.

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