Off axis Slice Plot breaks when using derived field and default center
biboyd opened this issue · 1 comments
biboyd commented
Bug report
Bug summary
Creating an OffAxisSlicePlot
with a derived field (e.g. ('gas', 'radial_velocity')
yields an error unless the center is defined (e.g. center=ds.domain_center
).
Code for reproduction
Using IsolatedGalaxy dataset
import yt
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
yt.SlicePlot(ds, [0.5, 0., 0.5], ("gas", "radial_velocity"))
Actual outcome
Traceback (most recent call last):
File "/home/biboyd/workspace/yt_bug_fix/test_yt.py", line 4, in <module>
yt.SlicePlot(ds, [0.5, 0., 0.5], ("gas", "radial_velocity"))
File "/home/biboyd/Repo/my_yt/yt/visualization/plot_window.py", line 2238, in __init__
cutting.get_data(fields)
File "/home/biboyd/Repo/my_yt/yt/data_objects/selection_objects/data_selection_objects.py", line 220, in get_data
self._generate_fields(fields_to_generate)
File "/home/biboyd/Repo/my_yt/yt/data_objects/selection_objects/data_selection_objects.py", line 252, in _generate_fields
fd = self._generate_field(field)
File "/home/biboyd/Repo/my_yt/yt/data_objects/data_containers.py", line 273, in _generate_field
tr = self._generate_fluid_field(field)
File "/home/biboyd/Repo/my_yt/yt/data_objects/data_containers.py", line 291, in _generate_fluid_field
rv = finfo(gen_obj)
File "/home/biboyd/Repo/my_yt/yt/fields/derived_field.py", line 285, in __call__
dd = self._function(self, data)
File "/home/biboyd/Repo/my_yt/yt/fields/geometric_fields.py", line 175, in _spherical_theta
coords = get_periodic_rvec(data)
File "/home/biboyd/Repo/my_yt/yt/fields/field_functions.py", line 47, in get_periodic_rvec
coords = obtain_position_vector(data).d
File "yt/utilities/lib/misc_utilities.pyx", line 586, in yt.utilities.lib.misc_utilities.obtain_position_vector
AttributeError: 'str' object has no attribute 'to'
Expected outcome
Expected a Slice
Version Information
- Operating System: Ubuntu 22.04
- Python Version: 3.10.12
- yt version: 4.4.dev0 Changeset = c148f72
- Other Libraries (if applicable):
yt installed from source
chrishavlin commented
Thanks for the report, @biboyd ! Turned out to be a simple one-line fix I think. If you want to install from source to try it out while it awaits review, you can do:
pip install git+https://github.com/chrishavlin/yt.git@fix_off_axis_set_center