TypeError: only length-1 arrays can be converted to Python scalars

Hello yt-users, I'm trying to read 2D flash data using a disk data object. The code is the following: import yt import numpy as np import matplotlib.pyplot as plt def angular_velocity(x,y,vx,vy): r=np.sqrt(x**2+y**2) theta=np.arctan2(y/x) w=(-vx*np.sin(theta)+vy*np.cos(theta))/r return w data_f="/home/guido/FLASH4.5/object/qsub/" data_name="rotator_mhd_2d_hdf5_chk_0015" property="density" field="dynamical_time" ds=yt.load(data_f+data_name) disk=ds.disk(ds.domain_center,[0.0,0.0,1.0],(ds.domain_ center/2.0,'cm'),(1,'cm')) time=ds.current_time.in_units("yr") print("field list \n:",ds.field_list) rp1=yt.create_profile(disk,'radius','temp') And the error I got is: yt : [INFO ] 2018-04-25 19:30:40,053 Particle file found: rotator_mhd_2d_hdf5_chk_0015 yt : [INFO ] 2018-04-25 19:30:40,079 Parameters: current_time = 0.75008895406 yt : [INFO ] 2018-04-25 19:30:40,079 Parameters: domain_dimensions = [8 8 1] yt : [INFO ] 2018-04-25 19:30:40,080 Parameters: domain_left_edge = [ 0. 0. 0.] yt : [INFO ] 2018-04-25 19:30:40,080 Parameters: domain_right_edge = [ 1. 1. 1.] yt : [INFO ] 2018-04-25 19:30:40,080 Parameters: cosmological_simulation = 0.0 Traceback (most recent call last): File "plot_ang.py", line 28, in <module> rp1=yt.create_profile(disk,'radius','temp') File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/profiles.py", line 1034, in create_profile for f, l in zip(bin_fields, logs)] File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/profiles.py", line 1034, in <listcomp> for f, l in zip(bin_fields, logs)] File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/derived_quantities.py", line 511, in __call__ rv = super(Extrema, self).__call__(fields, non_zero) File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/derived_quantities.py", line 66, in __call__ for sto, ds in parallel_objects(chunks, -1, storage = storage): File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 507, in parallel_objects for result_id, obj in oiter: File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/data_containers.py", line 1223, in chunks self.get_data() # Ensure we have built ourselves File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/data_containers.py", line 1266, in get_data self.index._identify_base_chunk(self) File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/geometry/grid_geometry_handler.py", line 293, in _identify_base_chunk gi = dobj.selector.select_grids(self.grid_left_edge, File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/data_containers.py", line 1218, in selector self._selector = sclass(self) File "yt/geometry/selection_routines.pyx", line 1006, in yt.geometry.selection_routines.DiskSelector.__init__ TypeError: only length-1 arrays can be converted to Python scalars I am using : yt ,3.4.1 ,py35_0 And the output of the statistics of the input file used is: $ yt stats ~/FLASH4.5/wind_tunnel/qsub_folder/windtunnel_4lev_hdf5_chk_0000 yt : [INFO ] 2018-04-25 19:33:56,124 Particle file found: windtunnel_4lev_hdf5_chk_0000 yt : [INFO ] 2018-04-25 19:33:56,149 Parameters: current_time = 0.0 yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: domain_dimensions = [120 40 1] yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: domain_left_edge = [ 0. 0. 0.] yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: domain_right_edge = [ 3. 1. 1.] yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: cosmological_simulation = 0.0 level # grids # cells # cells^3 ---------------------------------------------- 0 63 4032 16 ---------------------------------------------- 63 4032 t = 0.00000000e+00 = 0.00000000e+00 s = 0.00000000e+00 years Smallest Cell: Width: 8.102e-27 Mpc Width: 8.102e-21 pc Width: 1.671e-15 AU Width: 2.500e-02 cm Could you please help me to find out what I am doing wrong, I'm new to this yt version. Kind Regards, -- Guido

Hi Guido, On Wed, Apr 25, 2018 at 7:36 PM Guido granda muñoz <guidogranda@gmail.com> wrote:
Hello yt-users, I'm trying to read 2D flash data using a disk data object. The code is the following:
import yt import numpy as np import matplotlib.pyplot as plt
def angular_velocity(x,y,vx,vy): r=np.sqrt(x**2+y**2) theta=np.arctan2(y/x) w=(-vx*np.sin(theta)+vy*np.cos(theta))/r return w
data_f="/home/guido/FLASH4.5/object/qsub/" data_name="rotator_mhd_2d_hdf5_chk_0015"
property="density" field="dynamical_time"
ds=yt.load(data_f+data_name)
disk=ds.disk(ds.domain_center,[0.0,0.0,1.0],(ds.domain_center/2.0,'cm'),(1,'cm'))
I think the error is coming from right here. ds.domain_center is a three-element array, but the radius should be a scalar. Something like this: disk=ds.disk(ds.domain_center,[0.0,0.0,1.0],(0.5, 'cm'),(1, 'cm')) If that fixes the issue I'd appreciate it if you could file an issue in our bug tracker as a reminder to make a better message for this situation. We should do some error checking in the initializer for the disk data object to create a more friendly error message. You can file an issue by filling out the form here: https://github.com/yt-project/yt/issues/new
time=ds.current_time.in_units("yr") print("field list \n:",ds.field_list) rp1=yt.create_profile(disk,'radius','temp')
And the error I got is:
yt : [INFO ] 2018-04-25 19:30:40,053 Particle file found: rotator_mhd_2d_hdf5_chk_0015 yt : [INFO ] 2018-04-25 19:30:40,079 Parameters: current_time = 0.75008895406 yt : [INFO ] 2018-04-25 19:30:40,079 Parameters: domain_dimensions = [8 8 1] yt : [INFO ] 2018-04-25 19:30:40,080 Parameters: domain_left_edge = [ 0. 0. 0.] yt : [INFO ] 2018-04-25 19:30:40,080 Parameters: domain_right_edge = [ 1. 1. 1.] yt : [INFO ] 2018-04-25 19:30:40,080 Parameters: cosmological_simulation = 0.0 Traceback (most recent call last): File "plot_ang.py", line 28, in <module> rp1=yt.create_profile(disk,'radius','temp') File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/profiles.py", line 1034, in create_profile for f, l in zip(bin_fields, logs)] File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/profiles.py", line 1034, in <listcomp> for f, l in zip(bin_fields, logs)] File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/derived_quantities.py", line 511, in __call__ rv = super(Extrema, self).__call__(fields, non_zero) File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/derived_quantities.py", line 66, in __call__ for sto, ds in parallel_objects(chunks, -1, storage = storage): File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 507, in parallel_objects for result_id, obj in oiter: File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/data_containers.py", line 1223, in chunks self.get_data() # Ensure we have built ourselves File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/data_containers.py", line 1266, in get_data self.index._identify_base_chunk(self) File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/geometry/grid_geometry_handler.py", line 293, in _identify_base_chunk gi = dobj.selector.select_grids(self.grid_left_edge, File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/data_containers.py", line 1218, in selector self._selector = sclass(self) File "yt/geometry/selection_routines.pyx", line 1006, in yt.geometry.selection_routines.DiskSelector.__init__ TypeError: only length-1 arrays can be converted to Python scalars
I am using : yt ,3.4.1 ,py35_0
And the output of the statistics of the input file used is:
$ yt stats ~/FLASH4.5/wind_tunnel/qsub_folder/windtunnel_4lev_hdf5_chk_0000
yt : [INFO ] 2018-04-25 19:33:56,124 Particle file found: windtunnel_4lev_hdf5_chk_0000 yt : [INFO ] 2018-04-25 19:33:56,149 Parameters: current_time = 0.0 yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: domain_dimensions = [120 40 1] yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: domain_left_edge = [ 0. 0. 0.] yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: domain_right_edge = [ 3. 1. 1.] yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: cosmological_simulation = 0.0 level # grids # cells # cells^3 ---------------------------------------------- 0 63 4032 16 ---------------------------------------------- 63 4032
t = 0.00000000e+00 = 0.00000000e+00 s = 0.00000000e+00 years
Smallest Cell: Width: 8.102e-27 Mpc Width: 8.102e-21 pc Width: 1.671e-15 AU Width: 2.500e-02 cm
Could you please help me to find out what I am doing wrong, I'm new to this yt version.
Kind Regards,
-- Guido _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org

On Wed, Apr 25, 2018 at 8:12 PM Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Guido,
On Wed, Apr 25, 2018 at 7:36 PM Guido granda muñoz <guidogranda@gmail.com> wrote:
Hello yt-users, I'm trying to read 2D flash data using a disk data object. The code is the following:
import yt import numpy as np import matplotlib.pyplot as plt
def angular_velocity(x,y,vx,vy): r=np.sqrt(x**2+y**2) theta=np.arctan2(y/x) w=(-vx*np.sin(theta)+vy*np.cos(theta))/r return w
data_f="/home/guido/FLASH4.5/object/qsub/" data_name="rotator_mhd_2d_hdf5_chk_0015"
property="density" field="dynamical_time"
ds=yt.load(data_f+data_name)
disk=ds.disk(ds.domain_center,[0.0,0.0,1.0],(ds.domain_center/2.0,'cm'),(1,'cm'))
I think the error is coming from right here. ds.domain_center is a three-element array, but the radius should be a scalar. Something like this:
disk=ds.disk(ds.domain_center,[0.0,0.0,1.0],(0.5, 'cm'),(1, 'cm'))
If that fixes the issue I'd appreciate it if you could file an issue in our bug tracker as a reminder to make a better message for this situation. We should do some error checking in the initializer for the disk data object to create a more friendly error message.
You can file an issue by filling out the form here:
Since I haven't heard from Guido I went ahead and filed an issue about this: https://github.com/yt-project/yt/issues/1768
time=ds.current_time.in_units("yr") print("field list \n:",ds.field_list) rp1=yt.create_profile(disk,'radius','temp')
And the error I got is:
yt : [INFO ] 2018-04-25 19:30:40,053 Particle file found: rotator_mhd_2d_hdf5_chk_0015 yt : [INFO ] 2018-04-25 19:30:40,079 Parameters: current_time = 0.75008895406 yt : [INFO ] 2018-04-25 19:30:40,079 Parameters: domain_dimensions = [8 8 1] yt : [INFO ] 2018-04-25 19:30:40,080 Parameters: domain_left_edge = [ 0. 0. 0.] yt : [INFO ] 2018-04-25 19:30:40,080 Parameters: domain_right_edge = [ 1. 1. 1.] yt : [INFO ] 2018-04-25 19:30:40,080 Parameters: cosmological_simulation = 0.0 Traceback (most recent call last): File "plot_ang.py", line 28, in <module> rp1=yt.create_profile(disk,'radius','temp') File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/profiles.py", line 1034, in create_profile for f, l in zip(bin_fields, logs)] File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/profiles.py", line 1034, in <listcomp> for f, l in zip(bin_fields, logs)] File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/derived_quantities.py", line 511, in __call__ rv = super(Extrema, self).__call__(fields, non_zero) File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/derived_quantities.py", line 66, in __call__ for sto, ds in parallel_objects(chunks, -1, storage = storage): File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 507, in parallel_objects for result_id, obj in oiter: File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/data_containers.py", line 1223, in chunks self.get_data() # Ensure we have built ourselves File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/data_containers.py", line 1266, in get_data self.index._identify_base_chunk(self) File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/geometry/grid_geometry_handler.py", line 293, in _identify_base_chunk gi = dobj.selector.select_grids(self.grid_left_edge, File "/home/guido/.conda/envs/kuro/lib/python3.5/site-packages/yt/data_objects/data_containers.py", line 1218, in selector self._selector = sclass(self) File "yt/geometry/selection_routines.pyx", line 1006, in yt.geometry.selection_routines.DiskSelector.__init__ TypeError: only length-1 arrays can be converted to Python scalars
I am using : yt ,3.4.1 ,py35_0
And the output of the statistics of the input file used is:
$ yt stats ~/FLASH4.5/wind_tunnel/qsub_folder/windtunnel_4lev_hdf5_chk_0000
yt : [INFO ] 2018-04-25 19:33:56,124 Particle file found: windtunnel_4lev_hdf5_chk_0000 yt : [INFO ] 2018-04-25 19:33:56,149 Parameters: current_time = 0.0 yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: domain_dimensions = [120 40 1] yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: domain_left_edge = [ 0. 0. 0.] yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: domain_right_edge = [ 3. 1. 1.] yt : [INFO ] 2018-04-25 19:33:56,150 Parameters: cosmological_simulation = 0.0 level # grids # cells # cells^3 ---------------------------------------------- 0 63 4032 16 ---------------------------------------------- 63 4032
t = 0.00000000e+00 = 0.00000000e+00 s = 0.00000000e+00 years
Smallest Cell: Width: 8.102e-27 Mpc Width: 8.102e-21 pc Width: 1.671e-15 AU Width: 2.500e-02 cm
Could you please help me to find out what I am doing wrong, I'm new to this yt version.
Kind Regards,
-- Guido _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org

Hello Nathan, Sorry for the delay. You were right the error was caused by the using ds.domain_center instead of an scalar, and as you said the error message wasn't that helpful, so it is a good idea to change those error messages. Thanks,
participants (3)
-
Guido granda muñoz
-
Guido Granda Muñoz
-
Nathan Goldbaum