yt-project / yt

Main yt repository
http://yt-project.org
Other
454 stars 272 forks source link

unexpected behavior when using covering_grid on amrex dataset with variable refinement ratio #2811

Open darylbond opened 3 years ago

darylbond commented 3 years ago

Bug report

Bug summary

Loading an amrex dataset with variable refinement ratio leads to incorrect data access when using covering_grid.

Code for reproduction

import pylab as plt
import numpy as np
import yt
from yt.frontends.boxlib.data_structures import AMReXDataset
yt.funcs.mylog.setLevel(0)  # suppress output from yt

ds = yt.load("Riemann.plt00095")

left = ds.domain_left_edge
right = ds.domain_right_edge
size = ds.domain_dimensions
refinement = int(np.product(ds.ref_factors))
dx = (right - left) / (size*refinement)
size[0] *= refinement

cg = ds.covering_grid(2, left, size)

rho = cg[('boxlib', 'density-MHD')][:,0,0]

x = np.arange(float(left[0]) + float(dx[0]) / 2.0, float(right[0]), float(dx[0]))

plt.plot(x, rho)
plt.savefig("plot.png")
plt.show()

yt-test.zip

Actual outcome

plot

Expected outcome

The output data should be continuous without zero values throughout.

Version Information

neutrinoceros commented 3 years ago

Hi @darybond

dataset with variable refinement ratio

If I'm reading this right, I don't think yt supports this kind of data at all at the moment. A dataset is attached a single integer attribute ds.refine_by (usually 2). Supporting this wouldn't be a trivial change, but in the mean time maybe we can at least add a user-visible warning that this is expected to fail ? Do you get any correct-looking results with methods other than ds.covering_grid() ? I actually except everything else to break as well, in which case it should probably just error out at load time until we explicitly add support for this.

darylbond commented 3 years ago

I am fairly new to yt and so haven't really got a feel for other methods of extracting data yet, I'll have a poke around.

neutrinoceros commented 3 years ago

For instance, could you try simple plot functions such as yt.ProjectionPlot (or yt.ParticleProjectionPlot depending on the kind of data you have here) ?

neutrinoceros commented 3 years ago

hi @darylbond , any update on this ?