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

Bitbucket commits-noreply at bitbucket.org
Fri Feb 1 09:13:55 PST 2013


22 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/41358eecdad5/
changeset:   41358eecdad5
branch:      yt
user:        ngoldbaum
date:        2013-01-25 03:43:09
summary:     Adding ensure_tuple to funcs.  I think we've got all the interables now ;)
affected #:  1 file

diff -r 4be99c4ab148aa14cfcf9e0c0728cf6741284578 -r 41358eecdad53781948420c6d78bf23abfe8e41c yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -74,6 +74,19 @@
     else:
         return np.asarray([obj])
 
+def ensure_tuple(obj):
+    """
+    This function ensures that *obj* is a tuple.  Typically used to convert
+    scalar, list, or array arguments specified by a user in a context where
+    we assume a tuple internally
+    """
+    if isintance(obj, types.TupleType):
+        return obj
+    elif isinstance(obj, (types.ListType, np.ndarray)):
+        return tuple(obj)
+    else:
+        return (obj,)
+
 def read_struct(f, fmt):
     """
     This reads a struct, and only that struct, from an open file.


https://bitbucket.org/yt_analysis/yt/commits/b8be04593643/
changeset:   b8be04593643
branch:      yt
user:        ngoldbaum
date:        2013-01-25 03:43:26
summary:     Adding a periodicity attribute for the frontends I can figure it out for.
affected #:  9 files

diff -r 41358eecdad53781948420c6d78bf23abfe8e41c -r b8be04593643e5d32971566159a6b5940dae2ed5 yt/frontends/_skeleton/data_structures.py
--- a/yt/frontends/_skeleton/data_structures.py
+++ b/yt/frontends/_skeleton/data_structures.py
@@ -137,6 +137,7 @@
         #   self.domain_right_edge      <= array of float64
         #   self.dimensionality         <= int
         #   self.domain_dimensions      <= array of int64
+        #   self.periodicity            <= three-element tuple of booleans
         #   self.current_time           <= simulation time in code units
         #
         # We also set up cosmological information.  Set these to zero if

diff -r 41358eecdad53781948420c6d78bf23abfe8e41c -r b8be04593643e5d32971566159a6b5940dae2ed5 yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -610,6 +610,7 @@
         """
         self.dimensionality = 3
         self.refine_by = 2
+        self.periodicity = (True, True, True)
         self.cosmological_simulation = True
         self.parameters = {}
         self.unique_identifier = \

diff -r 41358eecdad53781948420c6d78bf23abfe8e41c -r b8be04593643e5d32971566159a6b5940dae2ed5 yt/frontends/athena/data_structures.py
--- a/yt/frontends/athena/data_structures.py
+++ b/yt/frontends/athena/data_structures.py
@@ -402,6 +402,10 @@
         self.num_ghost_zones = 0
         self.field_ordering = 'fortran'
         self.boundary_conditions = [1]*6
+        if 'periodicity' in self.specified_parameters:
+            self.periodicity = ensure_tuple(self.specified_parameters['periodicity'])
+        else:
+            self.periodicity = (True,)*self.dimensionality
 
         dname = self.parameter_filename
         gridlistread = glob.glob('id*/%s-id*%s' % (dname[4:-9],dname[-9:] ))

diff -r 41358eecdad53781948420c6d78bf23abfe8e41c -r b8be04593643e5d32971566159a6b5940dae2ed5 yt/frontends/castro/data_structures.py
--- a/yt/frontends/castro/data_structures.py
+++ b/yt/frontends/castro/data_structures.py
@@ -621,6 +621,7 @@
 
         self.parameters["TopGridRank"] = len(self.parameters["TopGridDimensions"])
         self.dimensionality = self.parameters["TopGridRank"]
+        self.periodicity = ensure_tuple(self.fparameters['castro.lo_bc'] == 0)
         self.domain_dimensions = self.parameters["TopGridDimensions"]
         self.refine_by = self.parameters.get("RefineBy", 2)
 

diff -r 41358eecdad53781948420c6d78bf23abfe8e41c -r b8be04593643e5d32971566159a6b5940dae2ed5 yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -819,6 +819,7 @@
         for k, v in data_label_factors.items():
             self.conversion_factors[data_labels[k]] = v
         self.refine_by = self.parameters["RefineBy"]
+        self.periodicity = tuple(self.parameters["LeftFaceBoundaryCondition"] == 3)
         self.dimensionality = self.parameters["TopGridRank"]
         if self.dimensionality > 1:
             self.domain_dimensions = self.parameters["TopGridDimensions"]
@@ -826,6 +827,7 @@
                 tmp = self.domain_dimensions.tolist()
                 tmp.append(1)
                 self.domain_dimensions = np.array(tmp)
+                self.periodicity += (False,)
             self.domain_left_edge = np.array(self.parameters["DomainLeftEdge"],
                                              "float64").copy()
             self.domain_right_edge = np.array(self.parameters["DomainRightEdge"],
@@ -836,6 +838,7 @@
             self.domain_right_edge = np.array(self.parameters["DomainRightEdge"],
                                              "float64")
             self.domain_dimensions = np.array([self.parameters["TopGridDimensions"],1,1])
+            self.periodicity += (False, False)
 
         self.current_time = self.parameters["InitialTime"]
         # To be enabled when we can break old pickles:

diff -r 41358eecdad53781948420c6d78bf23abfe8e41c -r b8be04593643e5d32971566159a6b5940dae2ed5 yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -450,6 +450,13 @@
         # Get the simulation time
         self.current_time = self.parameters["time"]
 
+        # Determine if this is a periodic box
+        self.periodicity = (self.parameters["xl_boundary_type"] == "periodic",)
+        if self.dimensionality > 1:
+            self.periodicity += (self.parameters["yl_boundary_type"] == "periodic",)
+        if self.dimensionality > 2:
+            self.periodicity += (self.parameters["zl_boundary_type"] == "periodic",)
+
         # Determine cosmological parameters.
         try: 
             self.parameters["usecosmology"]

diff -r 41358eecdad53781948420c6d78bf23abfe8e41c -r b8be04593643e5d32971566159a6b5940dae2ed5 yt/frontends/nyx/data_structures.py
--- a/yt/frontends/nyx/data_structures.py
+++ b/yt/frontends/nyx/data_structures.py
@@ -605,6 +605,8 @@
                 self.domain_left_edge = np.array([float(i) for i in vals])
             elif param.startswith("particles.write_in_plotfile"):
                 self.use_particles = boxlib_bool_to_int(vals[0])
+            elif param.startswith("nyx.lo_bc"):
+                self.periodicity = tuple([i == 0 for i in vals])
 
         # aliases we need
         self.parameters["TopGridRank"] = len(self.parameters["TopGridDimensions"])

diff -r 41358eecdad53781948420c6d78bf23abfe8e41c -r b8be04593643e5d32971566159a6b5940dae2ed5 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -354,6 +354,7 @@
         # distinguish them.
         mylog.warning("No current mechanism of distinguishing cosmological simulations in RAMSES!")
         self.cosmological_simulation = 1
+        self.periodicity = (True, True, True)
         self.current_redshift = (1.0 / rheader["aexp"]) - 1.0
         self.omega_lambda = rheader["omega_l"]
         self.omega_matter = rheader["omega_m"]

diff -r 41358eecdad53781948420c6d78bf23abfe8e41c -r b8be04593643e5d32971566159a6b5940dae2ed5 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -105,7 +105,8 @@
 class StreamHandler(object):
     def __init__(self, left_edges, right_edges, dimensions,
                  levels, parent_ids, particle_count, processor_ids,
-                 fields, io = None, particle_types = None):
+                 fields, io = None, particle_types = None, 
+                 periodicity = (True, True, True)):
         if particle_types is None: particle_types = {}
         self.left_edges = left_edges
         self.right_edges = right_edges
@@ -118,6 +119,7 @@
         self.fields = fields
         self.io = io
         self.particle_types = particle_types
+        self.periodicity = periodicity
             
     def get_fields(self):
         return self.fields.all_fields
@@ -313,6 +315,7 @@
         self.domain_right_edge = self.stream_handler.domain_right_edge[:]
         self.refine_by = self.stream_handler.refine_by
         self.dimensionality = self.stream_handler.dimensionality
+        self.periodicity = self.stream_handler.periodicity
         self.domain_dimensions = self.stream_handler.domain_dimensions
         self.current_time = self.stream_handler.simulation_time
         if self.stream_handler.cosmology_simulation:
@@ -398,7 +401,7 @@
     pf.h.update_data(grid_pdata)
                                         
 def load_uniform_grid(data, domain_dimensions, sim_unit_to_cm, bbox=None,
-                      nprocs=1, sim_time=0.0):
+                      nprocs=1, sim_time=0.0, periodicity=(True, True, True):
     r"""Load a uniform grid of data into yt as a
     :class:`~yt.frontends.stream.data_structures.StreamHandler`.
 
@@ -427,6 +430,9 @@
         If greater than 1, will create this number of subarrays out of data
     sim_time : float, optional
         The simulation time in seconds
+    periodicity : tuple of booleans
+        Determines whether the data will be treated as periodic along
+        each axis
 
     Examples
     --------
@@ -493,6 +499,7 @@
         np.zeros(nprocs).reshape((nprocs,1)),
         sfh,
         particle_types=particle_types
+        periodicity
     )
 
     handler.name = "UniformGridData"


https://bitbucket.org/yt_analysis/yt/commits/ef817a5b72ef/
changeset:   ef817a5b72ef
branch:      yt
user:        ngoldbaum
date:        2013-01-26 08:31:40
summary:     Adding ValidatePeriodic.
affected #:  2 files

diff -r b8be04593643e5d32971566159a6b5940dae2ed5 -r ef817a5b72ef32640b5394afa7b47aad4e38865f yt/data_objects/field_info_container.py
--- a/yt/data_objects/field_info_container.py
+++ b/yt/data_objects/field_info_container.py
@@ -33,6 +33,7 @@
 import numpy as np
 
 from yt.funcs import *
+from yt.utilities.definitions import axis_names
 
 class FieldInfoContainer(dict): # Resistance has utility
     """
@@ -199,6 +200,12 @@
     def __str__(self):
         return "(%s)" % (self.missing_parameters)
 
+class IsNotPeriodic(ValidationException):
+    def __init__(self, direction):
+        self.direction = direction
+    def __str__(self):
+        return str(self.direction)
+
 class FieldDetector(defaultdict):
     Level = 1
     NumberOfParticles = 1
@@ -490,3 +497,19 @@
         if isinstance(data, FieldDetector): return True
         if getattr(data, "_type_name", None) == 'grid': return True
         raise NeedsOriginalGrid()
+
+class ValidatePeriodic(FieldValidator):
+    def __init__(self):
+        """
+        This validator ensures that the parameter file's periodicity attribute
+        is True along all three directions
+        """
+        FieldValidator.__init__(self)
+    def __call__(self, data):
+        np = []
+        for i, p in enumerate(data.pf.periodicity):
+            if p == False:
+                np.append(i)
+        if len(np) > 0:
+            raise IsNotPeriodic([axis_names[i] for i in np])
+        return True

diff -r b8be04593643e5d32971566159a6b5940dae2ed5 -r ef817a5b72ef32640b5394afa7b47aad4e38865f yt/data_objects/universal_fields.py
--- a/yt/data_objects/universal_fields.py
+++ b/yt/data_objects/universal_fields.py
@@ -40,6 +40,7 @@
     ValidateGridType, \
     ValidateParameter, \
     ValidateSpatial, \
+    ValidatePeriodic, \
     NeedsGridType, \
     NeedsOriginalGrid, \
     NeedsDataField, \
@@ -805,6 +806,14 @@
 def _ConvertRadiusCGS(data):
     return data.convert("cm")
 add_field("ParticleRadius", function=_ParticleRadius,
+          validators=[ValidateParameter("center"), ValidatePeriodic()],
+          convert_function = _ConvertRadiusCGS, units=r"\rm{cm}",
+          particle_type = True,
+          display_name = "Particle Radius")
+add_field("Radius", function=_Radius,
+          validators=[ValidateParameter("center"), ValidatePeriodic()],
+          convert_function = _ConvertRadiusCGS, units=r"\rm{cm}")
+add_field("ParticleRadiusIsolated", function=_ParticleRadiusIsolated,
           validators=[ValidateParameter("center")],
           convert_function = _ConvertRadiusCGS, units=r"\rm{cm}",
           particle_type = True,
@@ -816,11 +825,13 @@
 def _ConvertRadiusMpc(data):
     return data.convert("mpc")
 add_field("RadiusMpc", function=_Radius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiusMpc, units=r"\rm{Mpc}",
           display_name = "Radius")
 add_field("ParticleRadiusMpc", function=_ParticleRadius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiusMpc, units=r"\rm{Mpc}",
           particle_type=True,
           display_name = "Particle Radius")
@@ -828,57 +839,67 @@
 def _ConvertRadiuskpc(data):
     return data.convert("kpc")
 add_field("ParticleRadiuskpc", function=_ParticleRadius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiuskpc, units=r"\rm{kpc}",
           particle_type=True,
           display_name = "Particle Radius")
 add_field("Radiuskpc", function=_Radius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiuskpc, units=r"\rm{kpc}",
           display_name = "Radius")
 
 def _ConvertRadiuskpch(data):
     return data.convert("kpch")
 add_field("ParticleRadiuskpch", function=_ParticleRadius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiuskpch, units=r"\rm{kpc}/\rm{h}",
           particle_type=True,
           display_name = "Particle Radius")
 add_field("Radiuskpch", function=_Radius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiuskpc, units=r"\rm{kpc}/\rm{h}",
           display_name = "Radius")
 
 def _ConvertRadiuspc(data):
     return data.convert("pc")
 add_field("ParticleRadiuspc", function=_ParticleRadius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiuspc, units=r"\rm{pc}",
           particle_type=True,
           display_name = "Particle Radius")
 add_field("Radiuspc", function=_Radius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiuspc, units=r"\rm{pc}",
           display_name="Radius")
 
 def _ConvertRadiusAU(data):
     return data.convert("au")
 add_field("ParticleRadiusAU", function=_ParticleRadius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiusAU, units=r"\rm{AU}",
           particle_type=True,
           display_name = "Particle Radius")
 add_field("RadiusAU", function=_Radius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           convert_function = _ConvertRadiusAU, units=r"\rm{AU}",
           display_name = "Radius")
 
 add_field("ParticleRadiusCode", function=_ParticleRadius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           particle_type=True,
           display_name = "Particle Radius (code)")
 add_field("RadiusCode", function=_Radius,
-          validators=[ValidateParameter("center")],
+          validators=[ValidateParameter("center"),
+                      ValidatePeriodic()],
           display_name = "Radius (code)")
 
 def _RadialVelocity(field, data):


https://bitbucket.org/yt_analysis/yt/commits/b52ed4e38be8/
changeset:   b52ed4e38be8
branch:      yt
user:        ngoldbaum
date:        2013-01-26 08:34:52
summary:     Adding a new non periodic radius field.
This reassigns the _function of a DerivedField object, allowing
the Radius field to use _RadiusIsolated instead of _Radius.
affected #:  5 files

diff -r ef817a5b72ef32640b5394afa7b47aad4e38865f -r b52ed4e38be8dea6b46b7f881693d7df0e31ed1f yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -42,6 +42,7 @@
 
 from yt.data_objects.derived_quantities import GridChildMaskWrapper
 from yt.data_objects.particle_io import particle_handler_registry
+from yt.data_objects import universal_fields
 from yt.utilities.lib import find_grids_in_inclined_box, \
     grid_points_in_volume, planar_points_in_volume, VoxelTraversal, \
     QuadTree, get_box_grids_below_level, ghost_zone_interpolate, \
@@ -68,7 +69,9 @@
     NeedsOriginalGrid, \
     NeedsDataField, \
     NeedsProperty, \
-    NeedsParameter
+    NeedsParameter, \
+    IsNotPeriodic, \
+    ValidatePeriodic
 
 def force_array(item, shape):
     try:
@@ -356,6 +359,16 @@
                 # We leave this to be implementation-specific
                 self._generate_field_in_grids(field, ngt_exception.ghost_zones)
                 return False
+            except IsNotPeriodic:
+                name = self.pf.field_info[field]._function.__name__
+                if name.endswith('Isolated') == False:
+                    setattr(self.pf.field_info[field], '_function',
+                            getattr(universal_fields,name+'Isolated'))
+                validators = self.pf.field_info[field].validators
+                validators = [v for v in validators if type(v) != ValidatePeriodic]
+                self.pf.field_info[field].validators = validators
+                self[field] = self.pf.field_info[field](self)
+                return True
             else:
                 self[field] = self.pf.field_info[field](self)
                 return True
@@ -3809,8 +3822,19 @@
     def _generate_field(self, field):
         if self.pf.field_info.has_key(field):
             # First we check the validator; this might even raise!
-            self.pf.field_info[field].check_available(self)
-            self[field] = self.pf.field_info[field](self)
+            try:
+                self.pf.field_info[field].check_available(self)
+            except IsNotPeriodic:
+                name = self.pf.field_info[field]._function.__name__
+                if name.endswith('Isolated') == False:
+                    setattr(self.pf.field_info[field], '_function',
+                            getattr(universal_fields,name+'Isolated'))
+                validators = self.pf.field_info[field].validators
+                validators = [v for v in validators if type(v) != ValidatePeriodic]
+                self.pf.field_info[field].validators = validators
+                self[field] = self.pf.field_info[field](self)
+            else:
+                self[field] = self.pf.field_info[field](self)
         else: # Can't find the field, try as it might
             raise KeyError(field)
 

diff -r ef817a5b72ef32640b5394afa7b47aad4e38865f -r b52ed4e38be8dea6b46b7f881693d7df0e31ed1f yt/data_objects/grid_patch.py
--- a/yt/data_objects/grid_patch.py
+++ b/yt/data_objects/grid_patch.py
@@ -33,13 +33,16 @@
 from yt.utilities.definitions import x_dict, y_dict
 
 from yt.data_objects.data_containers import YTFieldData
+from yt.data_objects import universal_fields
 from yt.utilities.definitions import x_dict, y_dict
 from .field_info_container import \
     NeedsGridType, \
     NeedsOriginalGrid, \
     NeedsDataField, \
     NeedsProperty, \
-    NeedsParameter
+    NeedsParameter, \
+    IsNotPeriodic, \
+    ValidatePeriodic
 
 class AMRGridPatch(object):
     _spatial = True
@@ -141,6 +144,15 @@
                 temp_array = self.pf.field_info[field](gz_grid)
                 sl = [slice(n_gz, -n_gz)] * 3
                 self[field] = temp_array[sl]
+            except IsNotPeriodic:
+                name = self.pf.field_info[field]._function.__name__
+                if name.endswith('Isolated') == False:
+                    setattr(self.pf.field_info[field], '_function',
+                            getattr(universal_fields,name+'Isolated'))
+                validators = self.pf.field_info[field].validators
+                validators = [v for v in validators if type(v) != ValidatePeriodic]
+                self.pf.field_info[field].validators = validators
+                self[field] = self.pf.field_info[field](self)
             else:
                 self[field] = self.pf.field_info[field](self)
         else: # Can't find the field, try as it might

diff -r ef817a5b72ef32640b5394afa7b47aad4e38865f -r b52ed4e38be8dea6b46b7f881693d7df0e31ed1f yt/data_objects/universal_fields.py
--- a/yt/data_objects/universal_fields.py
+++ b/yt/data_objects/universal_fields.py
@@ -786,23 +786,27 @@
 
 
 def _ParticleRadius(field, data):
-    center = data.get_field_parameter("center")
-    DW = data.pf.domain_right_edge - data.pf.domain_left_edge
-    radius = np.zeros(data["particle_position_x"].shape, dtype='float64')
-    for i, ax in enumerate('xyz'):
-        r = np.abs(data["particle_position_%s" % ax] - center[i])
-        radius += np.minimum(r, np.abs(DW[i]-r))**2.0
-    np.sqrt(radius, radius)
-    return radius
+    positions = np.array([data["particle_position_%s" % ax] for ax in 'xyz'])
+    c = data.get_field_parameter("center")
+    center = np.tile(c,(positions.shape[1],1)).transpose()
+    period = data.pf.domain_right_edge - data.pf.domain_left_edge
+    return periodic_dist(positions, center, period)
 def _Radius(field, data):
-    center = data.get_field_parameter("center")
-    DW = data.pf.domain_right_edge - data.pf.domain_left_edge
-    radius = np.zeros(data["x"].shape, dtype='float64')
-    for i, ax in enumerate('xyz'):
-        r = np.abs(data[ax] - center[i])
-        radius += np.minimum(r, np.abs(DW[i]-r))**2.0
-    np.sqrt(radius, radius)
-    return radius
+    positions = np.array([data['x'], data['y'], data['z']])
+    c = data.get_field_parameter("center")
+    center = np.tile(c,(positions.shape[1],1)).transpose()
+    period = data.pf.domain_right_edge - data.pf.domain_left_edge
+    return periodic_dist(positions, center, period)
+def _ParticleRadiusIsolated(field, data):
+    positions = np.array([data["particle_position_%s" % ax] for ax in 'xyz'])
+    c = data.get_field_parameter("center")
+    center = np.tile(c,(positions.shape[1],1)).transpose()
+    return euclidean_dist(positions, center)
+def _RadiusIsolated(field, data):
+    positions = np.array([data['x'], data['y'], data['z']])
+    c = data.get_field_parameter("center")
+    center = np.tile(c,(positions.shape[1],1)).transpose()
+    return euclidian_dist(positions, center)
 def _ConvertRadiusCGS(data):
     return data.convert("cm")
 add_field("ParticleRadius", function=_ParticleRadius,
@@ -818,7 +822,7 @@
           convert_function = _ConvertRadiusCGS, units=r"\rm{cm}",
           particle_type = True,
           display_name = "Particle Radius")
-add_field("Radius", function=_Radius,
+add_field("RadiusIsolated", function=_RadiusIsolated,
           validators=[ValidateParameter("center")],
           convert_function = _ConvertRadiusCGS, units=r"\rm{cm}")
 

diff -r ef817a5b72ef32640b5394afa7b47aad4e38865f -r b52ed4e38be8dea6b46b7f881693d7df0e31ed1f yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -401,7 +401,7 @@
     pf.h.update_data(grid_pdata)
                                         
 def load_uniform_grid(data, domain_dimensions, sim_unit_to_cm, bbox=None,
-                      nprocs=1, sim_time=0.0, periodicity=(True, True, True):
+                      nprocs=1, sim_time=0.0, periodicity=(True, True, True)):
     r"""Load a uniform grid of data into yt as a
     :class:`~yt.frontends.stream.data_structures.StreamHandler`.
 
@@ -498,8 +498,8 @@
         np.zeros(nprocs, dtype='int64').reshape(nprocs,1), # Temporary
         np.zeros(nprocs).reshape((nprocs,1)),
         sfh,
-        particle_types=particle_types
-        periodicity
+        particle_types=particle_types,
+        periodicity=periodicity
     )
 
     handler.name = "UniformGridData"

diff -r ef817a5b72ef32640b5394afa7b47aad4e38865f -r b52ed4e38be8dea6b46b7f881693d7df0e31ed1f yt/utilities/math_utils.py
--- a/yt/utilities/math_utils.py
+++ b/yt/utilities/math_utils.py
@@ -32,12 +32,12 @@
 
 def periodic_position(pos, pf):
     r"""Assuming periodicity, find the periodic position within the domain.
-    
+
     Parameters
     ----------
     pos : array
         An array of floats.
-    
+
     pf : StaticOutput
         A simulation static output.
     
@@ -55,15 +55,15 @@
     return pf.domain_left_edge + off
 
 def periodic_dist(a, b, period):
-    r"""Find the Euclidian periodic distance between two points.
+    r"""Find the Euclidean periodic distance between two sets of points.
     
     Parameters
     ----------
     a : array or list
-        An array or list of floats.
+        An (ndim, npoints) list of coordinates
     
     b : array of list
-        An array or list of floats.
+        An (ndim, npoints) list of coordinates
     
     period : float or array or list
         If the volume is symmetrically periodic, this can be a single float,
@@ -77,16 +77,47 @@
     >>> period = 1.
     >>> dist = periodic_dist(a, b, 1.)
     >>> dist
-    0.3464102
+    0.346410161514
     """
     a = np.array(a)
     b = np.array(b)
-    if a.size != b.size: RunTimeError("Arrays must be the same shape.")
-    c = np.empty((2, a.size), dtype="float64")
+    period = np.array(period)
+    if a.shape != b.shape: RuntimeError("Arrays must be the same shape.")
+    if period.shape != b.shape and len(b.shape) > 1:
+        period = np.tile(period, (b.shape[1],1)).transpose()
+    c = np.empty((2,) + a.shape, dtype="float64")
     c[0,:] = abs(a - b)
     c[1,:] = period - abs(a - b)
     d = np.amin(c, axis=0)**2
-    return math.sqrt(d.sum())
+    return np.sqrt(d.sum(axis=0))
+
+def euclidean_dist(a, b):
+    r"""Find the Euclidean distance between two points.
+
+    Parameters
+    ----------
+    a : array or list
+        An (ndim, npoints) list of coordinates
+
+    b : array of list
+        An (ndim, npoints) list of coordinates
+
+    Examples
+    --------
+    >>> a = np.array([0.1, 0.1, 0.1])
+    >>> b = np.array([0.9, 0,9, 0.9])
+    >>> period = 1.
+    >>> dist = euclidean_dist(a, b, period)
+    >>> dist
+    1.38564064606
+
+    """
+    a = np.array(a)
+    b = np.array(b)
+    if a.shape != b.shape: RuntimeError("Arrays must be the same shape.")
+    c = np.empty(a.shape, dtype="float64")
+    c = (a - b)**2
+    return np.sqrt(c.sum(axis=0))
 
 def rotate_vector_3D(a, dim, angle):
     r"""Rotates the elements of an array around an axis by some angle.


https://bitbucket.org/yt_analysis/yt/commits/b053ea68e96f/
changeset:   b053ea68e96f
branch:      yt
user:        ngoldbaum
date:        2013-01-26 08:36:39
summary:     Merged yt_analysis/yt into yt
affected #:  6 files
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/e2239c32d9b9/
changeset:   e2239c32d9b9
branch:      yt
user:        ngoldbaum
date:        2013-01-28 20:34:05
summary:     Rethinking the way we handle periodic fields.  No more validators and juggling
the _function attribute.  It works but it's complicated and doesn't make things
very clear.  Worse, to handle the corner case where a simulation is periodic
along only one or two directions, we have to either define six new fields
that handle each possible case or insert the logic into the periodic radius
field anyway, obviating the need for the validator and field metaprogramming.

This puts the logic inside the field definition.  I've also refactored the fields
so I think the semantic cost isn't very high.
affected #:  4 files
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/42d76617493c/
changeset:   42d76617493c
branch:      yt
user:        ngoldbaum
date:        2013-01-28 21:09:52
summary:     Removing ValidatePeriodic and IsNotPeriodic, they are not needed.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/2c97a98e636e/
changeset:   2c97a98e636e
branch:      yt
user:        ngoldbaum
date:        2013-01-28 21:10:09
summary:     Forgot to import periodic_dist and euclidean_dist.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/9bdf040a13a8/
changeset:   9bdf040a13a8
branch:      yt
user:        ngoldbaum
date:        2013-01-28 22:08:44
summary:     Fixing some issues that caused periodic_dist and Radius to break in some situations.
affected #:  2 files
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/c3685ea1c8e7/
changeset:   c3685ea1c8e7
branch:      yt
user:        ngoldbaum
date:        2013-01-28 22:55:05
summary:     Fixing some remaining jankiness in periodic_dist
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/d1fb8648ec3c/
changeset:   d1fb8648ec3c
branch:      yt
user:        ngoldbaum
date:        2013-01-28 22:55:18
summary:     Adding tests for the new periodicity functionality.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/0469784183b9/
changeset:   0469784183b9
branch:      yt
user:        ngoldbaum
date:        2013-01-29 08:31:23
summary:     Adding a periodicity attribute for the gdf frontend.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/f0e4de525d1f/
changeset:   f0e4de525d1f
branch:      yt
user:        ngoldbaum
date:        2013-01-29 08:32:29
summary:     Correcting a couple of typos.
affected #:  2 files
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/fd4422242964/
changeset:   fd4422242964
branch:      yt
user:        ngoldbaum
date:        2013-01-29 08:54:49
summary:     Fixing another typo.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/1b3974db20e2/
changeset:   1b3974db20e2
branch:      yt
user:        ngoldbaum
date:        2013-01-29 08:56:31
summary:     fake_parameter_file needs a periodicity attribute.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/4be7647a0347/
changeset:   4be7647a0347
branch:      yt
user:        ngoldbaum
date:        2013-01-29 20:52:02
summary:     Updating following Matt's comments.
affected #:  3 files
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/f9d7d69eb8c1/
changeset:   f9d7d69eb8c1
branch:      yt
user:        ngoldbaum
date:        2013-01-30 01:12:22
summary:     Need to use ensure_list otherwise 1D sims will barf.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/9990c4b19f61/
changeset:   9990c4b19f61
branch:      yt
user:        ngoldbaum
date:        2013-01-30 01:12:43
summary:     Merged yt_analysis/yt into yt
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/bb66dfc3b474/
changeset:   bb66dfc3b474
branch:      yt
user:        ngoldbaum
date:        2013-01-30 19:56:13
summary:     Setting periodicity in the orion frontend.
Minor stylistic modifications to the nyx and enzo frontends.
affected #:  3 files
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/37545795bc08/
changeset:   37545795bc08
branch:      yt
user:        ngoldbaum
date:        2013-01-30 19:56:41
summary:     Merging to tip.
affected #:  1 file
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/3617719a777f/
changeset:   3617719a777f
branch:      yt
user:        ngoldbaum
date:        2013-01-30 19:57:28
summary:     Merging.
affected #:  0 files
Diff not available.

https://bitbucket.org/yt_analysis/yt/commits/d7b721d8320d/
changeset:   d7b721d8320d
branch:      yt
user:        MatthewTurk
date:        2013-02-01 18:13:47
summary:     Merged in ngoldbaum/yt (pull request #410)

First pass at YTEP-6.  Closes #484.
affected #:  18 files
Diff not available.

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