You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For datasets in spherical coordinates, plotting a poloidal slice (i.e in the "R, z", "phi"-normal plane) can produce very visible moirés patterns. This effect seems to be strongest when the latitudinal domain is narrow, and not noticeable for sufficiently large domains.
This problem appears on yt 4.0.2 and on the dev branch, but it seems to be absent with 4.0.1 version, which was buggy in a different way (plot limits are not being calculated correctly)
Precisely, the problem bisects to ea10a37 (#3533).
So I'm hesitant to call this a regression because the pixelizer routine wasn't changed in this commit, only the plot limits calculation was affected. I believe the patch only made this problem apparent but that it was already present in yt 4.0.1
A possibility I want to explore is that the pixelizer may be doing something wrong when pixels are far from being squares. Indeed the default buffer (800x800) size is most appropriate for square pictures. Right now it's a little hard to test because the SlicePlot.set_buff_size method seems to be broken too (it affects the plot limits but it shouldn't). I note however than the effect can be mitigated on the user side by reducing the buffer resolution, which still works for square buffers :
Had a look at the pixelizer and found that the implementation may be excessively eager:
reducing what looks to me like an arbitrary jump as follow makes the problem disappear (for the default buffer resolution)
diff --git a/yt/utilities/lib/pixelization_routines.pyx b/yt/utilities/lib/pixelization_routines.pyx
index 18c35bc59..2d3571914 100644
--- a/yt/utilities/lib/pixelization_routines.pyx+++ b/yt/utilities/lib/pixelization_routines.pyx@@ -570,7 +570,7 @@ def pixelize_cylinder(np.float64_t[:,:] buff,
continue
theta_i = theta0 - dtheta_i
# Buffer of 0.5 here
- dthetamin = 0.5*dx/(r0 + dr_i)+ dthetamin = 0.1*dx/(r0 + dr_i)
while theta_i < theta0 + dtheta_i:
r_i = r0 - dr_i
costheta = math.cos(theta_i)
@@ -586,7 +586,7 @@ def pixelize_cylinder(np.float64_t[:,:] buff,
if pi >= 0 and pi < buff.shape[0] and \
pj >= 0 and pj < buff.shape[1]:
buff[pi, pj] = field[i]
- r_i += 0.5*dx+ r_i += 0.1*dx
theta_i += dthetamin
The issue with this patch is that it is still arbitrarily eager and I expect it to break for high resolution images. It's also a performance regression for existing cases. I'm sure the correct solution is to tune these increments in a more robust way.
Bug report
Bug summary
For datasets in spherical coordinates, plotting a poloidal slice (i.e in the "R, z", "phi"-normal plane) can produce very visible moirés patterns. This effect seems to be strongest when the latitudinal domain is narrow, and not noticeable for sufficiently large domains.
Code for reproduction
Going from widest to narrowest theta domains
Actual outcome
This problem appears on yt 4.0.2 and on the dev branch, but it seems to be absent with 4.0.1 version, which was buggy in a different way (plot limits are not being calculated correctly)
Precisely, the problem bisects to ea10a37 (#3533).
So I'm hesitant to call this a regression because the pixelizer routine wasn't changed in this commit, only the plot limits calculation was affected. I believe the patch only made this problem apparent but that it was already present in yt 4.0.1
A possibility I want to explore is that the pixelizer may be doing something wrong when pixels are far from being squares. Indeed the default buffer (800x800) size is most appropriate for square pictures. Right now it's a little hard to test because the
SlicePlot.set_buff_size
method seems to be broken too (it affects the plot limits but it shouldn't). I note however than the effect can be mitigated on the user side by reducing the buffer resolution, which still works for square buffers :this problem was first discovered downstream in neutrinoceros/yt_idefix#86
The text was updated successfully, but these errors were encountered: