diff --git a/yt/visualization/volume_rendering/off_axis_projection.py b/yt/visualization/volume_rendering/off_axis_projection.py index f31919de19..d733c74329 100644 --- a/yt/visualization/volume_rendering/off_axis_projection.py +++ b/yt/visualization/volume_rendering/off_axis_projection.py @@ -445,12 +445,14 @@ def temp_weightfield(field, data): # i.e. we ignore the z-component wmax = width[:2].max() # Recenter positions w.r.t. center of the plot window - xyz = np.stack( - [data_source["index", k] - center[i] for i, k in enumerate("xyz")], axis=-1 + xyz = data_source.ds.arr( + np.zeros((len(data_source[vol.field]), 3)), "code_length" ) # If we have periodic boundaries, we need to wrap the positions for idim, periodic in enumerate(data_source.ds.periodicity): + axis = "xyz"[idim] + xyz[..., idim] = data_source["index", axis] - center[idim] if not periodic: continue w = data_source.ds.domain_width[idim] @@ -458,8 +460,7 @@ def temp_weightfield(field, data): xyz[..., idim] = (xyz[..., idim] + w / 2) % w - w / 2 # Rescale to [-0.5, +0.5] - xyz /= wmax - xyz = xyz.to("1").d + xyz = (xyz / wmax).to("1").d dx = (data_source["index", "dx"] / wmax).to("1").d