[yt-dev] Issue #775: Cannot generate isosurfaces of fields that depend on field parameters (yt_analysis/yt)
Nathan Goldbaum
issues-reply at bitbucket.org
Thu Feb 6 14:52:23 PST 2014
New issue 775: Cannot generate isosurfaces of fields that depend on field parameters
https://bitbucket.org/yt_analysis/yt/issue/775/cannot-generate-isosurfaces-of-fields-that
Nathan Goldbaum:
Currently in 3.0 isosurfaces that depend on field parameters cannot be generated.
As an example:
```
#!python
from yt.mods import *
pf = load('HiResIsolatedgalaxy/DD0044/DD0044')
dd = pf.h.disk('c', [0,0,1], (20, 'kpc'), (3, 'kpc'))
radii = (np.arange(100)+1)/100.*20
fluxes = []
for r in radii:
iso = pf.h.surface(dd, 'radius', r)
print iso['density']
flux = iso.calculate_flux('x-velocity', 'y-velocity', 'z-velocity', 'Density')
fluxes.append(flux/1.9891e33*3.15569e13) # solar masses per megayear
print r, fluxes[-1]
```
On both unitrefactor and the current 3.0 tip, this fails with the following traceback:
```
#!python
Traceback (most recent call last):
File "radial_mass_flux.py", line 21, in <module>
print iso['density']
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/data_containers.py", line 205, in __getitem__
self.get_data(f)
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/construction_data_containers.py", line 826, in get_data
mask, fields, sample_type)
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/construction_data_containers.py", line 846, in _extract_isocontours_from_grid
vals = grid.get_vertex_centered_data(field, no_ghost = False)
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/grid_patch.py", line 293, in get_vertex_centered_data
np.add(new_field, cg[field][1: ,1: ,1: ], new_field)
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/data_containers.py", line 205, in __getitem__
self.get_data(f)
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/construction_data_containers.py", line 491, in get_data
if len(gen) > 0: self._generate_fields(gen)
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/data_containers.py", line 626, in _generate_fields
fd = self._generate_field(field)
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/data_containers.py", line 242, in _generate_field
tr = self._generate_fluid_field(field)
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/data_containers.py", line 262, in _generate_fluid_field
rv = finfo(gen_obj)
File "/Users/goldbaum/Documents/yt-hg/yt/fields/derived_field.py", line 181, in __call__
dd = self._function(self, data)
File "/Users/goldbaum/Documents/yt-hg/yt/fields/geometric_fields.py", line 49, in _radius
return get_radius(data, "")
File "/Users/goldbaum/Documents/yt-hg/yt/fields/field_functions.py", line 19, in get_radius
center = data.get_field_parameter("center").in_units("cm")
AttributeError: 'NoneType' object has no attribute 'in_units'
```
I ran this script in unitrefactor, but the same issue is present in the current 3.0 tip.
In this context, 'data' is a covering grid that gets generated by `grid_patch` objects, which have no field parameters.
A quick fix might be to somehow pass the field parameters associated with the disk object to the grid patches.
When I chatted with Matt a little while ago about this issue, he mentioned that we would need to use the chunking system to generate the covering grid, rather than the old grid-based method. I'm unsure how to do that, so I'm reporting the issue here in hopes of getting some advice or guidance on how to fix this issue.
More information about the yt-dev
mailing list