[yt-dev] Issue #1342: Covering grid does not return filtered particles (yt_analysis/yt)

Yi-Hao Chen issues-reply at bitbucket.org
Thu Mar 30 09:35:29 PDT 2017


New issue 1342: Covering grid does not return filtered particles
https://bitbucket.org/yt_analysis/yt/issues/1342/covering-grid-does-not-return-filtered

Yi-Hao Chen:

Using the following script, it seems that particles are not filtered when querying a covering grid.

```
#!python

import yt

@yt.particle_filter(requires=["particle_type"], filtered_type='all')
def stars(pfilter, data):
    filter = data[(pfilter.filtered_type, "particle_type")] == 2
    return filter

ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')

ds.add_particle_filter('stars')

for grid in ds.index.grids[20:30]:
    cg = ds.covering_grid(grid.Level, grid.LeftEdge, grid.ActiveDimensions)
    
    print grid, '{0:8d} {1:8d} {2:8d} {3:8d}'.format(\
            grid['all', 'particle_ones'].shape[0],\
            cg['all', 'particle_ones'].shape[0],\
            grid['stars', 'particle_ones'].shape[0],\
            cg['stars', 'particle_ones'].shape[0])
```
Output:

```
#!

EnzoGrid_0021     5127     5127        0     5127
EnzoGrid_0022    15764    15764        0    15764
EnzoGrid_0023    11869    11869       82    11869
EnzoGrid_0024     1842     1842        0     1842
EnzoGrid_0025       14       14        0       14
EnzoGrid_0026      285      285        0      285
EnzoGrid_0027      401      401        0      401
EnzoGrid_0028    43926    43926    33973    43926
EnzoGrid_0029     1907     1907        0     1907
EnzoGrid_0030    15185    15185        0    15185
```




More information about the yt-dev mailing list