[yt-users] Radial-averaged Profile error

Junhwan Choi (최준환) choi.junhwan at gmail.com
Mon Dec 14 15:00:46 PST 2015


Dear yt users and developers,

I get an error while I try to make a  radial-averaged  profile using yt.
In order to compute the profile I wrote the following script:
===================================
import matplotlib as matplotlib
matplotlib.use('Agg')
import yt
import yt.units as units
import numpy as np
import matplotlib.pyplot as plt

def _radiuspc(field, data):
    return data[('radius')].in_units('pc')
yt.add_field('radiuspc', function=_radiuspc, units="pc")

rmax = 1000
Nbin = 50
ds = yt.load("../DD0099/DD0099")
ds.index
ad= ds.all_data()

center = ds.find_max("density")[1]
my_sphere = ds.sphere("center", (rmax, "pc"))

rmin = max([0.1,2.0*ds.index.get_smallest_dx().in_units('pc')])
profile = yt.BinnedProfile1D(my_sphere, Nbin, 'radius', rmin,
rmax*units.pc, log_space=True, end_collect=False)
profile.add_fields(('gas','density'), weight='cell_volume')

plt.plot(na.log10(profile['radius']), na.log10(profile['density']))
plt.savefig('ProfGasDensity')
===================================

And, I get an following error to compute the density profile
…….
yt : [INFO     ] 2015-12-14 17:54:21,484 Max Value is 5.46111e-09 at
0.5093630427891190 0.4991425970893048 0.5065899804849306
Traceback (most recent call last):
  File "test_prof.py", line 26, in <module>
    profile.add_fields(('gas','density'), weight='cell_volume')
  File "/home/jhchoi/common-anaconda/src/yt/yt/data_objects/profiles.py",
line 117, in add_fields
    self["%s_std" % field] = np.sqrt(std_data[field])
TypeError: not all arguments converted during string formatting

Could anyone inform me how to resolve this error?

Thank you in advance,
Junhwan



More information about the yt-users mailing list