[yt-svn] commit/yt: 7 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Oct 16 13:10:52 PDT 2017
7 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/d79b1faf0378/
Changeset: d79b1faf0378
User: brittonsmith
Date: 2017-09-29 23:21:03+00:00
Summary: Fix typo in light cone projection.
Affected #: 1 file
diff -r f292c74a3a4f6b535647dd138465dc2561b68850 -r d79b1faf0378f3c5c16b7e0b1f7c97dbdf0f2b08 yt/analysis_modules/cosmological_observation/light_cone/light_cone_projection.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/light_cone_projection.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/light_cone_projection.py
@@ -210,7 +210,7 @@
proj.field_data["pdy"] = proj.field_data["pdy"].unit_quantity * \
np.concatenate([proj.field_data["pdy"].d, add_x_pdy.d, add_y_pdy.d,
add2_x_pdy.d, add2_y_pdy.d])
- proj.field_data[proj_field] = proj.field_data["pdy"].unit_quantity * \
+ proj.field_data[proj_field] = proj.field_data[proj_field].unit_quantity * \
np.concatenate([proj.field_data[proj_field].d, add_x_field.d, add_y_field.d,
add2_x_field.d, add2_y_field.d])
proj.field_data["weight_field"] = proj.field_data["weight_field"].unit_quantity * \
https://bitbucket.org/yt_analysis/yt/commits/5de1905a866d/
Changeset: 5de1905a866d
User: brittonsmith
Date: 2017-09-29 23:28:04+00:00
Summary: Switch from np.concatenate to uconcatenate for clarity/simplicity.
Affected #: 1 file
diff -r d79b1faf0378f3c5c16b7e0b1f7c97dbdf0f2b08 -r 5de1905a866d03e4eb4c3ac3b507eb3e6d9b2b37 yt/analysis_modules/cosmological_observation/light_cone/light_cone_projection.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/light_cone_projection.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/light_cone_projection.py
@@ -17,6 +17,8 @@
from yt.funcs import \
mylog
+from yt.units.yt_array import \
+ uconcatenate
from yt.visualization.fixed_resolution import \
FixedResolutionBuffer
from yt.utilities.parallel_tools.parallel_analysis_interface import \
@@ -198,25 +200,25 @@
del add_y_left
# Add the hanging cells back to the projection data.
- proj.field_data["px"] = proj.field_data["px"].unit_quantity * \
- np.concatenate([proj.field_data["px"].d, add_x_px.d, add_y_px.d,
- add2_x_px.d, add2_y_px.d])
- proj.field_data["py"] = proj.field_data["py"].unit_quantity * \
- np.concatenate([proj.field_data["py"].d, add_x_py.d, add_y_py.d,
- add2_x_py.d, add2_y_py.d])
- proj.field_data["pdx"] = proj.field_data["pdx"].unit_quantity * \
- np.concatenate([proj.field_data["pdx"].d, add_x_pdx.d, add_y_pdx.d,
- add2_x_pdx.d, add2_y_pdx.d])
- proj.field_data["pdy"] = proj.field_data["pdy"].unit_quantity * \
- np.concatenate([proj.field_data["pdy"].d, add_x_pdy.d, add_y_pdy.d,
- add2_x_pdy.d, add2_y_pdy.d])
- proj.field_data[proj_field] = proj.field_data[proj_field].unit_quantity * \
- np.concatenate([proj.field_data[proj_field].d, add_x_field.d, add_y_field.d,
- add2_x_field.d, add2_y_field.d])
- proj.field_data["weight_field"] = proj.field_data["weight_field"].unit_quantity * \
- np.concatenate([proj.field_data["weight_field"].d,
- add_x_weight_field.d, add_y_weight_field.d,
- add2_x_weight_field.d, add2_y_weight_field.d])
+ proj.field_data["px"] = uconcatenate(
+ [proj.field_data["px"], add_x_px,
+ add_y_px, add2_x_px, add2_y_px])
+ proj.field_data["py"] = uconcatenate(
+ [proj.field_data["py"], add_x_py,
+ add_y_py, add2_x_py, add2_y_py])
+ proj.field_data["pdx"] = uconcatenate(
+ [proj.field_data["pdx"], add_x_pdx,
+ add_y_pdx, add2_x_pdx, add2_y_pdx])
+ proj.field_data["pdy"] = uconcatenate(
+ [proj.field_data["pdy"], add_x_pdy,
+ add_y_pdy, add2_x_pdy, add2_y_pdy])
+ proj.field_data[proj_field] = uconcatenate(
+ [proj.field_data[proj_field], add_x_field,
+ add_y_field, add2_x_field, add2_y_field])
+ proj.field_data["weight_field"] = uconcatenate(
+ [proj.field_data["weight_field"],
+ add_x_weight_field, add_y_weight_field,
+ add2_x_weight_field, add2_y_weight_field])
# Delete original copies of hanging cells.
del add_x_px, add_y_px, add2_x_px, add2_y_px
https://bitbucket.org/yt_analysis/yt/commits/e6ab9d909aad/
Changeset: e6ab9d909aad
User: brittonsmith
Date: 2017-09-30 00:25:38+00:00
Summary: Adding light cone test.
Affected #: 2 files
diff -r 5de1905a866d03e4eb4c3ac3b507eb3e6d9b2b37 -r e6ab9d909aada8d42578373f450bdec8303151b8 yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
--- /dev/null
+++ b/yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
@@ -0,0 +1,81 @@
+"""
+light cone generator test
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2017, 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.
+#-----------------------------------------------------------------------------
+
+import h5py
+import numpy as np
+import os
+import shutil
+import tempfile
+
+from yt.analysis_modules.cosmological_observation.api import \
+ LightCone
+from yt.testing import \
+ assert_equal
+from yt.utilities.answer_testing.framework import \
+ AnswerTestingTest, \
+ data_dir_load, \
+ requires_sim
+
+ETC = "enzo_tiny_cosmology/32Mpc_32.enzo"
+
+class LightConeProjectionTest(AnswerTestingTest):
+ _type_name = "LightConeProjection"
+ _attrs = ()
+
+ def __init__(self, parameter_file, simulation_type):
+ self.parameter_file = parameter_file
+ self.simulation_type = simulation_type
+ self.ds = os.path.basename(self.parameter_file)
+
+ @property
+ def storage_name(self):
+ return os.path.basename(self.parameter_file)
+
+ def run(self):
+ # Set up in a temp dir
+ tmpdir = tempfile.mkdtemp()
+ curdir = os.getcwd()
+ os.chdir(tmpdir)
+
+ lc = LightCone(
+ self.parameter_file, self.simulation_type, 0., 0.1,
+ observer_redshift=0.0, time_data=False)
+ lc.calculate_light_cone_solution(
+ seed=123456789, filename="LC/solution.txt")
+ lc.project_light_cone(
+ (600.0, "arcmin"), (60.0, "arcsec"), "density",
+ weight_field=None, save_stack=True)
+
+ fh = h5py.File("LC/LightCone.h5")
+ data = fh["density_None"].value
+ units = fh["density_None"].attrs["units"]
+ assert units == "g/cm**2"
+ fh.close()
+
+ # clean up
+ os.chdir(curdir)
+ shutil.rmtree(tmpdir)
+
+ mean = data.mean()
+ mi = data[data.nonzero()].min()
+ ma = data.max()
+ return np.array([mean, mi, ma])
+
+ def compare(self, new_result, old_result):
+ assert_equal(new_result, old_result, verbose=True)
+
+ at requires_sim(ETC, "Enzo")
+def test_light_cone_projection():
+ yield LightConeProjectionTest(ETC, "Enzo")
https://bitbucket.org/yt_analysis/yt/commits/20b0db0e2675/
Changeset: 20b0db0e2675
User: brittonsmith
Date: 2017-09-30 00:28:18+00:00
Summary: Updating tests.yaml.
Affected #: 1 file
diff -r e6ab9d909aada8d42578373f450bdec8303151b8 -r 20b0db0e26752d8281d1ea8edfccbec55804f711 tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -117,6 +117,9 @@
local_particle_trajectory_000:
- yt/data_objects/tests/test_particle_trajectories.py
+ local_light_cone_001:
+ - yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
+
other_tests:
unittests:
- '--exclude=test_mesh_slices' # disable randomly failing test
https://bitbucket.org/yt_analysis/yt/commits/346ce1e899ca/
Changeset: 346ce1e899ca
User: brittonsmith
Date: 2017-09-30 21:24:17+00:00
Summary: Remove import.
Affected #: 1 file
diff -r 20b0db0e26752d8281d1ea8edfccbec55804f711 -r 346ce1e899ca501356ab917c94427c57a87f5c87 yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
@@ -25,7 +25,6 @@
assert_equal
from yt.utilities.answer_testing.framework import \
AnswerTestingTest, \
- data_dir_load, \
requires_sim
ETC = "enzo_tiny_cosmology/32Mpc_32.enzo"
https://bitbucket.org/yt_analysis/yt/commits/da7a73a095a1/
Changeset: da7a73a095a1
User: brittonsmith
Date: 2017-10-02 17:22:10+00:00
Summary: Wrap test in requires_module decorator for h5py.
Affected #: 1 file
diff -r 346ce1e899ca501356ab917c94427c57a87f5c87 -r da7a73a095a166bc9b86c7958197078729fd2765 yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
@@ -13,7 +13,8 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-import h5py
+from yt.utilities.on_demand_imports import \
+ _h5py as h5py
import numpy as np
import os
import shutil
@@ -22,13 +23,15 @@
from yt.analysis_modules.cosmological_observation.api import \
LightCone
from yt.testing import \
- assert_equal
+ assert_equal, \
+ requires_module
from yt.utilities.answer_testing.framework import \
AnswerTestingTest, \
requires_sim
ETC = "enzo_tiny_cosmology/32Mpc_32.enzo"
-
+
+ at requires_module("h5py")
class LightConeProjectionTest(AnswerTestingTest):
_type_name = "LightConeProjection"
_attrs = ()
https://bitbucket.org/yt_analysis/yt/commits/6822b5ab984f/
Changeset: 6822b5ab984f
User: jzuhone
Date: 2017-10-16 20:10:37+00:00
Summary: Merge pull request #1574 from brittonsmith/lcfix
[bugfix] fix units in light cone projection
Affected #: 4 files
diff -r 4ab03e728eed8390f8a1b11c4057b0c58f7f8130 -r 6822b5ab984f0a2c1426eeec6421aeb3bf2ee818 tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -118,6 +118,9 @@
local_particle_trajectory_000:
- yt/data_objects/tests/test_particle_trajectories.py
+ local_light_cone_001:
+ - yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
+
other_tests:
unittests:
- '--exclude=test_mesh_slices' # disable randomly failing test
diff -r 4ab03e728eed8390f8a1b11c4057b0c58f7f8130 -r 6822b5ab984f0a2c1426eeec6421aeb3bf2ee818 yt/analysis_modules/cosmological_observation/light_cone/light_cone_projection.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/light_cone_projection.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/light_cone_projection.py
@@ -17,6 +17,8 @@
from yt.funcs import \
mylog
+from yt.units.yt_array import \
+ uconcatenate
from yt.visualization.fixed_resolution import \
FixedResolutionBuffer
from yt.utilities.parallel_tools.parallel_analysis_interface import \
@@ -198,25 +200,25 @@
del add_y_left
# Add the hanging cells back to the projection data.
- proj.field_data["px"] = proj.field_data["px"].unit_quantity * \
- np.concatenate([proj.field_data["px"].d, add_x_px.d, add_y_px.d,
- add2_x_px.d, add2_y_px.d])
- proj.field_data["py"] = proj.field_data["py"].unit_quantity * \
- np.concatenate([proj.field_data["py"].d, add_x_py.d, add_y_py.d,
- add2_x_py.d, add2_y_py.d])
- proj.field_data["pdx"] = proj.field_data["pdx"].unit_quantity * \
- np.concatenate([proj.field_data["pdx"].d, add_x_pdx.d, add_y_pdx.d,
- add2_x_pdx.d, add2_y_pdx.d])
- proj.field_data["pdy"] = proj.field_data["pdy"].unit_quantity * \
- np.concatenate([proj.field_data["pdy"].d, add_x_pdy.d, add_y_pdy.d,
- add2_x_pdy.d, add2_y_pdy.d])
- proj.field_data[proj_field] = proj.field_data["pdy"].unit_quantity * \
- np.concatenate([proj.field_data[proj_field].d, add_x_field.d, add_y_field.d,
- add2_x_field.d, add2_y_field.d])
- proj.field_data["weight_field"] = proj.field_data["weight_field"].unit_quantity * \
- np.concatenate([proj.field_data["weight_field"].d,
- add_x_weight_field.d, add_y_weight_field.d,
- add2_x_weight_field.d, add2_y_weight_field.d])
+ proj.field_data["px"] = uconcatenate(
+ [proj.field_data["px"], add_x_px,
+ add_y_px, add2_x_px, add2_y_px])
+ proj.field_data["py"] = uconcatenate(
+ [proj.field_data["py"], add_x_py,
+ add_y_py, add2_x_py, add2_y_py])
+ proj.field_data["pdx"] = uconcatenate(
+ [proj.field_data["pdx"], add_x_pdx,
+ add_y_pdx, add2_x_pdx, add2_y_pdx])
+ proj.field_data["pdy"] = uconcatenate(
+ [proj.field_data["pdy"], add_x_pdy,
+ add_y_pdy, add2_x_pdy, add2_y_pdy])
+ proj.field_data[proj_field] = uconcatenate(
+ [proj.field_data[proj_field], add_x_field,
+ add_y_field, add2_x_field, add2_y_field])
+ proj.field_data["weight_field"] = uconcatenate(
+ [proj.field_data["weight_field"],
+ add_x_weight_field, add_y_weight_field,
+ add2_x_weight_field, add2_y_weight_field])
# Delete original copies of hanging cells.
del add_x_px, add_y_px, add2_x_px, add2_y_px
diff -r 4ab03e728eed8390f8a1b11c4057b0c58f7f8130 -r 6822b5ab984f0a2c1426eeec6421aeb3bf2ee818 yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
--- /dev/null
+++ b/yt/analysis_modules/cosmological_observation/light_cone/tests/test_light_cone.py
@@ -0,0 +1,83 @@
+"""
+light cone generator test
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2017, 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.utilities.on_demand_imports import \
+ _h5py as h5py
+import numpy as np
+import os
+import shutil
+import tempfile
+
+from yt.analysis_modules.cosmological_observation.api import \
+ LightCone
+from yt.testing import \
+ assert_equal, \
+ requires_module
+from yt.utilities.answer_testing.framework import \
+ AnswerTestingTest, \
+ requires_sim
+
+ETC = "enzo_tiny_cosmology/32Mpc_32.enzo"
+
+ at requires_module("h5py")
+class LightConeProjectionTest(AnswerTestingTest):
+ _type_name = "LightConeProjection"
+ _attrs = ()
+
+ def __init__(self, parameter_file, simulation_type):
+ self.parameter_file = parameter_file
+ self.simulation_type = simulation_type
+ self.ds = os.path.basename(self.parameter_file)
+
+ @property
+ def storage_name(self):
+ return os.path.basename(self.parameter_file)
+
+ def run(self):
+ # Set up in a temp dir
+ tmpdir = tempfile.mkdtemp()
+ curdir = os.getcwd()
+ os.chdir(tmpdir)
+
+ lc = LightCone(
+ self.parameter_file, self.simulation_type, 0., 0.1,
+ observer_redshift=0.0, time_data=False)
+ lc.calculate_light_cone_solution(
+ seed=123456789, filename="LC/solution.txt")
+ lc.project_light_cone(
+ (600.0, "arcmin"), (60.0, "arcsec"), "density",
+ weight_field=None, save_stack=True)
+
+ fh = h5py.File("LC/LightCone.h5")
+ data = fh["density_None"].value
+ units = fh["density_None"].attrs["units"]
+ assert units == "g/cm**2"
+ fh.close()
+
+ # clean up
+ os.chdir(curdir)
+ shutil.rmtree(tmpdir)
+
+ mean = data.mean()
+ mi = data[data.nonzero()].min()
+ ma = data.max()
+ return np.array([mean, mi, ma])
+
+ def compare(self, new_result, old_result):
+ assert_equal(new_result, old_result, verbose=True)
+
+ at requires_sim(ETC, "Enzo")
+def test_light_cone_projection():
+ yield LightConeProjectionTest(ETC, "Enzo")
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