Issue #1163: particle angular momentum profile error (yt_analysis/yt)
New issue 1163: particle angular momentum profile error https://bitbucket.org/yt_analysis/yt/issues/1163/particle-angular-momentum-p... Anonymous: Hi yt developer I wrote the following script to compute the particle angular momentum =============================== import matplotlib as matplotlib matplotlib.use('Agg') import yt import yt.units as units import numpy as np import matplotlib.pyplot as plt def _partradiuspc(field, data): return data[('all','particle_radius')].in_units('pc') yt.add_field('partradiuspc', function=_partradiuspc, particle_type=True, units="pc") index = 45 Nbin= 100 rmax = 3000 ds = yt.load("../DD%04d/DD%04d" % (index,index)) ds.index ad= ds.all_data() center = ds.find_max(("gas", "density"))[1] rmin = max([1.0e-3,2.0*ds.index.get_smallest_dx().in_units('pc')]) sphere = ds.sphere(center, rmax*units.pc) bulk_velocity = sphere.quantities['BulkVelocity']() sphere.set_field_parameter('bulk_velocity', bulk_velocity) profile = yt.Profile1D(sphere, 'partradiuspc', Nbin, x_min=rmin, x_max=rmax, x_log=True, weight_field=None) profile.add_fields(('all', 'particle_angular_momentum_x')) profile.add_fields(('all', 'particle_angular_momentum_y')) profile.add_fields(('all', 'particle_angular_momentum_z')) PartAngularMomentum = np.sqrt(profile[('all', 'particle_angular_momentum_x')]**2 + profile[('all', 'particle_angular_momentum_y')]**2 + profile[('all', 'particle_angular_momentum_z')]**2) plt.plot(profile.x, PartAngularMomentum, label='Total',linestyle="-",color='r') plt.xlabel('r [pc]') plt.ylabel('pang') =================================== And, I got the following error message ……………… Traceback (most recent call last): File "pang.py", line 26, in <module> profile = yt.Profile1D(sphere, 'partradiuspc', Nbin, x_min=rmin, x_max=rmax, x_log=True, weight_field=None) File "/home/jhchoi/common/src/yt/yt/data_objects/profiles.py", line 411, in __init__ self.x_field = data_source._determine_fields(x_field)[0] File "/home/jhchoi/common/src/yt/yt/data_objects/data_containers.py", line 1001, in _determine_fields raise YTFieldNotFound((ftype,fname),self.ds) yt.utilities.exceptions.YTFieldNotFound: Could not find field '('all', 'partradiuspc')' in DD0045. If I remove "particle_type=True" in add_field, it works. However, I am not sure that removing "particle_type=True" return correct output. Thank you, Junhwan
participants (1)
-
Anonymous