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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Mar 24 21:22:19 PDT 2014


7 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/b8fd8ff24d64/
Changeset:   b8fd8ff24d64
Branch:      yt-3.0
User:        BW Keller
Date:        2014-03-25 01:56:25
Summary:     Added specific fields for units and smoothing of Tipsy data.
Affected #:  2 files

diff -r 52d107903dc7266ae046be4adb93c0cc40cdb052 -r b8fd8ff24d6471b36d50a7a5d4ce4baa9a59cb4e yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -38,7 +38,7 @@
     mass_sun_cgs
 from yt.utilities.cosmology import Cosmology
 from .fields import \
-    SPHFieldInfo, OWLSFieldInfo
+    SPHFieldInfo, OWLSFieldInfo, TipsyFieldInfo
 from .definitions import \
     gadget_header_specs, \
     gadget_field_specs, \
@@ -356,7 +356,7 @@
 class TipsyDataset(ParticleDataset):
     _index_class = ParticleIndex
     _file_class = TipsyFile
-    _field_info_class = SPHFieldInfo
+    _field_info_class = TipsyFieldInfo
     _particle_mass_name = "Mass"
     _particle_coordinates_name = "Coordinates"
     _header_spec = (('time',    'd'),

diff -r 52d107903dc7266ae046be4adb93c0cc40cdb052 -r b8fd8ff24d6471b36d50a7a5d4ce4baa9a59cb4e yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -57,6 +57,36 @@
 
 
 
+class TipsyFieldInfo(SPHFieldInfo):
+
+    aux_particle_fields = {
+            'uDotFB':("uDotFB", ("code_mass * code_velocity**2", ["uDotFB"], None)),
+            'uDotAV':("uDotAV", ("code_mass * code_velocity**2", ["uDotAV"], None)),
+            'uDotPdV':("uDotPdV", ("code_mass * code_velocity**2", ["uDotPdV"], None)),
+            'uDotHydro':("uDotHydro", ("code_mass * code_velocity**2", ["uDotHydro"], None)),
+            'uDotDiff':("uDotDiff", ("code_mass * code_velocity**2", ["uDotDiff"], None)),
+            'uDot':("uDot", ("code_mass * code_velocity**2", ["uDot"], None)),
+            'coolontime':("coolontime", ("code_time", ["coolontime"], None)),
+            'timeform':("timeform", ("code_time", ["timeform"], None)),
+            'massform':("massform", ("code_mass", ["massform"], None)),
+            'HI':("HI", ("dimensionless", ["HI"], None)),
+            'HII':("HII", ("dimensionless", ["HII"], None)),
+            'HeI':("HeI", ("dimensionless", ["HeI"], None)),
+            'HeII':("HeII", ("dimensionless", ["HeII"], None)),
+            'OxMassFrac':("OxMassFrac", ("dimensionless", ["OxMassFrac"], None)),
+            'FeMassFrac':("FeMassFrac", ("dimensionless", ["FeMassFrac"], None)),
+            'c':("c", ("code_velocity", ["c"], None)),
+            'acc':("acc", ("code_velocity / code_time", ["acc"], None)),
+            'accg':("accg", ("code_velocity / code_time", ["accg"], None))}
+    def __init__(self, pf, field_list, slice_info = None):
+        for field in field_list:
+            if field[1] in self.aux_particle_fields.keys() and \
+                self.aux_particle_fields[field[1]] not in self.known_particle_fields:
+                self.known_particle_fields += (self.aux_particle_fields[field[1]],)
+        super(TipsyFieldInfo,self).__init__(pf, field_list, slice_info)
+
+
+        
 
 class OWLSFieldInfo(SPHFieldInfo):
 


https://bitbucket.org/yt_analysis/yt/commits/9fed1094c210/
Changeset:   9fed1094c210
Branch:      yt-3.0
User:        BW Keller
Date:        2014-03-25 01:59:17
Summary:     Merged experimental
Affected #:  1 file

diff -r b8fd8ff24d6471b36d50a7a5d4ce4baa9a59cb4e -r 9fed1094c21091af76eca06a77a0f4754f730157 yt/analysis_modules/sunyaev_zeldovich/projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/projection.py
@@ -53,7 +53,7 @@
 
     def _beta_par_squared(field, data):
         return data["gas","beta_par"]**2/data["gas","density"]
-    registry.add_field("gas","beta_par_squared",
+    registry.add_field(("gas","beta_par_squared"),
                        function = _beta_par_squared,
                        units="g/cm**3")
 
@@ -148,7 +148,7 @@
         L[axis] = 1.0
 
         beta_par = generate_beta_par(L)
-        self.pf.field_info.add_field(name=("gas","beta_par"), function=beta_par, units="g/cm**3")
+        self.pf.field_info.add_field(("gas","beta_par"), function=beta_par, units="g/cm**3")
         frb = proj.to_frb(width, nx)
         dens = frb["density"]
         Te = frb["t_sz"]/dens
@@ -211,7 +211,7 @@
             raise NotImplementedError
 
         beta_par = generate_beta_par(L)
-        self.pf.field_info.add_field(name=("gas","beta_par"), function=beta_par, units="g/cm**3")
+        self.pf.field_info.add_field(("gas","beta_par"), function=beta_par, units="g/cm**3")
 
         dens    = off_axis_projection(self.pf, ctr, L, w, nx, "density")
         Te      = off_axis_projection(self.pf, ctr, L, w, nx, "t_sz")/dens


https://bitbucket.org/yt_analysis/yt/commits/e08822f02e2c/
Changeset:   e08822f02e2c
Branch:      yt-3.0
User:        BW Keller
Date:        2014-03-25 02:57:30
Summary:     Removed the need to manually specify endianness and filled in the _is_valid
method, so load() now works with tipsy files.
Affected #:  1 file

diff -r 9fed1094c21091af76eca06a77a0f4754f730157 -r e08822f02e2c4090108db8a05aa1d7bae5de2da6 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -368,7 +368,6 @@
                     ('dummy',   'i'))
 
     def __init__(self, filename, dataset_type="tipsy",
-                 endian=">",
                  field_dtypes=None,
                  domain_left_edge=None,
                  domain_right_edge=None,
@@ -378,7 +377,7 @@
                  n_ref=64, over_refine_factor=1):
         self.n_ref = n_ref
         self.over_refine_factor = over_refine_factor
-        self.endian = endian
+        self.endian = self._validate_header(filename)[1]
         self.storage_filename = None
         if domain_left_edge is None:
             domain_left_edge = np.zeros(3, "float64") - 0.5
@@ -515,10 +514,35 @@
             density_unit = self.mass_unit / self.length_unit**3
         self.time_unit = 1.0 / np.sqrt(G * density_unit)
 
+    @staticmethod
+    def _validate_header(filename):
+        try:
+            f = open(filename,'rb')
+        except:
+            return False, 1
+        fs = len(f.read())
+        f.seek(0)
+        #Read in the header
+        t, n, ndim, ng, nd, ns = struct.unpack("<diiiii", f.read(28))
+        endianswap = "<"
+        #Check Endianness
+        if (ndim < 1 or ndim > 3):
+            endianswap = ">"
+            f.seek(0)
+            t, n, ndim, ng, nd, ns = struct.unpack(">diiiii", f.read(28))
+        #Catch for 4 byte padding
+        if (fs == 32+48*ng+36*nd+44*ns):
+            f.read(4)
+        #File is borked if this is true
+        elif (fs != 28+48*ng+36*nd+44*ns):
+            f.close()
+            return False, 0
+        f.close()
+        return True, endianswap
+
     @classmethod
     def _is_valid(self, *args, **kwargs):
-        # We do not allow load() of these files.
-        return False
+        return TipsyDataset._validate_header(args[0])[0]
 
 class HTTPParticleFile(ParticleFile):
     pass


https://bitbucket.org/yt_analysis/yt/commits/771700bdb543/
Changeset:   771700bdb543
Branch:      yt-3.0
User:        BW Keller
Date:        2014-03-25 02:59:06
Summary:     Merged changes from upstream.
Affected #:  4 files

diff -r e08822f02e2c4090108db8a05aa1d7bae5de2da6 -r 771700bdb54301921de408a3aa788468cbad3e2f yt/analysis_modules/sunyaev_zeldovich/projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/projection.py
@@ -149,6 +149,8 @@
 
         beta_par = generate_beta_par(L)
         self.pf.field_info.add_field(("gas","beta_par"), function=beta_par, units="g/cm**3")
+        proj = self.pf.h.proj("density", axis, center=ctr, data_source=source)
+        proj.set_field_parameter("axis", axis)
         frb = proj.to_frb(width, nx)
         dens = frb["density"]
         Te = frb["t_sz"]/dens

diff -r e08822f02e2c4090108db8a05aa1d7bae5de2da6 -r 771700bdb54301921de408a3aa788468cbad3e2f yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -14,7 +14,6 @@
 #-----------------------------------------------------------------------------
 import numpy as np
 import os.path
-import glob
 import stat
 import weakref
 import cStringIO
@@ -203,14 +202,17 @@
         particle header, star files, etc.
         """
         base_prefix, base_suffix = filename_pattern['amr']
+        aexpstr = 'a'+file_amr.rsplit('a',1)[1].replace(base_suffix,'')
         possibles = glob.glob(os.path.dirname(file_amr)+"/*")
         for filetype, (prefix, suffix) in filename_pattern.iteritems():
             # if this attribute is already set skip it
             if getattr(self, "_file_"+filetype, None) is not None:
                 continue
-            stripped = file_amr.replace(base_prefix, prefix)
-            stripped = stripped.replace(base_suffix, suffix)
-            match, = difflib.get_close_matches(stripped, possibles, 1, 0.6)
+            match = None
+            for possible in possibles:
+                if possible.endswith(aexpstr+suffix):
+                    if os.path.basename(possible).startswith(prefix):
+                        match = possible
             if match is not None:
                 mylog.info('discovered %s:%s', filetype, match)
                 setattr(self, "_file_"+filetype, match)

diff -r e08822f02e2c4090108db8a05aa1d7bae5de2da6 -r 771700bdb54301921de408a3aa788468cbad3e2f yt/frontends/art/tests/test_outputs.py
--- a/yt/frontends/art/tests/test_outputs.py
+++ b/yt/frontends/art/tests/test_outputs.py
@@ -1,5 +1,5 @@
 """
-ART frontend tests using SFG1 a=0.330
+ART frontend tests using D9p a=0.500
 
 
 
@@ -22,20 +22,22 @@
     data_dir_load
 from yt.frontends.art.api import ARTDataset
 
-_fields = ("Density", "particle_mass", ("all", "particle_position_x"))
+_fields = ("Temperature", "Density", "particle_mass", ("all", "particle_position_x"))
 
-sfg1 = "10MpcBox_csf512_a0.330.d"
+d9p = "D9p_500/10MpcBox_HartGal_csf_a0.500.d"
 
-
- at requires_pf(sfg1, big_data=True)
-def test_sfg1():
-    pf = data_dir_load(sfg1)
-    yield assert_equal, str(pf), "10MpcBox_csf512_a0.330.d"
+ at requires_pf(d9p, big_data=True)
+def test_d9p():
+    pf = data_dir_load(d9p)
+    yield assert_equal, str(pf), "10MpcBox_HartGal_csf_a0.500.d"
+    for test in big_patch_amr(d9p, _fields):
+        test_d9p.__name__ = test.description
+        yield test
     dso = [None, ("sphere", ("max", (0.1, 'unitary')))]
     for field in _fields:
         for axis in [0, 1, 2]:
             for ds in dso:
                 for weight_field in [None, "Density"]:
                     yield PixelizedProjectionValuesTest(
-                        sfg1, axis, field, weight_field,
+                        d9p, axis, field, weight_field,
                         ds)


https://bitbucket.org/yt_analysis/yt/commits/eb210e28a4e9/
Changeset:   eb210e28a4e9
Branch:      yt-3.0
User:        BW Keller
Date:        2014-03-25 05:14:36
Summary:     Updated documentation to reflect new changes in Tipsy file handling.
Affected #:  3 files

diff -r 771700bdb54301921de408a3aa788468cbad3e2f -r eb210e28a4e91437aa6cb4161f58be5adb6d3912 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -372,25 +372,6 @@
 particle type specifications.  *These are all excellent projects for new
 contributors!*
 
-Tipsy data cannot be automatically detected.  You can load it with a command
-similar to the following:
-
-.. code-block:: python
-
-    ds = TipsyDataset('test.00169',
-        parameter_file='test.param',
-        endian = '<',
-        domain_left_edge = domain_left_edge,
-        domain_right_edge = domain_right_edge,
-    )
-
-Not all of these arguments are necessary; additionally, yt accepts the
-arguments ``n_ref``, ``over_refine_factor``, ``cosmology_parameters``, and
-``unit_base``.  By default, yt will not utilize a parameter file, and by
-default it will assume the data is "big" endian (`>`).  Optionally, you may
-specify ``field_dtypes``, which describe the size of various fields.  For
-example, if you have stored positions as 64-bit floats, you can specify this
-with:
 
 .. code-block:: python
 

diff -r 771700bdb54301921de408a3aa788468cbad3e2f -r eb210e28a4e91437aa6cb4161f58be5adb6d3912 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -540,6 +540,32 @@
         f.close()
         return True, endianswap
 
+    @staticmethod
+    def _validate_header(filename):
+        try:
+            f = open(filename,'rb')
+        except:
+            return False, 1
+        fs = len(f.read())
+        f.seek(0)
+        #Read in the header
+        t, n, ndim, ng, nd, ns = struct.unpack("<diiiii", f.read(28))
+        endianswap = "<"
+        #Check Endianness
+        if (ndim < 1 or ndim > 3):
+            endianswap = ">"
+            f.seek(0)
+            t, n, ndim, ng, nd, ns = struct.unpack(">diiiii", f.read(28))
+        #Catch for 4 byte padding
+        if (fs == 32+48*ng+36*nd+44*ns):
+            f.read(4)
+        #File is borked if this is true
+        elif (fs != 28+48*ng+36*nd+44*ns):
+            f.close()
+            return False, 0
+        f.close()
+        return True, endianswap
+
     @classmethod
     def _is_valid(self, *args, **kwargs):
         return TipsyDataset._validate_header(args[0])[0]

diff -r 771700bdb54301921de408a3aa788468cbad3e2f -r eb210e28a4e91437aa6cb4161f58be5adb6d3912 yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -59,30 +59,30 @@
 
 class TipsyFieldInfo(SPHFieldInfo):
 
-    aux_particle_fields = {
-            'uDotFB':("uDotFB", ("code_mass * code_velocity**2", ["uDotFB"], None)),
-            'uDotAV':("uDotAV", ("code_mass * code_velocity**2", ["uDotAV"], None)),
-            'uDotPdV':("uDotPdV", ("code_mass * code_velocity**2", ["uDotPdV"], None)),
-            'uDotHydro':("uDotHydro", ("code_mass * code_velocity**2", ["uDotHydro"], None)),
-            'uDotDiff':("uDotDiff", ("code_mass * code_velocity**2", ["uDotDiff"], None)),
-            'uDot':("uDot", ("code_mass * code_velocity**2", ["uDot"], None)),
-            'coolontime':("coolontime", ("code_time", ["coolontime"], None)),
-            'timeform':("timeform", ("code_time", ["timeform"], None)),
-            'massform':("massform", ("code_mass", ["massform"], None)),
-            'HI':("HI", ("dimensionless", ["HI"], None)),
-            'HII':("HII", ("dimensionless", ["HII"], None)),
-            'HeI':("HeI", ("dimensionless", ["HeI"], None)),
-            'HeII':("HeII", ("dimensionless", ["HeII"], None)),
-            'OxMassFrac':("OxMassFrac", ("dimensionless", ["OxMassFrac"], None)),
-            'FeMassFrac':("FeMassFrac", ("dimensionless", ["FeMassFrac"], None)),
-            'c':("c", ("code_velocity", ["c"], None)),
-            'acc':("acc", ("code_velocity / code_time", ["acc"], None)),
-            'accg':("accg", ("code_velocity / code_time", ["accg"], None))}
     def __init__(self, pf, field_list, slice_info = None):
+        aux_particle_fields = {
+                'uDotFB':("uDotFB", ("code_mass * code_velocity**2", ["uDotFB"], None)),
+                'uDotAV':("uDotAV", ("code_mass * code_velocity**2", ["uDotAV"], None)),
+                'uDotPdV':("uDotPdV", ("code_mass * code_velocity**2", ["uDotPdV"], None)),
+                'uDotHydro':("uDotHydro", ("code_mass * code_velocity**2", ["uDotHydro"], None)),
+                'uDotDiff':("uDotDiff", ("code_mass * code_velocity**2", ["uDotDiff"], None)),
+                'uDot':("uDot", ("code_mass * code_velocity**2", ["uDot"], None)),
+                'coolontime':("coolontime", ("code_time", ["coolontime"], None)),
+                'timeform':("timeform", ("code_time", ["timeform"], None)),
+                'massform':("massform", ("code_mass", ["massform"], None)),
+                'HI':("HI", ("dimensionless", ["HI"], None)),
+                'HII':("HII", ("dimensionless", ["HII"], None)),
+                'HeI':("HeI", ("dimensionless", ["HeI"], None)),
+                'HeII':("HeII", ("dimensionless", ["HeII"], None)),
+                'OxMassFrac':("OxMassFrac", ("dimensionless", ["OxMassFrac"], None)),
+                'FeMassFrac':("FeMassFrac", ("dimensionless", ["FeMassFrac"], None)),
+                'c':("c", ("code_velocity", ["c"], None)),
+                'acc':("acc", ("code_velocity / code_time", ["acc"], None)),
+                'accg':("accg", ("code_velocity / code_time", ["accg"], None))}
         for field in field_list:
-            if field[1] in self.aux_particle_fields.keys() and \
-                self.aux_particle_fields[field[1]] not in self.known_particle_fields:
-                self.known_particle_fields += (self.aux_particle_fields[field[1]],)
+            if field[1] in aux_particle_fields.keys() and \
+                aux_particle_fields[field[1]] not in self.known_particle_fields:
+                self.known_particle_fields += (aux_particle_fields[field[1]],)
         super(TipsyFieldInfo,self).__init__(pf, field_list, slice_info)
 
 


https://bitbucket.org/yt_analysis/yt/commits/ca4e20b9b0db/
Changeset:   ca4e20b9b0db
Branch:      yt-3.0
User:        BW Keller
Date:        2014-03-25 05:17:16
Summary:     Doubled validate_header method somehow.  oops.
Affected #:  1 file

diff -r eb210e28a4e91437aa6cb4161f58be5adb6d3912 -r ca4e20b9b0dbf496a2891025096067e253604dab yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -540,32 +540,6 @@
         f.close()
         return True, endianswap
 
-    @staticmethod
-    def _validate_header(filename):
-        try:
-            f = open(filename,'rb')
-        except:
-            return False, 1
-        fs = len(f.read())
-        f.seek(0)
-        #Read in the header
-        t, n, ndim, ng, nd, ns = struct.unpack("<diiiii", f.read(28))
-        endianswap = "<"
-        #Check Endianness
-        if (ndim < 1 or ndim > 3):
-            endianswap = ">"
-            f.seek(0)
-            t, n, ndim, ng, nd, ns = struct.unpack(">diiiii", f.read(28))
-        #Catch for 4 byte padding
-        if (fs == 32+48*ng+36*nd+44*ns):
-            f.read(4)
-        #File is borked if this is true
-        elif (fs != 28+48*ng+36*nd+44*ns):
-            f.close()
-            return False, 0
-        f.close()
-        return True, endianswap
-
     @classmethod
     def _is_valid(self, *args, **kwargs):
         return TipsyDataset._validate_header(args[0])[0]


https://bitbucket.org/yt_analysis/yt/commits/bc7abe74aa1e/
Changeset:   bc7abe74aa1e
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-03-25 05:22:13
Summary:     Merged in bwkeller/yt/yt-3.0 (pull request #757)

Added autodetection of valid tipsy files
Affected #:  3 files

diff -r 4b00820c086bb1d5329e2f9ec3b8287c0127063e -r bc7abe74aa1e1bc01d6cbf0697733fd70ffe9cdd doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -372,25 +372,6 @@
 particle type specifications.  *These are all excellent projects for new
 contributors!*
 
-Tipsy data cannot be automatically detected.  You can load it with a command
-similar to the following:
-
-.. code-block:: python
-
-    ds = TipsyDataset('test.00169',
-        parameter_file='test.param',
-        endian = '<',
-        domain_left_edge = domain_left_edge,
-        domain_right_edge = domain_right_edge,
-    )
-
-Not all of these arguments are necessary; additionally, yt accepts the
-arguments ``n_ref``, ``over_refine_factor``, ``cosmology_parameters``, and
-``unit_base``.  By default, yt will not utilize a parameter file, and by
-default it will assume the data is "big" endian (`>`).  Optionally, you may
-specify ``field_dtypes``, which describe the size of various fields.  For
-example, if you have stored positions as 64-bit floats, you can specify this
-with:
 
 .. code-block:: python
 

diff -r 4b00820c086bb1d5329e2f9ec3b8287c0127063e -r bc7abe74aa1e1bc01d6cbf0697733fd70ffe9cdd yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -38,7 +38,7 @@
     mass_sun_cgs
 from yt.utilities.cosmology import Cosmology
 from .fields import \
-    SPHFieldInfo, OWLSFieldInfo
+    SPHFieldInfo, OWLSFieldInfo, TipsyFieldInfo
 from .definitions import \
     gadget_header_specs, \
     gadget_field_specs, \
@@ -356,7 +356,7 @@
 class TipsyDataset(ParticleDataset):
     _index_class = ParticleIndex
     _file_class = TipsyFile
-    _field_info_class = SPHFieldInfo
+    _field_info_class = TipsyFieldInfo
     _particle_mass_name = "Mass"
     _particle_coordinates_name = "Coordinates"
     _header_spec = (('time',    'd'),
@@ -368,7 +368,6 @@
                     ('dummy',   'i'))
 
     def __init__(self, filename, dataset_type="tipsy",
-                 endian=">",
                  field_dtypes=None,
                  domain_left_edge=None,
                  domain_right_edge=None,
@@ -378,7 +377,7 @@
                  n_ref=64, over_refine_factor=1):
         self.n_ref = n_ref
         self.over_refine_factor = over_refine_factor
-        self.endian = endian
+        self.endian = self._validate_header(filename)[1]
         self.storage_filename = None
         if domain_left_edge is None:
             domain_left_edge = np.zeros(3, "float64") - 0.5
@@ -515,10 +514,35 @@
             density_unit = self.mass_unit / self.length_unit**3
         self.time_unit = 1.0 / np.sqrt(G * density_unit)
 
+    @staticmethod
+    def _validate_header(filename):
+        try:
+            f = open(filename,'rb')
+        except:
+            return False, 1
+        fs = len(f.read())
+        f.seek(0)
+        #Read in the header
+        t, n, ndim, ng, nd, ns = struct.unpack("<diiiii", f.read(28))
+        endianswap = "<"
+        #Check Endianness
+        if (ndim < 1 or ndim > 3):
+            endianswap = ">"
+            f.seek(0)
+            t, n, ndim, ng, nd, ns = struct.unpack(">diiiii", f.read(28))
+        #Catch for 4 byte padding
+        if (fs == 32+48*ng+36*nd+44*ns):
+            f.read(4)
+        #File is borked if this is true
+        elif (fs != 28+48*ng+36*nd+44*ns):
+            f.close()
+            return False, 0
+        f.close()
+        return True, endianswap
+
     @classmethod
     def _is_valid(self, *args, **kwargs):
-        # We do not allow load() of these files.
-        return False
+        return TipsyDataset._validate_header(args[0])[0]
 
 class HTTPParticleFile(ParticleFile):
     pass

diff -r 4b00820c086bb1d5329e2f9ec3b8287c0127063e -r bc7abe74aa1e1bc01d6cbf0697733fd70ffe9cdd yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -57,6 +57,36 @@
 
 
 
+class TipsyFieldInfo(SPHFieldInfo):
+
+    def __init__(self, pf, field_list, slice_info = None):
+        aux_particle_fields = {
+                'uDotFB':("uDotFB", ("code_mass * code_velocity**2", ["uDotFB"], None)),
+                'uDotAV':("uDotAV", ("code_mass * code_velocity**2", ["uDotAV"], None)),
+                'uDotPdV':("uDotPdV", ("code_mass * code_velocity**2", ["uDotPdV"], None)),
+                'uDotHydro':("uDotHydro", ("code_mass * code_velocity**2", ["uDotHydro"], None)),
+                'uDotDiff':("uDotDiff", ("code_mass * code_velocity**2", ["uDotDiff"], None)),
+                'uDot':("uDot", ("code_mass * code_velocity**2", ["uDot"], None)),
+                'coolontime':("coolontime", ("code_time", ["coolontime"], None)),
+                'timeform':("timeform", ("code_time", ["timeform"], None)),
+                'massform':("massform", ("code_mass", ["massform"], None)),
+                'HI':("HI", ("dimensionless", ["HI"], None)),
+                'HII':("HII", ("dimensionless", ["HII"], None)),
+                'HeI':("HeI", ("dimensionless", ["HeI"], None)),
+                'HeII':("HeII", ("dimensionless", ["HeII"], None)),
+                'OxMassFrac':("OxMassFrac", ("dimensionless", ["OxMassFrac"], None)),
+                'FeMassFrac':("FeMassFrac", ("dimensionless", ["FeMassFrac"], None)),
+                'c':("c", ("code_velocity", ["c"], None)),
+                'acc':("acc", ("code_velocity / code_time", ["acc"], None)),
+                'accg':("accg", ("code_velocity / code_time", ["accg"], None))}
+        for field in field_list:
+            if field[1] in aux_particle_fields.keys() and \
+                aux_particle_fields[field[1]] not in self.known_particle_fields:
+                self.known_particle_fields += (aux_particle_fields[field[1]],)
+        super(TipsyFieldInfo,self).__init__(pf, field_list, slice_info)
+
+
+        
 
 class OWLSFieldInfo(SPHFieldInfo):

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