[yt-dev] Issue #1266: ds.add_gradient_fields not working properly on 2D data (yt_analysis/yt)

Dominik Derigs issues-reply at bitbucket.org
Mon Aug 29 06:14:01 PDT 2016


New issue 1266: ds.add_gradient_fields not working properly on 2D data
https://bitbucket.org/yt_analysis/yt/issues/1266/dsadd_gradient_fields-not-working-properly

Dominik Derigs:

I want to plot the divergence of the magnetic field. For this, I think, the right approach is to use the function add_gradient_field. However, I have been unable to successfully generate any gradient field on my data (2D, FLASH).

There is no suitable public dataset available that could be used to show my problem (2D, periodic, magnetic fields), so I uploaded an exemplary data file [here](https://hera.ph1.uni-koeln.de/~derigs/rotor_mhd_2d_hdf5_chk_0003_cleaning).

MWE:

```
#!python

import yt
ds = yt.load("rotor_mhd_2d_hdf5_chk_0003_cleaning")
slc = yt.SlicePlot(ds, 'z', ["pressure", "pressure_gradient_x", "pressure_gradient_y"])
slc.save()
```

**While the pressure plot is correct, the gradient plots are just empty.**

pressure:
![rotor_mhd_2d_hdf5_chk_0003_cleaning_Slice_z_pressure.png](https://bitbucket.org/repo/BXbAb/images/2652892335-rotor_mhd_2d_hdf5_chk_0003_cleaning_Slice_z_pressure.png)

pressure_gradient_x:
![rotor_mhd_2d_hdf5_chk_0003_cleaning_Slice_z_pressure_gradient_x.png](https://bitbucket.org/repo/BXbAb/images/4076349652-rotor_mhd_2d_hdf5_chk_0003_cleaning_Slice_z_pressure_gradient_x.png)

pressure_gradient_y:
![rotor_mhd_2d_hdf5_chk_0003_cleaning_Slice_z_pressure_gradient_y.png](https://bitbucket.org/repo/BXbAb/images/1628325399-rotor_mhd_2d_hdf5_chk_0003_cleaning_Slice_z_pressure_gradient_y.png)




More information about the yt-dev mailing list