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] annotate_sphere radius depends on choice of center #5062

Open
cphyc opened this issue Nov 22, 2024 · 2 comments · May be fixed by #5063
Open

[BUG] annotate_sphere radius depends on choice of center #5062

cphyc opened this issue Nov 22, 2024 · 2 comments · May be fixed by #5063

Comments

@cphyc
Copy link
Member

cphyc commented Nov 22, 2024

Bug report

Bug summary

When annotating plots with a sphere, the apparent size of the sphere depends on the units of the center of the plot.

Code for reproduction

import yt
import numpy as np

ds = yt.load_sample("output_00080")

rad = ds.quan(200, "kpccm/h")
# Option 1
center = ds.arr(ds.all_data().argmax("density"))
# Option 2
center = ds.arr(ds.all_data().argmax("density")).in_units("code_length")
# Option 3
center = ds.arr(ds.all_data().argmax("density")).in_units("Mpccm/h")
sp = ds.sphere(center, 2*rad)

p = yt.ProjectionPlot(
    ds,
    "x",
    ("gas", "density"),
    center=center,
    width=rad * 2,
    data_source=sp,
    origin="native",
)
p.annotate_sphere(center, rad, circle_args={"color": "white"})
p.set_axes_unit("Mpccm/h")
p.save("/tmp/")

Actual outcome

Option Outcome
1 info_00080_Projection_x_density
2 info_00080_Projection_x_density
3 info_00080_Projection_x_density

Expected outcome

All three images should be the same.

@cphyc cphyc added the bug label Nov 22, 2024
@neutrinoceros
Copy link
Member

It looks exactly as if input units are completely ignored and code units are assumed in all cases.

@cphyc
Copy link
Member Author

cphyc commented Nov 22, 2024

Found the issue!

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