[yt-dev] Issue #568: Slicing with cylindrical coordinates (yt_analysis/yt)

rth issues-reply at bitbucket.org
Fri May 17 10:10:55 PDT 2013


New issue 568: Slicing with cylindrical coordinates
https://bitbucket.org/yt_analysis/yt/issue/568/slicing-with-cylindrical-coordinates

rth:

# Slicing with cylindrical coordinates #
Currenly slicing a 2d cylindrical FLASH simulation along the θ axis with yt-3.0 gives wrong results. 

```
#!python

from yt.mods import *

# file included in the attachement
pf = load('./test_hdf5_plt_cnt_0013')

fig = SlicePlot(pf, 2,  ['r', 'z', 'theta', 'dens'], fontsize=10, origin="domain")
fig.save(mpl_kwargs={'bbox_inches':'tight', 'dpi': 500})
```
the produced figures are attached.

1. Slice_z_theta.png:  this projection is supposed to be a constant as there is just one cell in θ direction. On the figure though, there are also some additional cells (ghost cells?) in between blocks with diffferent levels of refinement, that seem to have completely arbitrary values.
2. Slice_z_r.png:  same issue as in 1.
3. Slice_z_z.png: the plot should be linearly increasing along the z axis, and it is not the case.
4. Slice_z_dens.png: Density slice. Same issue as  1.

the labels are actually misleading: all the plots were done in (r‚ z) plane.

Actually, using yt-2.4 and replacing (r, z, θ) -> (x, y, z) still presents the same issue of arbitrary cells between blocks of different levels of refinement in a density slice. Up to now I was using Antony Sopatz's  [flash.output.slice](http://flash.uchicago.edu/site/flashcode/user_support/tools4b/_modules/flash/output.html#slice), altought based on pf.h.slice, did not show the same behaviour. Unless I seriously misunderstand something, or I messed up my yt installation. Can someone please try to reproduce the attached plots?

# Spatial derivatives in cyllindrical #

Compuring a spatial derivative of a field fails in yt-3.0.

```
#!python

from yt.mods import *
# closely based on add_grad and replacing 'x'  by 'r'
def _gradr(field, data):
    grad = data['dens'][2:,1:-1,1:-1] - data['dens'][:-2,1:-1,1:-1]
    grad /= 2.0*data["dr"].flat[0]
    g = np.zeros(data['dens'].shape, dtype='float64')
    g[1:-1,1:-1,1:-1] = np.abs(grad)
    return g

add_field("Grad_dens_r", function=_gradr,
                         take_log=False, validators=[ValidateSpatial(1,['dens', 'dr'])],
                         )

pf = load('./test_hdf5_plt_cnt_0013')

fig = SlicePlot(pf, 2,  'Grad_dens_r', fontsize=10, origin="domain")
#fig.annotate_grids()
fig.save(mpl_kwargs={'bbox_inches':'tight', 'dpi': 500})
```


```
#!python

S1 = 2303214662 ; S2 = 0 ; jname 1 256s = 264
Traceback (most recent call last):
  File "test_case.py", line 18, in <module>
    fig = SlicePlot(pf, 2,  'Grad_dens_r', fontsize=10, origin="domain")
  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/visualization/plot_window.py", line 1226, in __init__
    slc.get_data(fields)
  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/data_objects/data_containers.py", line 500, in get_data
    self._generate_fields(fields_to_generate)
  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/data_objects/data_containers.py", line 510, in _generate_fields
    self.field_data[field] = self._generate_field(field)
  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/data_objects/data_containers.py", line 226, in _generate_field
    return self._generate_fluid_field(field)
  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/data_objects/data_containers.py", line 239, in _generate_fluid_field
    rv = self._generate_spatial_fluid(field, ngt_exception.ghost_zones)
  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/data_objects/data_containers.py", line 263, in _generate_spatial_fluid
    data = gz[field][ngz:-ngz, ngz:-ngz, ngz:-ngz][mask]
  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/data_objects/data_containers.py", line 200, in __getitem__
    self.get_data(f)
  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/data_objects/construction_data_containers.py", line 437, in get_data
    if len(fill) > 0: self._fill_fields(fill)
  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/data_objects/construction_data_containers.py", line 555, in _fill_fields
    chunk.ires)
  File "misc_utilities.pyx", line 551, in yt.utilities.lib.misc_utilities.fill_region (yt/utilities/lib/misc_utilities.c:10025)
ValueError: Buffer dtype mismatch, expected 'float64_t' but got 'float'
```
temporarily fixing the dtype problem in ```data_objects/construction_data_containers.py```, produces a plot that is definitely not d/dr (see Slice_dens_r.png attached). I don't know if the fact that  
line 510 of ```data_objects/data_containers.py``` there is 

```
#!python

                 try:
                     self.field_data[field] = self._generate_field(field)
                 except GenerationInProgress as gip:
                     for f in gip.fields:
                         if f not in fields_to_generate:
                             fields_to_generate.append(f)
                 #else:
                 #    raise
```

that is silenly ignoring ```NeedsGridType``` exceptions, for this plot, could have something to do with it.

```
#!python

  File "/mnt/netapp2/yurchak.r/src/yt-3.0/yt/data_objects/field_info_container.py", line 558, in __call__
    raise NeedsGridType(self.ghost_zones,self.fields)
yt.data_objects.field_info_container.NeedsGridType: (1, ['dens', 'dr'])

```
Thank you.








More information about the yt-dev mailing list