Issue #966: Negative radius values in particle_spherical_position_radius fields (and some inconsistant values) (yt_analysis/yt)

New issue 966: Negative radius values in particle_spherical_position_radius fields (and some inconsistant values) https://bitbucket.org/yt_analysis/yt/issue/966/negative-radius-values-in Benjamin Thompson:
From discussion within this PR
[https://bitbucket.org/yt_analysis/yt/pull-request/1308/wip-particle_cylindrical_r-and/diff](https://bitbucket.org/yt_analysis/yt/pull-request/1308/wip-particle_cylindrical_r-and/diff) I have found that particle_spherical_position_radius (as well as my newly proposed particle_cylindrical_position_radius) produces negative radius values. ``` #!python sphere["particle_cylindrical_position_radius"].min() ``` -6.41156882532e+23 cm ``` #!python sphere["particle_spherical_position_radius"].min() ``` -7.83826739716e+23 cm wheras sphere["particle_spherical_radius"] does not ``` #!python sphere["particle_spherical_radius"].min() ``` 1.25498335796e+20 cm FYI particle_spherical_radius is more of a direct copy from how the fluid fields compute the spherical radius. Interestingly enough. Both these methods produce different results too. E.g ``` #!python sphere["particle_spherical_radius"][20] ``` returns 2.37463756333e+23 cm and ``` #!python sphere["particle_spherical_position_radius"][20] ``` returns 5.0064012169e+22 cm FYI the two different methods for calculating these radii are. For "spherical_position_radius" ``` #!python def _particle_spherical_position_radius(field, data): """ Radial component of the particles' position vectors in spherical coords on the provided field parameters for 'normal', 'center', 'bulk_velocity', """ normal = data.get_field_parameter('normal') center = data.get_field_parameter('center') bv = data.get_field_parameter("bulk_velocity") pos = spos pos = YTArray([data[ptype, pos % ax] for ax in "xyz"]) theta = get_sph_theta(pos, center) phi = get_sph_phi(pos, center) pos = pos - np.reshape(center, (3, 1)) sphr = get_sph_r_component(pos, theta, phi, normal) return sphr registry.add_field((ptype, "particle_spherical_position_radius"), function=_particle_spherical_position_radius, particle_type=True, units="cm", validators=[ValidateParameter("normal"), ValidateParameter("center")]) ``` and "spherical_radius" ``` #!python def _particle_radius(field, data): return get_radius(data, "particle_position_") registry.add_field((ptype, "particle_radius"), function=_particle_radius, validators=[ValidateParameter("center")], units="cm", particle_type = True, display_name = "Particle Radius") # this is just particle radius but add it for ease of use registry.add_field((ptype, "particle_spherical_radius"), function=_particle_radius, particle_type=True, units="cm", validators=[ValidateParameter("normal"), ValidateParameter("center")]) ``` I have noticed in the fluid gas fields, we are using instead. ``` #!python def _spherical_r(field, data): coords = get_periodic_rvec(data) return data.ds.arr(get_sph_r(coords), "code_length").in_cgs() ``` which returns positive radii as expected. So basically. Which "radius" calculation should be used for spherical radii? I am thinking a similar sort of manner as done in the fluid fields. In summary 1) Why are we getting negative radius for particle_spherical_position_radius 2) Why _______________________________________________ yt-dev mailing list yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
participants (1)
-
Benjamin Thompson