Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Off-axis projections and on-axis projections differ for oct-based datasets #5071

Closed
cphyc opened this issue Dec 2, 2024 · 0 comments · Fixed by #5077
Closed

[BUG] Off-axis projections and on-axis projections differ for oct-based datasets #5071

cphyc opened this issue Dec 2, 2024 · 0 comments · Fixed by #5077

Comments

@cphyc
Copy link
Member

cphyc commented Dec 2, 2024

Bug report

Bug summary

Copied from #5059
OK - I've actually uncovered a funny one.

import numpy as np
import yt
import matplotlib.pyplot as plt
ds = yt.load("output_00080")
p1 = yt.ProjectionPlot(
    ds,
    "x",
    ("gas", "density"),
    center=[0.5] * 3,
    width=.8,
    #weight_field=("gas", "density"),
)
p2 = yt.OffAxisProjectionPlot(
    ds,
    [1, 0, 0],
    ("gas", "density"),
    center=[0.5] * 3,
    width=.8,
    #weight_field=("gas", "density"),
)

# Note: due to our implementation, the off-axis projection will have a
# slightly blurred cell edges so we can't do an exact comparison
v1, v2 = p1.frb["gas", "density"], p2.frb["gas", "density"]

fig = plt.figure()
plt.imshow(v1, origin="lower", norm=plt.matplotlib.colors.LogNorm())
plt.colorbar()
fig.savefig("/tmp/1.png")

fig = plt.figure()
plt.imshow(v2, origin="lower", norm=plt.matplotlib.colors.LogNorm())
plt.colorbar()
fig.savefig("/tmp/2.png")

fig = plt.figure()
plt.imshow(v1 / v2, origin="lower")
plt.colorbar()
fig.savefig("/tmp/3.png")
print(np.median(v1 / v2), np.mean(v1 / v2), np.std(v1 / v2))

This returns:

Projection Off-axis projection Difference
1 2 3

The funny thing is that the ratio between the on-axis and the off-axis projection is equal (within some uncertainties) to plot_width * 0.5675 (above, plot_width = 0.8). This is the case for a RAMSES dataset (here), but the same can be obtained using fake_random_ds instead, yielding the same value.

As much as I see how I could have missed a plot_width factor, what the heck is 0.5675?

Expected outcome

Both the projection and off-axis projection should be the same map (up to small differences).
This bug was most likely introduced in #4741.

Version Information

  • yt version: 4.4 and above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants