[yt-dev] Issue #1086: derived_field_list not updated after add_volume_weighted_smoothed_field (yt_analysis/yt)

Bili Dong issues-reply at bitbucket.org
Fri Sep 25 12:52:45 PDT 2015


New issue 1086: derived_field_list not updated after add_volume_weighted_smoothed_field
https://bitbucket.org/yt_analysis/yt/issues/1086/derived_field_list-not-updated-after

Bili Dong:

When ``add_volume_weighted_smoothed_field`` is used to add a smoothed field to a dataset (``ds`` thereafter) as shown below, ``ds.derived_field_list`` remains the same before and after the operation. The issue is that ``ds.field_info`` is supposed to be passed to ``add_volume_weighted_smoothed_field``. Then ``ds.field_info.add_field`` is called to add the field, which updates ``ds.field_info`` but not ``ds.derived_field_list``. One way to fix it is to call ``registry.ds.add_field`` instead of ``registry.add_field`` in ``add_volume_weighted_smoothed_field`` (here ``registry`` is supposed to be ``ds.field_info``. But I'm not sure if this is the best way to do it.

``` python
import yt
   
ds = yt.load('GadgetDiskGalaxy/snapshot_200.hdf5')
ds.index
   
from yt.fields.particle_fields import add_volume_weighted_smoothed_field

add_volume_weighted_smoothed_field('PartType0', 'Coordinates', 'Masses',
                                   'SmoothingLength', 'Density',
                                   'particle_ones', ds.field_info)

ad = ds.all_data()
field = ('deposit', 'PartType0_smoothed_particle_ones')
print(field in ds.derived_field_list)
ad[field]
```

BTW, ``('deposit', 'PartType0_smoothed_particle_ones')`` can be accessed with no problem.





More information about the yt-dev mailing list