import yt ds = yt.load(...) ad = ds.all_data() virial = ds.arr(1.4,'Mpc/h') sph = ds.sphere([.5,.5,.5],5.*virial) profile = yt.ProfilePlot(sph,'radius',('gas','temperature'),x_log=False,weight_field='cell_mass') rrvir = np.array(profile.profiles[0].x/virial)