Open clochhaas opened 1 year ago
Hi, and welcome to yt! Thanks for opening your first issue. We have an issue template that helps us to gather relevant information to help diagnosing and fixing the issue.
Thanks @clochhaas for reporting this in such details ! I tried to reproduce this with a simple test dataset
from yt.testing import fake_amr_ds
ds = fake_amr_ds(fields=[("gas", "density"), ("gas", "velocity_x")], units=["g/cm**3", "cm/s"])`)
and the behaviour seems correct there (there are potentially other issues, but not the ones you're seeing with Enzo data).
Therefore I suspect this may be a frontend-specific bug. I'll investigate further
So I discovered that there's an important difference between how units are determined for on-axis projections and off-axis ones when creating the underlying "image array" (a 2D buffer with units):
Unfortunately the "dirty no-good" hack doesn't work for off-axis projections, because a OffAxisProjectionDummyDataSource
isn't subscriptable (it lacks support for __getitem__
).
I think the bug is showing the limits of the pile of hacks that currently is the backbone of off-axis projections in yt. I'm quite out of my depth on this one, so I don't think I'll be able to quickly patch it as I initially hoped...
@clochhaas i cannot promise I will get to this before next week, but soon.
Bug report
Bug summary
When making off-axis projection plots using a user-defined velocity field in units of km/s, the plot gives values that are in cm/s instead of km/s and setting the units for the field in the projection plot doesn't change the behavior.
Code for reproduction
This code uses the enzo_tiny_cosmology public dataset.
Actual outcome
axis-aligned_user-defined-field.png:
off-axis_user-defined-field.png:
off-axis_default-field.png:
off-axis_user-defined-field-cm.png:
Expected outcome
The expected outcome is that the second image above (off-axis_user-defined-field.png) should look the same as the fourth image (off-axis_user-defined-field-cm.png), rather than having values on the colorbar that are 5 orders of magnitude larger. The only difference between these two is that the user-defined field is given different units in the call to ds.add_field.
Version Information
yt and python were both installed from conda, using the conda-forge channel.