[yt-dev] Issue #1029: PhasePlot fails for a user-added derived field with no field type (yt_analysis/yt)

Nathan Goldbaum issues-reply at bitbucket.org
Fri Jun 5 12:17:17 PDT 2015


New issue 1029: PhasePlot fails for a user-added derived field with no field type
https://bitbucket.org/yt_analysis/yt/issue/1029/phaseplot-fails-for-a-user-added-derived

Nathan Goldbaum:

This is illustrated by the following test script:


```
#!python
import yt

ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
def _mach_speed(field, data):
    return ((data["velocity_x"]**2 + data["velocity_y"]**2 + data["velocity_z"]**2)**(0.5) / (data["temperature"]**(0.5)))

ds.add_field("mach_speed", function=_mach_speed, units="cm*K**(-0.5)/s")

plot = yt.PhasePlot(ds.all_data(), 'density', 'mach_speed', 'cell_mass', weight_field=None)

plot.save()

```

which raises the following traceback:


```
#!python

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    plot = yt.PhasePlot(ds.all_data(), 'density', 'mach_speed', 'cell_mass', weight_field=None)
  File "/Users/goldbaum/Documents/yt-hg/yt/visualization/profile_plotter.py", line 724, in __init__
    fractional=fractional)
  File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/profiles.py", line 1436, in create_profile
    for f in bin_fields + fields]
  File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/static_output.py", line 540, in _get_field_info
    raise YTFieldNotFound((ftype, fname), self)
yt.utilities.exceptions.YTFieldNotFound: Could not find field '('all', ('gas', 'mach_speed'))' in galaxy0030.

```

If I replace `'mach_speed'` with `('gas', 'mach_speed')` in the call to `add_field`, this behaves as expected.





More information about the yt-dev mailing list