[yt-svn] commit/yt: xarthisius: Merged in MatthewTurk/yt (pull request #2278)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Jul 16 09:00:52 PDT 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/acc390b0a7fe/
Changeset: acc390b0a7fe
Branch: yt
User: xarthisius
Date: 2016-07-16 16:00:24+00:00
Summary: Merged in MatthewTurk/yt (pull request #2278)
Add grid_levels and grid_indices to octrees. Closes #993.
Affected #: 2 files
diff -r d893be12e55c80f5fce09fe679cd570b0b7cc1f3 -r acc390b0a7fec1cb38db9030a9f0e22eac2dcbc2 yt/data_objects/tests/test_covering_grid.py
--- a/yt/data_objects/tests/test_covering_grid.py
+++ b/yt/data_objects/tests/test_covering_grid.py
@@ -56,7 +56,7 @@
# Now we test other attributes
yield assert_equal, cg["ones"].max(), 1.0
yield assert_equal, cg["ones"].min(), 1.0
- yield assert_equal, cg["grid_level"], 0
+ yield assert_equal, cg["grid_level"], level
yield assert_equal, cg["cell_volume"].sum(), ds.domain_width.prod()
for g in ds.index.grids:
di = g.get_global_startindex()
diff -r d893be12e55c80f5fce09fe679cd570b0b7cc1f3 -r acc390b0a7fec1cb38db9030a9f0e22eac2dcbc2 yt/fields/geometric_fields.py
--- a/yt/fields/geometric_fields.py
+++ b/yt/fields/geometric_fields.py
@@ -18,7 +18,6 @@
from .derived_field import \
ValidateParameter, \
- ValidateGridType, \
ValidateSpatial
from .field_functions import \
@@ -51,21 +50,33 @@
def _grid_level(field, data):
"""The AMR refinement level"""
- return np.ones(data.ActiveDimensions)*(data.Level)
+ arr = np.ones(data.ires.shape, dtype="float64")
+ arr *= data.ires
+ if data._spatial:
+ return data._reshape_vals(arr)
+ return arr
registry.add_field(("index", "grid_level"),
function=_grid_level,
units="",
- validators=[ValidateGridType(), ValidateSpatial(0)])
+ validators=[ValidateSpatial(0)])
def _grid_indices(field, data):
"""The index of the leaf grid the mesh cells exist on"""
- return np.ones(data["index", "ones"].shape)*(data.id-data._id_offset)
+ if hasattr(data, "domain_id"):
+ this_id = data.domain_id
+ else:
+ this_id = data.id - data._id_offset
+ arr = np.ones(data["index", "ones"].shape)
+ arr *= this_id
+ if data._spatial:
+ return data._reshape_vals(arr)
+ return arr
registry.add_field(("index", "grid_indices"),
function=_grid_indices,
units="",
- validators=[ValidateGridType(), ValidateSpatial(0)],
+ validators=[ValidateSpatial(0)],
take_log=False)
def _ones_over_dx(field, data):
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