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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sun Aug 10 00:55:22 PDT 2014


14 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/d7af05c55681/
Changeset:   d7af05c55681
Branch:      yt-3.0
User:        jzuhone
Date:        2014-07-28 23:44:12
Summary:     Change the origin of the image with "center"
Affected #:  1 file

diff -r 9bcd9fb6fe3a08a393a6d5754528f84084be0342 -r d7af05c55681188113ca791a8c42666246ceded6 yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -252,7 +252,7 @@
 
 axis_wcs = [[1,2],[0,2],[0,1]]
 
-def construct_image(data_source):
+def construct_image(data_source, center=None):
     ds = data_source.ds
     axis = data_source.axis
     if hasattr(ds, "wcs"):
@@ -264,13 +264,16 @@
         cunit = [str(ds.wcs.wcs.cunit[idx]) for idx in axis_wcs[axis]]
         ctype = [ds.wcs.wcs.ctype[idx] for idx in axis_wcs[axis]]
     else:
+        if center is None:
+            crval = [0.0,0.0]
+        else:
+            crval = [(ds.domain_center-center)[idx].in_units(unit) for idx in axis_wcs[axis]]
         # This is some other kind of dataset
         unit = ds.get_smallest_appropriate_unit(ds.domain_width.max())
         dx = ds.index.get_smallest_dx()
         nx, ny = (ds.domain_width[axis_wcs[axis]]/dx).ndarray_view().astype("int")
         crpix = [0.5*(nx+1), 0.5*(ny+1)]
         cdelt = [dx.in_units(unit)]*2
-        crval = [ds.domain_center[idx].in_units(unit) for idx in axis_wcs[axis]]
         cunit = [unit]*2
         ctype = ["LINEAR"]*2
     frb = data_source.to_frb((1.0,"unitary"), (nx,ny))
@@ -295,7 +298,7 @@
     fields : string or list of strings
         The fields to slice
     center : A sequence floats, a string, or a tuple.
-         The coordinate of the center of the image. If set to 'c', 'center' or
+         The coordinate of the origin of the image. If set to 'c', 'center' or
          left blank, the plot is centered on the middle of the domain. If set to
          'max' or 'm', the center will be located at the maximum of the
          ('gas', 'density') field. Units can be specified by passing in center
@@ -308,7 +311,7 @@
         axis = fix_axis(axis, ds)
         center = get_sanitized_center(center, ds)
         slc = ds.slice(axis, center[axis], **kwargs)
-        w, frb = construct_image(slc)
+        w, frb = construct_image(slc, center=center)
         super(FITSSlice, self).__init__(frb, fields=fields, wcs=w)
         for i, field in enumerate(fields):
             self[i].header["bunit"] = str(frb[field].units)
@@ -327,12 +330,21 @@
         The fields to project
     weight_field : string
         The field used to weight the projection.
+    center : A sequence floats, a string, or a tuple.
+        The coordinate of the origin of the image. If set to 'c', 'center' or
+        left blank, the plot is centered on the middle of the domain. If set to
+        'max' or 'm', the center will be located at the maximum of the
+        ('gas', 'density') field. Units can be specified by passing in center
+        as a tuple containing a coordinate and string unit name or by passing
+        in a YTArray.  If a list or unitless array is supplied, code units are
+        assumed.
     """
-    def __init__(self, ds, axis, fields, weight_field=None, **kwargs):
+    def __init__(self, ds, axis, fields, center="c", weight_field=None, **kwargs):
         fields = ensure_list(fields)
         axis = fix_axis(axis, ds)
+        center = get_sanitized_center(center, ds)
         prj = ds.proj(fields[0], axis, weight_field=weight_field, **kwargs)
-        w, frb = construct_image(prj)
+        w, frb = construct_image(prj, center=center)
         super(FITSProjection, self).__init__(frb, fields=fields, wcs=w)
         for i, field in enumerate(fields):
             self[i].header["bunit"] = str(frb[field].units)


https://bitbucket.org/yt_analysis/yt/commits/7a8cec18f402/
Changeset:   7a8cec18f402
Branch:      yt-3.0
User:        jzuhone
Date:        2014-07-28 23:52:05
Summary:     Bug fix
Affected #:  1 file

diff -r d7af05c55681188113ca791a8c42666246ceded6 -r 7a8cec18f4023952c8d749f9cdf9063389e80fbe yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -264,12 +264,12 @@
         cunit = [str(ds.wcs.wcs.cunit[idx]) for idx in axis_wcs[axis]]
         ctype = [ds.wcs.wcs.ctype[idx] for idx in axis_wcs[axis]]
     else:
+        # This is some other kind of dataset
+        unit = ds.get_smallest_appropriate_unit(ds.domain_width.max())
         if center is None:
             crval = [0.0,0.0]
         else:
             crval = [(ds.domain_center-center)[idx].in_units(unit) for idx in axis_wcs[axis]]
-        # This is some other kind of dataset
-        unit = ds.get_smallest_appropriate_unit(ds.domain_width.max())
         dx = ds.index.get_smallest_dx()
         nx, ny = (ds.domain_width[axis_wcs[axis]]/dx).ndarray_view().astype("int")
         crpix = [0.5*(nx+1), 0.5*(ny+1)]


https://bitbucket.org/yt_analysis/yt/commits/0b13a3957c81/
Changeset:   0b13a3957c81
Branch:      yt
User:        jzuhone
Date:        2014-08-05 22:31:26
Summary:     Merge
Affected #:  1 file

diff -r 9e50338a7e3706e73a8406b41bb7379d06a7e96e -r 0b13a3957c81f8e7fa3241868b0da3d518c8fa37 yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -252,7 +252,7 @@
 
 axis_wcs = [[1,2],[0,2],[0,1]]
 
-def construct_image(data_source):
+def construct_image(data_source, center=None):
     ds = data_source.ds
     axis = data_source.axis
     if hasattr(ds, "wcs"):
@@ -266,11 +266,14 @@
     else:
         # This is some other kind of dataset
         unit = ds.get_smallest_appropriate_unit(ds.domain_width.max())
+        if center is None:
+            crval = [0.0,0.0]
+        else:
+            crval = [(ds.domain_center-center)[idx].in_units(unit) for idx in axis_wcs[axis]]
         dx = ds.index.get_smallest_dx()
         nx, ny = (ds.domain_width[axis_wcs[axis]]/dx).ndarray_view().astype("int")
         crpix = [0.5*(nx+1), 0.5*(ny+1)]
         cdelt = [dx.in_units(unit)]*2
-        crval = [ds.domain_center[idx].in_units(unit) for idx in axis_wcs[axis]]
         cunit = [unit]*2
         ctype = ["LINEAR"]*2
     frb = data_source.to_frb((1.0,"unitary"), (nx,ny))
@@ -295,7 +298,7 @@
     fields : string or list of strings
         The fields to slice
     center : A sequence floats, a string, or a tuple.
-         The coordinate of the center of the image. If set to 'c', 'center' or
+         The coordinate of the origin of the image. If set to 'c', 'center' or
          left blank, the plot is centered on the middle of the domain. If set to
          'max' or 'm', the center will be located at the maximum of the
          ('gas', 'density') field. Units can be specified by passing in center
@@ -308,7 +311,7 @@
         axis = fix_axis(axis, ds)
         center = get_sanitized_center(center, ds)
         slc = ds.slice(axis, center[axis], **kwargs)
-        w, frb = construct_image(slc)
+        w, frb = construct_image(slc, center=center)
         super(FITSSlice, self).__init__(frb, fields=fields, wcs=w)
         for i, field in enumerate(fields):
             self[i].header["bunit"] = str(frb[field].units)
@@ -327,12 +330,21 @@
         The fields to project
     weight_field : string
         The field used to weight the projection.
+    center : A sequence floats, a string, or a tuple.
+        The coordinate of the origin of the image. If set to 'c', 'center' or
+        left blank, the plot is centered on the middle of the domain. If set to
+        'max' or 'm', the center will be located at the maximum of the
+        ('gas', 'density') field. Units can be specified by passing in center
+        as a tuple containing a coordinate and string unit name or by passing
+        in a YTArray.  If a list or unitless array is supplied, code units are
+        assumed.
     """
-    def __init__(self, ds, axis, fields, weight_field=None, **kwargs):
+    def __init__(self, ds, axis, fields, center="c", weight_field=None, **kwargs):
         fields = ensure_list(fields)
         axis = fix_axis(axis, ds)
+        center = get_sanitized_center(center, ds)
         prj = ds.proj(fields[0], axis, weight_field=weight_field, **kwargs)
-        w, frb = construct_image(prj)
+        w, frb = construct_image(prj, center=center)
         super(FITSProjection, self).__init__(frb, fields=fields, wcs=w)
         for i, field in enumerate(fields):
             self[i].header["bunit"] = str(frb[field].units)


https://bitbucket.org/yt_analysis/yt/commits/6080e68a1e27/
Changeset:   6080e68a1e27
Branch:      yt
User:        jzuhone
Date:        2014-08-06 01:23:30
Summary:     Athena answer testing
Affected #:  2 files

diff -r 0b13a3957c81f8e7fa3241868b0da3d518c8fa37 -r 6080e68a1e27c9acbb71ae6e73b662a5cf624c22 yt/frontends/athena/tests/test_outputs.py
--- /dev/null
+++ b/yt/frontends/athena/tests/test_outputs.py
@@ -0,0 +1,62 @@
+"""
+Athena frontend tests
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2013, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+from yt.testing import *
+from yt.utilities.answer_testing.framework import \
+    requires_ds, \
+    small_patch_amr, \
+    big_patch_amr, \
+    data_dir_load
+from yt.frontends.athena.api import AthenaDataset
+
+parameters_sloshing = {"time_unit":(1.0,"Myr"),
+                       "length_unit":(1.0,"Mpc"),
+                       "mass_unit":(1.0e14,"Msun")}
+parameters_stripping = {"time_unit":3.086e14,
+                        "length_unit":8.0236e22,
+                        "mass_unit":9.999e-30*8.0236e22**3}
+
+_fields_sloshing = ("temperature", "density", "velocity_magnitude")
+
+sloshing = "MHDSloshing/sloshing_low_res_hdf5_plt_cnt_0300"
+ at requires_ds(sloshing, big_data=True)
+def test_sloshing():
+    ds = data_dir_load(sloshing, parameters=parameters_sloshing)
+    yield assert_equal, str(ds), "sloshing_low_res_hdf5_plt_cnt_0300"
+    for test in small_patch_amr(sloshing, _fields_sloshing):
+        test_sloshing.__name__ = test.description
+        yield test
+
+_fields_blast = ("temperature", "density")
+
+blast = "WindTunnel/windtunnel_4lev_hdf5_plt_cnt_0030"
+ at requires_ds(blast)
+def test_blast():
+    ds = data_dir_load(blast)
+    yield assert_equal, str(ds), "windtunnel_4lev_hdf5_plt_cnt_0030"
+    for test in small_patch_amr(blast, _fields_blast):
+        test_blast.__name__ = test.description
+        yield test
+
+_fields_stripping = ("temperature", "density")
+
+stripping = "WindTunnel/windtunnel_4lev_hdf5_plt_cnt_0030"
+ at requires_ds(stripping)
+def test_stripping():
+    ds = data_dir_load(stripping, parameters=parameters_stripping)
+    yield assert_equal, str(ds), "windtunnel_4lev_hdf5_plt_cnt_0030"
+    for test in small_patch_amr(stripping, _fields_stripping):
+        test_stripping.__name__ = test.description
+        yield test


https://bitbucket.org/yt_analysis/yt/commits/cee33cd5a63f/
Changeset:   cee33cd5a63f
Branch:      yt
User:        jzuhone
Date:        2014-08-06 02:55:26
Summary:     This athena field was missing from the definitions
Affected #:  1 file

diff -r 6080e68a1e27c9acbb71ae6e73b662a5cf624c22 -r cee33cd5a63f6e2f4ec13aecce2dbdea94ea2c79 yt/frontends/athena/fields.py
--- a/yt/frontends/athena/fields.py
+++ b/yt/frontends/athena/fields.py
@@ -96,6 +96,8 @@
                            function=_total_energy,
                            units="erg/g")
         elif ("athena","total_energy") in self.field_list:
+            self.add_output_field(("athena","total_energy"),
+                                  units=pres_units)
             def _pressure(field, data):
                 return eint_from_etot(data)*(data.ds.gamma-1.0)
             self.add_field(("gas","pressure"), function=_pressure,


https://bitbucket.org/yt_analysis/yt/commits/df0a3e692482/
Changeset:   df0a3e692482
Branch:      yt
User:        jzuhone
Date:        2014-08-06 02:55:40
Summary:     Updating answer tests
Affected #:  1 file

diff -r cee33cd5a63f6e2f4ec13aecce2dbdea94ea2c79 -r df0a3e692482df9214d99f620de496aea04c72e0 yt/frontends/athena/tests/test_outputs.py
--- a/yt/frontends/athena/tests/test_outputs.py
+++ b/yt/frontends/athena/tests/test_outputs.py
@@ -24,39 +24,40 @@
 parameters_sloshing = {"time_unit":(1.0,"Myr"),
                        "length_unit":(1.0,"Mpc"),
                        "mass_unit":(1.0e14,"Msun")}
+
 parameters_stripping = {"time_unit":3.086e14,
                         "length_unit":8.0236e22,
                         "mass_unit":9.999e-30*8.0236e22**3}
 
-_fields_sloshing = ("temperature", "density", "velocity_magnitude")
+_fields_sloshing = ("temperature", "density", "magnetic_energy")
 
-sloshing = "MHDSloshing/sloshing_low_res_hdf5_plt_cnt_0300"
+sloshing = "MHDSloshing/id0/virgo_cluster.0055.vtk"
 @requires_ds(sloshing, big_data=True)
 def test_sloshing():
     ds = data_dir_load(sloshing, parameters=parameters_sloshing)
-    yield assert_equal, str(ds), "sloshing_low_res_hdf5_plt_cnt_0300"
+    yield assert_equal, str(ds), "virgo_cluster.0055"
     for test in small_patch_amr(sloshing, _fields_sloshing):
         test_sloshing.__name__ = test.description
         yield test
 
-_fields_blast = ("temperature", "density")
+_fields_blast = ("temperature", "density", "velocity_magnitude")
 
-blast = "WindTunnel/windtunnel_4lev_hdf5_plt_cnt_0030"
+blast = "MHDBlast/Blast.0100.vtk"
 @requires_ds(blast)
 def test_blast():
     ds = data_dir_load(blast)
-    yield assert_equal, str(ds), "windtunnel_4lev_hdf5_plt_cnt_0030"
+    yield assert_equal, str(ds), "Blast.0100"
     for test in small_patch_amr(blast, _fields_blast):
         test_blast.__name__ = test.description
         yield test
 
-_fields_stripping = ("temperature", "density")
+_fields_stripping = ("temperature", "density", "specific_scalar[0]")
 
-stripping = "WindTunnel/windtunnel_4lev_hdf5_plt_cnt_0030"
+stripping = "RamPressureStripping/id0/rps.0062.vtk"
 @requires_ds(stripping)
 def test_stripping():
     ds = data_dir_load(stripping, parameters=parameters_stripping)
-    yield assert_equal, str(ds), "windtunnel_4lev_hdf5_plt_cnt_0030"
+    yield assert_equal, str(ds), "rps.0062"
     for test in small_patch_amr(stripping, _fields_stripping):
         test_stripping.__name__ = test.description
         yield test


https://bitbucket.org/yt_analysis/yt/commits/18a2319d925d/
Changeset:   18a2319d925d
Branch:      yt
User:        jzuhone
Date:        2014-08-06 04:46:46
Summary:     More iterations to get the answer tests to work, but still some bugs
Affected #:  3 files

diff -r df0a3e692482df9214d99f620de496aea04c72e0 -r 18a2319d925db69d7ef3938f636bf35feead7d13 yt/frontends/athena/data_structures.py
--- a/yt/frontends/athena/data_structures.py
+++ b/yt/frontends/athena/data_structures.py
@@ -107,7 +107,7 @@
         self.directory = os.path.dirname(self.dataset.filename)
         self.dataset_type = dataset_type
         # for now, the index file is the dataset!
-        self.index_filename = self.dataset.filename
+        self.index_filename = os.path.join(os.getcwd(), self.dataset.filename)
         #self.directory = os.path.dirname(self.index_filename)
         self._fhandle = file(self.index_filename,'rb')
         GridIndex.__init__(self, ds, dataset_type)

diff -r df0a3e692482df9214d99f620de496aea04c72e0 -r 18a2319d925db69d7ef3938f636bf35feead7d13 yt/frontends/athena/fields.py
--- a/yt/frontends/athena/fields.py
+++ b/yt/frontends/athena/fields.py
@@ -41,18 +41,18 @@
     def setup_fluid_fields(self):
         # Add velocity fields
         for comp in "xyz":
-            vel_field = ("athena", "velocity_%s" % (comp))
-            mom_field = ("athena", "momentum_%s" % (comp))
+            vel_field = ("athena", "velocity_%s" % comp)
+            mom_field = ("athena", "momentum_%s" % comp)
             if vel_field in self.field_list:
                 self.add_output_field(vel_field, units="code_length/code_time")
-                self.alias(("gas","velocity_%s" % (comp)), vel_field,
+                self.alias(("gas","velocity_%s" % comp), vel_field,
                            units="cm/s")
             elif mom_field in self.field_list:
                 self.add_output_field(mom_field,
                                       units="code_mass*code_length/code_time")
-                f = lambda data: data["athena","momentum_%s" % (comp)] / \
+                f = lambda data: data["athena","momentum_%s" % comp] / \
                                  data["athena","density"]
-                self.add_field(("gas","velocity_%s" % (comp)),
+                self.add_field(("gas","velocity_%s" % comp),
                                function=f, units = "cm/s")
         # Add pressure, energy, and temperature fields
         def ekin1(data):

diff -r df0a3e692482df9214d99f620de496aea04c72e0 -r 18a2319d925db69d7ef3938f636bf35feead7d13 yt/frontends/athena/tests/test_outputs.py
--- a/yt/frontends/athena/tests/test_outputs.py
+++ b/yt/frontends/athena/tests/test_outputs.py
@@ -34,7 +34,7 @@
 sloshing = "MHDSloshing/id0/virgo_cluster.0055.vtk"
 @requires_ds(sloshing, big_data=True)
 def test_sloshing():
-    ds = data_dir_load(sloshing, parameters=parameters_sloshing)
+    ds = data_dir_load(sloshing, kwargs={"parameters":parameters_sloshing})
     yield assert_equal, str(ds), "virgo_cluster.0055"
     for test in small_patch_amr(sloshing, _fields_sloshing):
         test_sloshing.__name__ = test.description
@@ -53,10 +53,10 @@
 
 _fields_stripping = ("temperature", "density", "specific_scalar[0]")
 
-stripping = "RamPressureStripping/id0/rps.0062.vtk"
- at requires_ds(stripping)
+stripping = "RamPressureStripping/id0/rps.0063.vtk"
+ at requires_ds(stripping, big_data=True)
 def test_stripping():
-    ds = data_dir_load(stripping, parameters=parameters_stripping)
+    ds = data_dir_load(stripping, kwargs={"parameters":parameters_stripping})
     yield assert_equal, str(ds), "rps.0062"
     for test in small_patch_amr(stripping, _fields_stripping):
         test_stripping.__name__ = test.description


https://bitbucket.org/yt_analysis/yt/commits/b768ffa735ac/
Changeset:   b768ffa735ac
Branch:      yt
User:        jzuhone
Date:        2014-08-06 05:47:36
Summary:     Not sure why this change is necessary, but it fixes the velocity bugs. I do know why the units were wrong for momentum though.
Affected #:  2 files

diff -r 18a2319d925db69d7ef3938f636bf35feead7d13 -r b768ffa735ac9a3f13f8dc2222b4303dde6f4fe3 yt/frontends/athena/data_structures.py
--- a/yt/frontends/athena/data_structures.py
+++ b/yt/frontends/athena/data_structures.py
@@ -366,7 +366,7 @@
         # Unfortunately we now have to mandate that the index gets 
         # instantiated so that we can make sure we have the correct left 
         # and right domain edges.
-        self.h
+        self.index
 
     def _set_code_unit_attributes(self):
         """
@@ -458,14 +458,13 @@
             self.hubble_constant = self.cosmological_simulation = 0.0
         self.parameters['Time'] = self.current_time # Hardcode time conversion for now.
         self.parameters["HydroMethod"] = 0 # Hardcode for now until field staggering is supported.
-        if self.specified_parameters.has_key("gamma") :
+        if self.specified_parameters.has_key("gamma"):
             self.parameters["Gamma"] = self.specified_parameters["gamma"]
-        else :
+        else:
             self.parameters["Gamma"] = 5./3. 
         self.geometry = self.specified_parameters.get("geometry", "cartesian")
         self._handle.close()
 
-
     @classmethod
     def _is_valid(self, *args, **kwargs):
         try:

diff -r 18a2319d925db69d7ef3938f636bf35feead7d13 -r b768ffa735ac9a3f13f8dc2222b4303dde6f4fe3 yt/frontends/athena/fields.py
--- a/yt/frontends/athena/fields.py
+++ b/yt/frontends/athena/fields.py
@@ -49,11 +49,11 @@
                            units="cm/s")
             elif mom_field in self.field_list:
                 self.add_output_field(mom_field,
-                                      units="code_mass*code_length/code_time")
-                f = lambda data: data["athena","momentum_%s" % comp] / \
-                                 data["athena","density"]
+                                      units="code_mass/code_time/code_length**2")
+                def _velocity(field, data):
+                    return data[mom_field]/data["athena","density"]
                 self.add_field(("gas","velocity_%s" % comp),
-                               function=f, units = "cm/s")
+                               function=_velocity, units = "cm/s")
         # Add pressure, energy, and temperature fields
         def ekin1(data):
             return 0.5*(data["athena","momentum_x"]**2 +


https://bitbucket.org/yt_analysis/yt/commits/f0d323a1b915/
Changeset:   f0d323a1b915
Branch:      yt
User:        jzuhone
Date:        2014-08-06 06:13:24
Summary:     Squashing more athena bugs
Affected #:  2 files

diff -r b768ffa735ac9a3f13f8dc2222b4303dde6f4fe3 -r f0d323a1b9151e32b7f0a921339ae21540694489 yt/frontends/athena/fields.py
--- a/yt/frontends/athena/fields.py
+++ b/yt/frontends/athena/fields.py
@@ -25,6 +25,11 @@
 erg_units = "code_mass * (code_length/code_time)**2"
 rho_units = "code_mass / code_length**3"
 
+def velocity_field(comp):
+    def _velocity(field, data):
+        return data["athena", "momentum_%s" % comp]/data["athena","density"]
+    return _velocity
+
 class AthenaFieldInfo(FieldInfoContainer):
     known_other_fields = (
         ("density", ("code_mass/code_length**3", ["density"], None)),
@@ -50,10 +55,8 @@
             elif mom_field in self.field_list:
                 self.add_output_field(mom_field,
                                       units="code_mass/code_time/code_length**2")
-                def _velocity(field, data):
-                    return data[mom_field]/data["athena","density"]
                 self.add_field(("gas","velocity_%s" % comp),
-                               function=_velocity, units = "cm/s")
+                               function=velocity_field(comp), units = "cm/s")
         # Add pressure, energy, and temperature fields
         def ekin1(data):
             return 0.5*(data["athena","momentum_x"]**2 +

diff -r b768ffa735ac9a3f13f8dc2222b4303dde6f4fe3 -r f0d323a1b9151e32b7f0a921339ae21540694489 yt/frontends/athena/tests/test_outputs.py
--- a/yt/frontends/athena/tests/test_outputs.py
+++ b/yt/frontends/athena/tests/test_outputs.py
@@ -53,7 +53,7 @@
 
 _fields_stripping = ("temperature", "density", "specific_scalar[0]")
 
-stripping = "RamPressureStripping/id0/rps.0063.vtk"
+stripping = "RamPressureStripping/id0/rps.0062.vtk"
 @requires_ds(stripping, big_data=True)
 def test_stripping():
     ds = data_dir_load(stripping, kwargs={"parameters":parameters_stripping})


https://bitbucket.org/yt_analysis/yt/commits/879a6b0c01c1/
Changeset:   879a6b0c01c1
Branch:      yt
User:        jzuhone
Date:        2014-08-06 18:37:41
Summary:     The optional argument for input_center wasn't being used
Affected #:  1 file

diff -r f0d323a1b9151e32b7f0a921339ae21540694489 -r 879a6b0c01c18f2bd4c4bd64eaf442ce71ad4bb0 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -758,7 +758,7 @@
 
 def big_patch_amr(ds_fn, fields, input_center="max", input_weight="density"):
     if not can_run_ds(ds_fn): return
-    dso = [ None, ("sphere", ("max", (0.1, 'unitary')))]
+    dso = [ None, ("sphere", (input_center, (0.1, 'unitary')))]
     yield GridHierarchyTest(ds_fn)
     yield ParentageRelationshipsTest(ds_fn)
     for field in fields:


https://bitbucket.org/yt_analysis/yt/commits/2939122bac38/
Changeset:   2939122bac38
Branch:      yt
User:        jzuhone
Date:        2014-08-06 20:34:44
Summary:     Fix projections for no_cgs_equiv_length datasets when the field dimensions are dimensionless
Affected #:  1 file

diff -r 879a6b0c01c18f2bd4c4bd64eaf442ce71ad4bb0 -r 2939122bac38786372e3abf8c7a3873c1429dad5 yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -336,8 +336,8 @@
                                   registry=self.ds.unit_registry)
             if self.weight_field is None and not self._sum_only:
                 u_obj = Unit(units, registry=self.ds.unit_registry)
-                if (u_obj.is_code_unit and not u_obj.is_dimensionless) and \
-                  input_units != units or self.ds.no_cgs_equiv_length:
+                if ((u_obj.is_code_unit or self.ds.no_cgs_equiv_length) and
+                    not u_obj.is_dimensionless) and input_units != units:
                     final_unit = "(%s) * code_length" % units
                     self[field].convert_to_units(final_unit)
         for i in data.keys(): self[i] = data.pop(i)


https://bitbucket.org/yt_analysis/yt/commits/8f49d0537977/
Changeset:   8f49d0537977
Branch:      yt
User:        jzuhone
Date:        2014-08-06 20:50:41
Summary:     Using different datasets for the answer tests
Affected #:  1 file

diff -r 2939122bac38786372e3abf8c7a3873c1429dad5 -r 8f49d0537977cf0e96dfccddb3b66e6c801bd1fd yt/frontends/athena/tests/test_outputs.py
--- a/yt/frontends/athena/tests/test_outputs.py
+++ b/yt/frontends/athena/tests/test_outputs.py
@@ -21,28 +21,20 @@
     data_dir_load
 from yt.frontends.athena.api import AthenaDataset
 
-parameters_sloshing = {"time_unit":(1.0,"Myr"),
-                       "length_unit":(1.0,"Mpc"),
-                       "mass_unit":(1.0e14,"Msun")}
+_fields_cloud = ("scalar[0]", "density", "total_energy")
 
-parameters_stripping = {"time_unit":3.086e14,
-                        "length_unit":8.0236e22,
-                        "mass_unit":9.999e-30*8.0236e22**3}
-
-_fields_sloshing = ("temperature", "density", "magnetic_energy")
-
-sloshing = "MHDSloshing/id0/virgo_cluster.0055.vtk"
- at requires_ds(sloshing, big_data=True)
-def test_sloshing():
-    ds = data_dir_load(sloshing, kwargs={"parameters":parameters_sloshing})
-    yield assert_equal, str(ds), "virgo_cluster.0055"
-    for test in small_patch_amr(sloshing, _fields_sloshing):
-        test_sloshing.__name__ = test.description
+cloud = "ShockCloud/id0/Cloud.0050.vtk"
+ at requires_ds(cloud)
+def test_cloud():
+    ds = data_dir_load(cloud)
+    yield assert_equal, str(ds), "Cloud.0050"
+    for test in small_patch_amr(cloud, _fields_cloud):
+        test_cloud.__name__ = test.description
         yield test
 
 _fields_blast = ("temperature", "density", "velocity_magnitude")
 
-blast = "MHDBlast/Blast.0100.vtk"
+blast = "MHDBlast/id0/Blast.0100.vtk"
 @requires_ds(blast)
 def test_blast():
     ds = data_dir_load(blast)
@@ -51,6 +43,10 @@
         test_blast.__name__ = test.description
         yield test
 
+parameters_stripping = {"time_unit":3.086e14,
+                        "length_unit":8.0236e22,
+                        "mass_unit":9.999e-30*8.0236e22**3}
+
 _fields_stripping = ("temperature", "density", "specific_scalar[0]")
 
 stripping = "RamPressureStripping/id0/rps.0062.vtk"


https://bitbucket.org/yt_analysis/yt/commits/47d240b30d78/
Changeset:   47d240b30d78
Branch:      yt
User:        jzuhone
Date:        2014-08-07 23:08:49
Summary:     Updated code support to reflect Athena answer testing.
Affected #:  1 file

diff -r 8f49d0537977cf0e96dfccddb3b66e6c801bd1fd -r 47d240b30d78885fd9284b85d9d2ee9b82342266 doc/source/reference/code_support.rst
--- a/doc/source/reference/code_support.rst
+++ b/doc/source/reference/code_support.rst
@@ -20,7 +20,7 @@
 +-----------------------+------------+-----------+------------+-------+----------+----------+------------+----------+ 
 | ARTIO                 |     Y      |     Y     |      Y     |   Y   |    Y     |    Y     |     Y      |   Full   |
 +-----------------------+------------+-----------+------------+-------+----------+----------+------------+----------+ 
-| Athena                |     Y      |     N     |      Y     |   Y   |    Y     |    Y     |     N      |   Full   |
+| Athena                |     Y      |     N     |      Y     |   Y   |    Y     |    Y     |     Y      |   Full   |
 +-----------------------+------------+-----------+------------+-------+----------+----------+------------+----------+ 
 | Castro                |     Y      |     Y     |   Partial  |   Y   |    Y     |    Y     |     N      |   Full   |
 +-----------------------+------------+-----------+------------+-------+----------+----------+------------+----------+ 


https://bitbucket.org/yt_analysis/yt/commits/77bbb0c5a38e/
Changeset:   77bbb0c5a38e
Branch:      yt
User:        xarthisius
Date:        2014-08-10 09:55:15
Summary:     Merged in jzuhone/yt-3.x (pull request #1135)

Athena Answer Testing and Bug Fixes
Affected #:  8 files

diff -r d0ec6bb3dbf2455e05e565f1d862a2942810e6ef -r 77bbb0c5a38e27dd1855f23710a631765ca31f05 doc/source/reference/code_support.rst
--- a/doc/source/reference/code_support.rst
+++ b/doc/source/reference/code_support.rst
@@ -20,7 +20,7 @@
 +-----------------------+------------+-----------+------------+-------+----------+----------+------------+----------+ 
 | ARTIO                 |     Y      |     Y     |      Y     |   Y   |    Y     |    Y     |     Y      |   Full   |
 +-----------------------+------------+-----------+------------+-------+----------+----------+------------+----------+ 
-| Athena                |     Y      |     N     |      Y     |   Y   |    Y     |    Y     |     N      |   Full   |
+| Athena                |     Y      |     N     |      Y     |   Y   |    Y     |    Y     |     Y      |   Full   |
 +-----------------------+------------+-----------+------------+-------+----------+----------+------------+----------+ 
 | Castro                |     Y      |     Y     |   Partial  |   Y   |    Y     |    Y     |     N      |   Full   |
 +-----------------------+------------+-----------+------------+-------+----------+----------+------------+----------+ 

diff -r d0ec6bb3dbf2455e05e565f1d862a2942810e6ef -r 77bbb0c5a38e27dd1855f23710a631765ca31f05 yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -336,8 +336,8 @@
                                   registry=self.ds.unit_registry)
             if self.weight_field is None and not self._sum_only:
                 u_obj = Unit(units, registry=self.ds.unit_registry)
-                if (u_obj.is_code_unit and not u_obj.is_dimensionless) and \
-                  input_units != units or self.ds.no_cgs_equiv_length:
+                if ((u_obj.is_code_unit or self.ds.no_cgs_equiv_length) and
+                    not u_obj.is_dimensionless) and input_units != units:
                     final_unit = "(%s) * code_length" % units
                     self[field].convert_to_units(final_unit)
         for i in data.keys(): self[i] = data.pop(i)

diff -r d0ec6bb3dbf2455e05e565f1d862a2942810e6ef -r 77bbb0c5a38e27dd1855f23710a631765ca31f05 yt/frontends/athena/data_structures.py
--- a/yt/frontends/athena/data_structures.py
+++ b/yt/frontends/athena/data_structures.py
@@ -107,7 +107,7 @@
         self.directory = os.path.dirname(self.dataset.filename)
         self.dataset_type = dataset_type
         # for now, the index file is the dataset!
-        self.index_filename = self.dataset.filename
+        self.index_filename = os.path.join(os.getcwd(), self.dataset.filename)
         #self.directory = os.path.dirname(self.index_filename)
         self._fhandle = file(self.index_filename,'rb')
         GridIndex.__init__(self, ds, dataset_type)
@@ -366,7 +366,7 @@
         # Unfortunately we now have to mandate that the index gets 
         # instantiated so that we can make sure we have the correct left 
         # and right domain edges.
-        self.h
+        self.index
 
     def _set_code_unit_attributes(self):
         """
@@ -458,14 +458,13 @@
             self.hubble_constant = self.cosmological_simulation = 0.0
         self.parameters['Time'] = self.current_time # Hardcode time conversion for now.
         self.parameters["HydroMethod"] = 0 # Hardcode for now until field staggering is supported.
-        if self.specified_parameters.has_key("gamma") :
+        if self.specified_parameters.has_key("gamma"):
             self.parameters["Gamma"] = self.specified_parameters["gamma"]
-        else :
+        else:
             self.parameters["Gamma"] = 5./3. 
         self.geometry = self.specified_parameters.get("geometry", "cartesian")
         self._handle.close()
 
-
     @classmethod
     def _is_valid(self, *args, **kwargs):
         try:

diff -r d0ec6bb3dbf2455e05e565f1d862a2942810e6ef -r 77bbb0c5a38e27dd1855f23710a631765ca31f05 yt/frontends/athena/fields.py
--- a/yt/frontends/athena/fields.py
+++ b/yt/frontends/athena/fields.py
@@ -25,6 +25,11 @@
 erg_units = "code_mass * (code_length/code_time)**2"
 rho_units = "code_mass / code_length**3"
 
+def velocity_field(comp):
+    def _velocity(field, data):
+        return data["athena", "momentum_%s" % comp]/data["athena","density"]
+    return _velocity
+
 class AthenaFieldInfo(FieldInfoContainer):
     known_other_fields = (
         ("density", ("code_mass/code_length**3", ["density"], None)),
@@ -41,19 +46,17 @@
     def setup_fluid_fields(self):
         # Add velocity fields
         for comp in "xyz":
-            vel_field = ("athena", "velocity_%s" % (comp))
-            mom_field = ("athena", "momentum_%s" % (comp))
+            vel_field = ("athena", "velocity_%s" % comp)
+            mom_field = ("athena", "momentum_%s" % comp)
             if vel_field in self.field_list:
                 self.add_output_field(vel_field, units="code_length/code_time")
-                self.alias(("gas","velocity_%s" % (comp)), vel_field,
+                self.alias(("gas","velocity_%s" % comp), vel_field,
                            units="cm/s")
             elif mom_field in self.field_list:
                 self.add_output_field(mom_field,
-                                      units="code_mass*code_length/code_time")
-                f = lambda data: data["athena","momentum_%s" % (comp)] / \
-                                 data["athena","density"]
-                self.add_field(("gas","velocity_%s" % (comp)),
-                               function=f, units = "cm/s")
+                                      units="code_mass/code_time/code_length**2")
+                self.add_field(("gas","velocity_%s" % comp),
+                               function=velocity_field(comp), units = "cm/s")
         # Add pressure, energy, and temperature fields
         def ekin1(data):
             return 0.5*(data["athena","momentum_x"]**2 +
@@ -96,6 +99,8 @@
                            function=_total_energy,
                            units="erg/g")
         elif ("athena","total_energy") in self.field_list:
+            self.add_output_field(("athena","total_energy"),
+                                  units=pres_units)
             def _pressure(field, data):
                 return eint_from_etot(data)*(data.ds.gamma-1.0)
             self.add_field(("gas","pressure"), function=_pressure,

diff -r d0ec6bb3dbf2455e05e565f1d862a2942810e6ef -r 77bbb0c5a38e27dd1855f23710a631765ca31f05 yt/frontends/athena/tests/test_outputs.py
--- /dev/null
+++ b/yt/frontends/athena/tests/test_outputs.py
@@ -0,0 +1,59 @@
+"""
+Athena frontend tests
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2013, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+from yt.testing import *
+from yt.utilities.answer_testing.framework import \
+    requires_ds, \
+    small_patch_amr, \
+    big_patch_amr, \
+    data_dir_load
+from yt.frontends.athena.api import AthenaDataset
+
+_fields_cloud = ("scalar[0]", "density", "total_energy")
+
+cloud = "ShockCloud/id0/Cloud.0050.vtk"
+ at requires_ds(cloud)
+def test_cloud():
+    ds = data_dir_load(cloud)
+    yield assert_equal, str(ds), "Cloud.0050"
+    for test in small_patch_amr(cloud, _fields_cloud):
+        test_cloud.__name__ = test.description
+        yield test
+
+_fields_blast = ("temperature", "density", "velocity_magnitude")
+
+blast = "MHDBlast/id0/Blast.0100.vtk"
+ at requires_ds(blast)
+def test_blast():
+    ds = data_dir_load(blast)
+    yield assert_equal, str(ds), "Blast.0100"
+    for test in small_patch_amr(blast, _fields_blast):
+        test_blast.__name__ = test.description
+        yield test
+
+parameters_stripping = {"time_unit":3.086e14,
+                        "length_unit":8.0236e22,
+                        "mass_unit":9.999e-30*8.0236e22**3}
+
+_fields_stripping = ("temperature", "density", "specific_scalar[0]")
+
+stripping = "RamPressureStripping/id0/rps.0062.vtk"
+ at requires_ds(stripping, big_data=True)
+def test_stripping():
+    ds = data_dir_load(stripping, kwargs={"parameters":parameters_stripping})
+    yield assert_equal, str(ds), "rps.0062"
+    for test in small_patch_amr(stripping, _fields_stripping):
+        test_stripping.__name__ = test.description
+        yield test

diff -r d0ec6bb3dbf2455e05e565f1d862a2942810e6ef -r 77bbb0c5a38e27dd1855f23710a631765ca31f05 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -758,7 +758,7 @@
 
 def big_patch_amr(ds_fn, fields, input_center="max", input_weight="density"):
     if not can_run_ds(ds_fn): return
-    dso = [ None, ("sphere", ("max", (0.1, 'unitary')))]
+    dso = [ None, ("sphere", (input_center, (0.1, 'unitary')))]
     yield GridHierarchyTest(ds_fn)
     yield ParentageRelationshipsTest(ds_fn)
     for field in fields:

diff -r d0ec6bb3dbf2455e05e565f1d862a2942810e6ef -r 77bbb0c5a38e27dd1855f23710a631765ca31f05 yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -252,7 +252,7 @@
 
 axis_wcs = [[1,2],[0,2],[0,1]]
 
-def construct_image(data_source):
+def construct_image(data_source, center=None):
     ds = data_source.ds
     axis = data_source.axis
     if hasattr(ds, "wcs"):
@@ -266,11 +266,14 @@
     else:
         # This is some other kind of dataset
         unit = ds.get_smallest_appropriate_unit(ds.domain_width.max())
+        if center is None:
+            crval = [0.0,0.0]
+        else:
+            crval = [(ds.domain_center-center)[idx].in_units(unit) for idx in axis_wcs[axis]]
         dx = ds.index.get_smallest_dx()
         nx, ny = (ds.domain_width[axis_wcs[axis]]/dx).ndarray_view().astype("int")
         crpix = [0.5*(nx+1), 0.5*(ny+1)]
         cdelt = [dx.in_units(unit)]*2
-        crval = [ds.domain_center[idx].in_units(unit) for idx in axis_wcs[axis]]
         cunit = [unit]*2
         ctype = ["LINEAR"]*2
     frb = data_source.to_frb((1.0,"unitary"), (nx,ny))
@@ -295,7 +298,7 @@
     fields : string or list of strings
         The fields to slice
     center : A sequence floats, a string, or a tuple.
-         The coordinate of the center of the image. If set to 'c', 'center' or
+         The coordinate of the origin of the image. If set to 'c', 'center' or
          left blank, the plot is centered on the middle of the domain. If set to
          'max' or 'm', the center will be located at the maximum of the
          ('gas', 'density') field. Units can be specified by passing in center
@@ -308,7 +311,7 @@
         axis = fix_axis(axis, ds)
         center = get_sanitized_center(center, ds)
         slc = ds.slice(axis, center[axis], **kwargs)
-        w, frb = construct_image(slc)
+        w, frb = construct_image(slc, center=center)
         super(FITSSlice, self).__init__(frb, fields=fields, wcs=w)
         for i, field in enumerate(fields):
             self[i].header["bunit"] = str(frb[field].units)
@@ -327,12 +330,21 @@
         The fields to project
     weight_field : string
         The field used to weight the projection.
+    center : A sequence floats, a string, or a tuple.
+        The coordinate of the origin of the image. If set to 'c', 'center' or
+        left blank, the plot is centered on the middle of the domain. If set to
+        'max' or 'm', the center will be located at the maximum of the
+        ('gas', 'density') field. Units can be specified by passing in center
+        as a tuple containing a coordinate and string unit name or by passing
+        in a YTArray.  If a list or unitless array is supplied, code units are
+        assumed.
     """
-    def __init__(self, ds, axis, fields, weight_field=None, **kwargs):
+    def __init__(self, ds, axis, fields, center="c", weight_field=None, **kwargs):
         fields = ensure_list(fields)
         axis = fix_axis(axis, ds)
+        center = get_sanitized_center(center, ds)
         prj = ds.proj(fields[0], axis, weight_field=weight_field, **kwargs)
-        w, frb = construct_image(prj)
+        w, frb = construct_image(prj, center=center)
         super(FITSProjection, self).__init__(frb, fields=fields, wcs=w)
         for i, field in enumerate(fields):
             self[i].header["bunit"] = str(frb[field].units)

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