We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
potential problem with zooming in axisymmetric coords
I'm trying to set the center and width for a 2-d slice plot of axisymmetric data, but it does not seem to work correctly. 

**Code for reproduction**
```
import yt
from yt.units import cm

ds = yt.load("plt06677")

print(ds.domain_left_edge)
print(ds.domain_right_edge)

xctr = 0.5*(ds.domain_left_edge[0] + ds.domain_right_edge[0])
yctr = 5000*cm

xwidth = ds.domain_right_edge[0] - ds.domain_left_edge[0]
ywidth = 1.e4*cm

print(yctr - 0.5*ywidth, yctr + 0.5*ywidth)

#slc = yt.SlicePlot(ds, "theta", "temperature", origin="native",
#                   center=(xctr,yctr,0.0), width=(xwidth,ywidth))

slc = yt.plot_2d(ds, "temperature", origin="native",
                   center=(xctr,yctr), width=(xwidth,ywidth))

slc.save("test.png")
```

a datafile can be found here:

http://bender.astro.sunysb.edu/random/plt06677.tgz

(400 MB)

**Actual outcome**

It produced the following plot:
![test](https://user-images.githubusercontent.com/7817509/31736148-f3a43d62-b411-11e7-8fc1-19cd7df3a446.png)


**Expected outcome**

It should have the y (vertical) scale run from 0 to 1.e4 cm.

**Version Information**
<!--Please specify your platform and versions of the relevant libraries you are
using:-->
  * Operating System: Fedora 26
  * Python Version: 3.6.2
  * yt version: 3.5.dev0
  * Other Libraries (if applicable): 

<!--Please tell us how you installed yt and python e.g., from source,
pip, conda. If you installed from conda, please specify which channel you used
if not the default-->

installed from source


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `yt/geometry/coordinates/cylindrical_coordinates.py`
Content:
```
1 """
2 Definitions for cylindrical coordinate systems
3 
4 
5 
6 
7 """
8 
9 #-----------------------------------------------------------------------------
10 # Copyright (c) 2013, yt Development Team.
11 #
12 # Distributed under the terms of the Modified BSD License.
13 #
14 # The full license is in the file COPYING.txt, distributed with this software.
15 #-----------------------------------------------------------------------------
16 
17 import numpy as np
18 from .coordinate_handler import \
19     CoordinateHandler, \
20     _unknown_coord, \
21     _get_coord_fields, \
22     cylindrical_to_cartesian, \
23     cartesian_to_cylindrical
24 from yt.utilities.lib.pixelization_routines import \
25     pixelize_cartesian, pixelize_cylinder
26 #
27 # Cylindrical fields
28 #
29 
30 class CylindricalCoordinateHandler(CoordinateHandler):
31     name = "cylindrical"
32 
33     def __init__(self, ds, ordering = ('r', 'z', 'theta')):
34         super(CylindricalCoordinateHandler, self).__init__(ds, ordering)
35         self.image_units = {}
36         self.image_units[self.axis_id['r']] = ("rad", None)
37         self.image_units[self.axis_id['theta']] = (None, None)
38         self.image_units[self.axis_id['z']] = (None, None)
39 
40     def setup_fields(self, registry):
41         # return the fields for r, z, theta
42         registry.add_field(("index", "dx"), sampling_type="cell",  function=_unknown_coord)
43         registry.add_field(("index", "dy"), sampling_type="cell",  function=_unknown_coord)
44         registry.add_field(("index", "x"), sampling_type="cell",  function=_unknown_coord)
45         registry.add_field(("index", "y"), sampling_type="cell",  function=_unknown_coord)
46         f1, f2 = _get_coord_fields(self.axis_id['r'])
47         registry.add_field(("index", "dr"), sampling_type="cell",  function = f1,
48                            display_field = False,
49                            units = "code_length")
50         registry.add_field(("index", "r"), sampling_type="cell",  function = f2,
51                            display_field = False,
52                            units = "code_length")
53 
54         f1, f2 = _get_coord_fields(self.axis_id['z'])
55         registry.add_field(("index", "dz"), sampling_type="cell",  function = f1,
56                            display_field = False,
57                            units = "code_length")
58         registry.add_field(("index", "z"), sampling_type="cell",  function = f2,
59                            display_field = False,
60                            units = "code_length")
61 
62         f1, f2 = _get_coord_fields(self.axis_id['theta'], "")
63         registry.add_field(("index", "dtheta"), sampling_type="cell",  function = f1,
64                            display_field = False,
65                            units = "")
66         registry.add_field(("index", "theta"), sampling_type="cell",  function = f2,
67                            display_field = False,
68                            units = "")
69 
70         def _CylindricalVolume(field, data):
71             r = data["index", "r"]
72             dr = data["index", "dr"]
73             vol = 0.5*((r+0.5*dr)**2-(r-0.5*dr)**2)
74             vol *= data["index", "dtheta"]
75             vol *= data["index", "dz"]
76             return vol
77         registry.add_field(("index", "cell_volume"), sampling_type="cell",
78                  function=_CylindricalVolume,
79                  units = "code_length**3")
80 
81         def _path_r(field, data):
82             return data["index", "dr"]
83         registry.add_field(("index", "path_element_r"), sampling_type="cell", 
84                  function = _path_r,
85                  units = "code_length")
86         def _path_theta(field, data):
87             # Note: this already assumes cell-centered
88             return data["index", "r"] * data["index", "dtheta"]
89         registry.add_field(("index", "path_element_theta"), sampling_type="cell", 
90                  function = _path_theta,
91                  units = "code_length")
92         def _path_z(field, data):
93             return data["index", "dz"]
94         registry.add_field(("index", "path_element_z"), sampling_type="cell", 
95                  function = _path_z,
96                  units = "code_length")
97 
98     def pixelize(self, dimension, data_source, field, bounds, size,
99                  antialias = True, periodic = True):
100         ax_name = self.axis_name[dimension]
101         if ax_name in ('r', 'theta'):
102             return self._ortho_pixelize(data_source, field, bounds, size,
103                                         antialias, dimension, periodic)
104         elif ax_name == "z":
105             return self._cyl_pixelize(data_source, field, bounds, size,
106                                         antialias)
107         else:
108             # Pixelizing along a cylindrical surface is a bit tricky
109             raise NotImplementedError
110 
111     def _ortho_pixelize(self, data_source, field, bounds, size, antialias,
112                         dim, periodic):
113         period = self.period[:2].copy() # dummy here
114         period[0] = self.period[self.x_axis[dim]]
115         period[1] = self.period[self.y_axis[dim]]
116         if hasattr(period, 'in_units'):
117             period = period.in_units("code_length").d
118         buff = np.zeros(size, dtype="f8")
119         pixelize_cartesian(buff, data_source['px'], data_source['py'],
120                                   data_source['pdx'], data_source['pdy'],
121                                   data_source[field],
122                                   bounds, int(antialias),
123                                   period, int(periodic))
124         return buff
125 
126     def _cyl_pixelize(self, data_source, field, bounds, size, antialias):
127         buff = np.zeros((size[1], size[0]), dtype="f8")
128         pixelize_cylinder(buff,
129                           data_source['px'],
130                           data_source['pdx'],
131                           data_source['py'],
132                           data_source['pdy'],
133                           data_source[field], bounds)
134         return buff
135 
136     _x_pairs = (('r', 'theta'), ('z', 'r'), ('theta', 'r'))
137     _y_pairs = (('r', 'z'), ('z', 'theta'), ('theta', 'z'))
138 
139     _image_axis_name = None
140 
141     @property
142     def image_axis_name(self):
143         if self._image_axis_name is not None:
144             return self._image_axis_name
145         # This is the x and y axes labels that get displayed.  For
146         # non-Cartesian coordinates, we usually want to override these for
147         # Cartesian coordinates, since we transform them.
148         rv = {self.axis_id['r']: ('theta', 'z'),
149               self.axis_id['z']: ('x', 'y'),
150               self.axis_id['theta']: ('r', 'z')}
151         for i in list(rv.keys()):
152             rv[self.axis_name[i]] = rv[i]
153             rv[self.axis_name[i].upper()] = rv[i]
154         self._image_axis_name = rv
155         return rv
156 
157     def convert_from_cartesian(self, coord):
158         return cartesian_to_cylindrical(coord)
159 
160     def convert_to_cartesian(self, coord):
161         return cylindrical_to_cartesian(coord)
162 
163     def convert_to_cylindrical(self, coord):
164         return coord
165 
166     def convert_from_cylindrical(self, coord):
167         return coord
168 
169     def convert_to_spherical(self, coord):
170         raise NotImplementedError
171 
172     def convert_from_spherical(self, coord):
173         raise NotImplementedError
174 
175     @property
176     def period(self):
177         return np.array([0.0, 0.0, 2.0*np.pi])
178 
179     def sanitize_center(self, center, axis):
180         center, display_center = super(
181             CylindricalCoordinateHandler, self).sanitize_center(center, axis)
182         display_center = [0.0 * display_center[0],
183                           0.0 * display_center[1],
184                           0.0 * display_center[2]]
185         ax_name = self.axis_name[axis]
186         r_ax = self.axis_id['r']
187         theta_ax = self.axis_id['theta']
188         z_ax = self.axis_id['z']
189         if ax_name == "r":
190             # zeros everywhere
191             display_center[theta_ax] = self.ds.domain_center[theta_ax]
192             display_center[z_ax] = self.ds.domain_center[z_ax]
193         elif ax_name == "theta":
194             # Note we are using domain_right_edge, not domain_width, so that in
195             # cases where DLE is not zero we go to the inner edge.
196             display_center[r_ax] = self.ds.domain_right_edge[r_ax]/2.0
197             display_center[z_ax] = self.ds.domain_center[z_ax]
198             # zeros for the others
199         return center, display_center
200 
201     def sanitize_width(self, axis, width, depth):
202         name = self.axis_name[axis]
203         r_ax, theta_ax, z_ax = (self.ds.coordinates.axis_id[ax]
204                                 for ax in ('r', 'theta', 'z'))
205         if width is not None:
206              width = super(CylindricalCoordinateHandler,
207                            self).sanitize_width(axis, width, depth)
208         # Note: regardless of axes, these are set up to give consistent plots
209         # when plotted, which is not strictly a "right hand rule" for axes.
210         elif name == "r": # soup can label
211             width = [2.0 * np.pi * self.ds.domain_width.uq,
212                      self.ds.domain_width[z_ax]]
213         elif name == "theta":
214             width = [self.ds.domain_right_edge[r_ax],
215                      self.ds.domain_width[z_ax]]
216         elif name == "z":
217             width = [2.0*self.ds.domain_right_edge[r_ax],
218                      2.0*self.ds.domain_right_edge[r_ax]]
219         return width
220
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/yt/geometry/coordinates/cylindrical_coordinates.py b/yt/geometry/coordinates/cylindrical_coordinates.py
--- a/yt/geometry/coordinates/cylindrical_coordinates.py
+++ b/yt/geometry/coordinates/cylindrical_coordinates.py
@@ -187,15 +187,11 @@
         theta_ax = self.axis_id['theta']
         z_ax = self.axis_id['z']
         if ax_name == "r":
-            # zeros everywhere
             display_center[theta_ax] = self.ds.domain_center[theta_ax]
             display_center[z_ax] = self.ds.domain_center[z_ax]
         elif ax_name == "theta":
-            # Note we are using domain_right_edge, not domain_width, so that in
-            # cases where DLE is not zero we go to the inner edge.
-            display_center[r_ax] = self.ds.domain_right_edge[r_ax]/2.0
-            display_center[z_ax] = self.ds.domain_center[z_ax]
-            # zeros for the others
+            # use existing center value
+            for idx in (r_ax, z_ax): display_center[idx] = center[idx]
         return center, display_center
 
     def sanitize_width(self, axis, width, depth):

{"golden_diff": "diff --git a/yt/geometry/coordinates/cylindrical_coordinates.py b/yt/geometry/coordinates/cylindrical_coordinates.py\n--- a/yt/geometry/coordinates/cylindrical_coordinates.py\n+++ b/yt/geometry/coordinates/cylindrical_coordinates.py\n@@ -187,15 +187,11 @@\n         theta_ax = self.axis_id['theta']\n         z_ax = self.axis_id['z']\n         if ax_name == \"r\":\n-            # zeros everywhere\n             display_center[theta_ax] = self.ds.domain_center[theta_ax]\n             display_center[z_ax] = self.ds.domain_center[z_ax]\n         elif ax_name == \"theta\":\n-            # Note we are using domain_right_edge, not domain_width, so that in\n-            # cases where DLE is not zero we go to the inner edge.\n-            display_center[r_ax] = self.ds.domain_right_edge[r_ax]/2.0\n-            display_center[z_ax] = self.ds.domain_center[z_ax]\n-            # zeros for the others\n+            # use existing center value\n+            for idx in (r_ax, z_ax): display_center[idx] = center[idx]\n         return center, display_center\n \n     def sanitize_width(self, axis, width, depth):\n", "issue": "potential problem with zooming in axisymmetric coords\nI'm trying to set the center and width for a 2-d slice plot of axisymmetric data, but it does not seem to work correctly. \r\n\r\n**Code for reproduction**\r\n```\r\nimport yt\r\nfrom yt.units import cm\r\n\r\nds = yt.load(\"plt06677\")\r\n\r\nprint(ds.domain_left_edge)\r\nprint(ds.domain_right_edge)\r\n\r\nxctr = 0.5*(ds.domain_left_edge[0] + ds.domain_right_edge[0])\r\nyctr = 5000*cm\r\n\r\nxwidth = ds.domain_right_edge[0] - ds.domain_left_edge[0]\r\nywidth = 1.e4*cm\r\n\r\nprint(yctr - 0.5*ywidth, yctr + 0.5*ywidth)\r\n\r\n#slc = yt.SlicePlot(ds, \"theta\", \"temperature\", origin=\"native\",\r\n#                   center=(xctr,yctr,0.0), width=(xwidth,ywidth))\r\n\r\nslc = yt.plot_2d(ds, \"temperature\", origin=\"native\",\r\n                   center=(xctr,yctr), width=(xwidth,ywidth))\r\n\r\nslc.save(\"test.png\")\r\n```\r\n\r\na datafile can be found here:\r\n\r\nhttp://bender.astro.sunysb.edu/random/plt06677.tgz\r\n\r\n(400 MB)\r\n\r\n**Actual outcome**\r\n\r\nIt produced the following plot:\r\n![test](https://user-images.githubusercontent.com/7817509/31736148-f3a43d62-b411-11e7-8fc1-19cd7df3a446.png)\r\n\r\n\r\n**Expected outcome**\r\n\r\nIt should have the y (vertical) scale run from 0 to 1.e4 cm.\r\n\r\n**Version Information**\r\n<!--Please specify your platform and versions of the relevant libraries you are\r\nusing:-->\r\n  * Operating System: Fedora 26\r\n  * Python Version: 3.6.2\r\n  * yt version: 3.5.dev0\r\n  * Other Libraries (if applicable): \r\n\r\n<!--Please tell us how you installed yt and python e.g., from source,\r\npip, conda. If you installed from conda, please specify which channel you used\r\nif not the default-->\r\n\r\ninstalled from source\r\n\n", "before_files": [{"content": "\"\"\"\nDefinitions for cylindrical coordinate systems\n\n\n\n\n\"\"\"\n\n#-----------------------------------------------------------------------------\n# Copyright (c) 2013, yt Development Team.\n#\n# Distributed under the terms of the Modified BSD License.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\nimport numpy as np\nfrom .coordinate_handler import \\\n    CoordinateHandler, \\\n    _unknown_coord, \\\n    _get_coord_fields, \\\n    cylindrical_to_cartesian, \\\n    cartesian_to_cylindrical\nfrom yt.utilities.lib.pixelization_routines import \\\n    pixelize_cartesian, pixelize_cylinder\n#\n# Cylindrical fields\n#\n\nclass CylindricalCoordinateHandler(CoordinateHandler):\n    name = \"cylindrical\"\n\n    def __init__(self, ds, ordering = ('r', 'z', 'theta')):\n        super(CylindricalCoordinateHandler, self).__init__(ds, ordering)\n        self.image_units = {}\n        self.image_units[self.axis_id['r']] = (\"rad\", None)\n        self.image_units[self.axis_id['theta']] = (None, None)\n        self.image_units[self.axis_id['z']] = (None, None)\n\n    def setup_fields(self, registry):\n        # return the fields for r, z, theta\n        registry.add_field((\"index\", \"dx\"), sampling_type=\"cell\",  function=_unknown_coord)\n        registry.add_field((\"index\", \"dy\"), sampling_type=\"cell\",  function=_unknown_coord)\n        registry.add_field((\"index\", \"x\"), sampling_type=\"cell\",  function=_unknown_coord)\n        registry.add_field((\"index\", \"y\"), sampling_type=\"cell\",  function=_unknown_coord)\n        f1, f2 = _get_coord_fields(self.axis_id['r'])\n        registry.add_field((\"index\", \"dr\"), sampling_type=\"cell\",  function = f1,\n                           display_field = False,\n                           units = \"code_length\")\n        registry.add_field((\"index\", \"r\"), sampling_type=\"cell\",  function = f2,\n                           display_field = False,\n                           units = \"code_length\")\n\n        f1, f2 = _get_coord_fields(self.axis_id['z'])\n        registry.add_field((\"index\", \"dz\"), sampling_type=\"cell\",  function = f1,\n                           display_field = False,\n                           units = \"code_length\")\n        registry.add_field((\"index\", \"z\"), sampling_type=\"cell\",  function = f2,\n                           display_field = False,\n                           units = \"code_length\")\n\n        f1, f2 = _get_coord_fields(self.axis_id['theta'], \"\")\n        registry.add_field((\"index\", \"dtheta\"), sampling_type=\"cell\",  function = f1,\n                           display_field = False,\n                           units = \"\")\n        registry.add_field((\"index\", \"theta\"), sampling_type=\"cell\",  function = f2,\n                           display_field = False,\n                           units = \"\")\n\n        def _CylindricalVolume(field, data):\n            r = data[\"index\", \"r\"]\n            dr = data[\"index\", \"dr\"]\n            vol = 0.5*((r+0.5*dr)**2-(r-0.5*dr)**2)\n            vol *= data[\"index\", \"dtheta\"]\n            vol *= data[\"index\", \"dz\"]\n            return vol\n        registry.add_field((\"index\", \"cell_volume\"), sampling_type=\"cell\",\n                 function=_CylindricalVolume,\n                 units = \"code_length**3\")\n\n        def _path_r(field, data):\n            return data[\"index\", \"dr\"]\n        registry.add_field((\"index\", \"path_element_r\"), sampling_type=\"cell\", \n                 function = _path_r,\n                 units = \"code_length\")\n        def _path_theta(field, data):\n            # Note: this already assumes cell-centered\n            return data[\"index\", \"r\"] * data[\"index\", \"dtheta\"]\n        registry.add_field((\"index\", \"path_element_theta\"), sampling_type=\"cell\", \n                 function = _path_theta,\n                 units = \"code_length\")\n        def _path_z(field, data):\n            return data[\"index\", \"dz\"]\n        registry.add_field((\"index\", \"path_element_z\"), sampling_type=\"cell\", \n                 function = _path_z,\n                 units = \"code_length\")\n\n    def pixelize(self, dimension, data_source, field, bounds, size,\n                 antialias = True, periodic = True):\n        ax_name = self.axis_name[dimension]\n        if ax_name in ('r', 'theta'):\n            return self._ortho_pixelize(data_source, field, bounds, size,\n                                        antialias, dimension, periodic)\n        elif ax_name == \"z\":\n            return self._cyl_pixelize(data_source, field, bounds, size,\n                                        antialias)\n        else:\n            # Pixelizing along a cylindrical surface is a bit tricky\n            raise NotImplementedError\n\n    def _ortho_pixelize(self, data_source, field, bounds, size, antialias,\n                        dim, periodic):\n        period = self.period[:2].copy() # dummy here\n        period[0] = self.period[self.x_axis[dim]]\n        period[1] = self.period[self.y_axis[dim]]\n        if hasattr(period, 'in_units'):\n            period = period.in_units(\"code_length\").d\n        buff = np.zeros(size, dtype=\"f8\")\n        pixelize_cartesian(buff, data_source['px'], data_source['py'],\n                                  data_source['pdx'], data_source['pdy'],\n                                  data_source[field],\n                                  bounds, int(antialias),\n                                  period, int(periodic))\n        return buff\n\n    def _cyl_pixelize(self, data_source, field, bounds, size, antialias):\n        buff = np.zeros((size[1], size[0]), dtype=\"f8\")\n        pixelize_cylinder(buff,\n                          data_source['px'],\n                          data_source['pdx'],\n                          data_source['py'],\n                          data_source['pdy'],\n                          data_source[field], bounds)\n        return buff\n\n    _x_pairs = (('r', 'theta'), ('z', 'r'), ('theta', 'r'))\n    _y_pairs = (('r', 'z'), ('z', 'theta'), ('theta', 'z'))\n\n    _image_axis_name = None\n\n    @property\n    def image_axis_name(self):\n        if self._image_axis_name is not None:\n            return self._image_axis_name\n        # This is the x and y axes labels that get displayed.  For\n        # non-Cartesian coordinates, we usually want to override these for\n        # Cartesian coordinates, since we transform them.\n        rv = {self.axis_id['r']: ('theta', 'z'),\n              self.axis_id['z']: ('x', 'y'),\n              self.axis_id['theta']: ('r', 'z')}\n        for i in list(rv.keys()):\n            rv[self.axis_name[i]] = rv[i]\n            rv[self.axis_name[i].upper()] = rv[i]\n        self._image_axis_name = rv\n        return rv\n\n    def convert_from_cartesian(self, coord):\n        return cartesian_to_cylindrical(coord)\n\n    def convert_to_cartesian(self, coord):\n        return cylindrical_to_cartesian(coord)\n\n    def convert_to_cylindrical(self, coord):\n        return coord\n\n    def convert_from_cylindrical(self, coord):\n        return coord\n\n    def convert_to_spherical(self, coord):\n        raise NotImplementedError\n\n    def convert_from_spherical(self, coord):\n        raise NotImplementedError\n\n    @property\n    def period(self):\n        return np.array([0.0, 0.0, 2.0*np.pi])\n\n    def sanitize_center(self, center, axis):\n        center, display_center = super(\n            CylindricalCoordinateHandler, self).sanitize_center(center, axis)\n        display_center = [0.0 * display_center[0],\n                          0.0 * display_center[1],\n                          0.0 * display_center[2]]\n        ax_name = self.axis_name[axis]\n        r_ax = self.axis_id['r']\n        theta_ax = self.axis_id['theta']\n        z_ax = self.axis_id['z']\n        if ax_name == \"r\":\n            # zeros everywhere\n            display_center[theta_ax] = self.ds.domain_center[theta_ax]\n            display_center[z_ax] = self.ds.domain_center[z_ax]\n        elif ax_name == \"theta\":\n            # Note we are using domain_right_edge, not domain_width, so that in\n            # cases where DLE is not zero we go to the inner edge.\n            display_center[r_ax] = self.ds.domain_right_edge[r_ax]/2.0\n            display_center[z_ax] = self.ds.domain_center[z_ax]\n            # zeros for the others\n        return center, display_center\n\n    def sanitize_width(self, axis, width, depth):\n        name = self.axis_name[axis]\n        r_ax, theta_ax, z_ax = (self.ds.coordinates.axis_id[ax]\n                                for ax in ('r', 'theta', 'z'))\n        if width is not None:\n             width = super(CylindricalCoordinateHandler,\n                           self).sanitize_width(axis, width, depth)\n        # Note: regardless of axes, these are set up to give consistent plots\n        # when plotted, which is not strictly a \"right hand rule\" for axes.\n        elif name == \"r\": # soup can label\n            width = [2.0 * np.pi * self.ds.domain_width.uq,\n                     self.ds.domain_width[z_ax]]\n        elif name == \"theta\":\n            width = [self.ds.domain_right_edge[r_ax],\n                     self.ds.domain_width[z_ax]]\n        elif name == \"z\":\n            width = [2.0*self.ds.domain_right_edge[r_ax],\n                     2.0*self.ds.domain_right_edge[r_ax]]\n        return width\n", "path": "yt/geometry/coordinates/cylindrical_coordinates.py"}], "after_files": [{"content": "\"\"\"\nDefinitions for cylindrical coordinate systems\n\n\n\n\n\"\"\"\n\n#-----------------------------------------------------------------------------\n# Copyright (c) 2013, yt Development Team.\n#\n# Distributed under the terms of the Modified BSD License.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\nimport numpy as np\nfrom .coordinate_handler import \\\n    CoordinateHandler, \\\n    _unknown_coord, \\\n    _get_coord_fields, \\\n    cylindrical_to_cartesian, \\\n    cartesian_to_cylindrical\nfrom yt.utilities.lib.pixelization_routines import \\\n    pixelize_cartesian, pixelize_cylinder\n#\n# Cylindrical fields\n#\n\nclass CylindricalCoordinateHandler(CoordinateHandler):\n    name = \"cylindrical\"\n\n    def __init__(self, ds, ordering = ('r', 'z', 'theta')):\n        super(CylindricalCoordinateHandler, self).__init__(ds, ordering)\n        self.image_units = {}\n        self.image_units[self.axis_id['r']] = (\"rad\", None)\n        self.image_units[self.axis_id['theta']] = (None, None)\n        self.image_units[self.axis_id['z']] = (None, None)\n\n    def setup_fields(self, registry):\n        # return the fields for r, z, theta\n        registry.add_field((\"index\", \"dx\"), sampling_type=\"cell\",  function=_unknown_coord)\n        registry.add_field((\"index\", \"dy\"), sampling_type=\"cell\",  function=_unknown_coord)\n        registry.add_field((\"index\", \"x\"), sampling_type=\"cell\",  function=_unknown_coord)\n        registry.add_field((\"index\", \"y\"), sampling_type=\"cell\",  function=_unknown_coord)\n        f1, f2 = _get_coord_fields(self.axis_id['r'])\n        registry.add_field((\"index\", \"dr\"), sampling_type=\"cell\",  function = f1,\n                           display_field = False,\n                           units = \"code_length\")\n        registry.add_field((\"index\", \"r\"), sampling_type=\"cell\",  function = f2,\n                           display_field = False,\n                           units = \"code_length\")\n\n        f1, f2 = _get_coord_fields(self.axis_id['z'])\n        registry.add_field((\"index\", \"dz\"), sampling_type=\"cell\",  function = f1,\n                           display_field = False,\n                           units = \"code_length\")\n        registry.add_field((\"index\", \"z\"), sampling_type=\"cell\",  function = f2,\n                           display_field = False,\n                           units = \"code_length\")\n\n        f1, f2 = _get_coord_fields(self.axis_id['theta'], \"\")\n        registry.add_field((\"index\", \"dtheta\"), sampling_type=\"cell\",  function = f1,\n                           display_field = False,\n                           units = \"\")\n        registry.add_field((\"index\", \"theta\"), sampling_type=\"cell\",  function = f2,\n                           display_field = False,\n                           units = \"\")\n\n        def _CylindricalVolume(field, data):\n            r = data[\"index\", \"r\"]\n            dr = data[\"index\", \"dr\"]\n            vol = 0.5*((r+0.5*dr)**2-(r-0.5*dr)**2)\n            vol *= data[\"index\", \"dtheta\"]\n            vol *= data[\"index\", \"dz\"]\n            return vol\n        registry.add_field((\"index\", \"cell_volume\"), sampling_type=\"cell\",\n                 function=_CylindricalVolume,\n                 units = \"code_length**3\")\n\n        def _path_r(field, data):\n            return data[\"index\", \"dr\"]\n        registry.add_field((\"index\", \"path_element_r\"), sampling_type=\"cell\", \n                 function = _path_r,\n                 units = \"code_length\")\n        def _path_theta(field, data):\n            # Note: this already assumes cell-centered\n            return data[\"index\", \"r\"] * data[\"index\", \"dtheta\"]\n        registry.add_field((\"index\", \"path_element_theta\"), sampling_type=\"cell\", \n                 function = _path_theta,\n                 units = \"code_length\")\n        def _path_z(field, data):\n            return data[\"index\", \"dz\"]\n        registry.add_field((\"index\", \"path_element_z\"), sampling_type=\"cell\", \n                 function = _path_z,\n                 units = \"code_length\")\n\n    def pixelize(self, dimension, data_source, field, bounds, size,\n                 antialias = True, periodic = True):\n        ax_name = self.axis_name[dimension]\n        if ax_name in ('r', 'theta'):\n            return self._ortho_pixelize(data_source, field, bounds, size,\n                                        antialias, dimension, periodic)\n        elif ax_name == \"z\":\n            return self._cyl_pixelize(data_source, field, bounds, size,\n                                        antialias)\n        else:\n            # Pixelizing along a cylindrical surface is a bit tricky\n            raise NotImplementedError\n\n    def _ortho_pixelize(self, data_source, field, bounds, size, antialias,\n                        dim, periodic):\n        period = self.period[:2].copy() # dummy here\n        period[0] = self.period[self.x_axis[dim]]\n        period[1] = self.period[self.y_axis[dim]]\n        if hasattr(period, 'in_units'):\n            period = period.in_units(\"code_length\").d\n        buff = np.zeros(size, dtype=\"f8\")\n        pixelize_cartesian(buff, data_source['px'], data_source['py'],\n                                  data_source['pdx'], data_source['pdy'],\n                                  data_source[field],\n                                  bounds, int(antialias),\n                                  period, int(periodic))\n        return buff\n\n    def _cyl_pixelize(self, data_source, field, bounds, size, antialias):\n        buff = np.zeros((size[1], size[0]), dtype=\"f8\")\n        pixelize_cylinder(buff,\n                          data_source['px'],\n                          data_source['pdx'],\n                          data_source['py'],\n                          data_source['pdy'],\n                          data_source[field], bounds)\n        return buff\n\n    _x_pairs = (('r', 'theta'), ('z', 'r'), ('theta', 'r'))\n    _y_pairs = (('r', 'z'), ('z', 'theta'), ('theta', 'z'))\n\n    _image_axis_name = None\n\n    @property\n    def image_axis_name(self):\n        if self._image_axis_name is not None:\n            return self._image_axis_name\n        # This is the x and y axes labels that get displayed.  For\n        # non-Cartesian coordinates, we usually want to override these for\n        # Cartesian coordinates, since we transform them.\n        rv = {self.axis_id['r']: ('theta', 'z'),\n              self.axis_id['z']: ('x', 'y'),\n              self.axis_id['theta']: ('r', 'z')}\n        for i in list(rv.keys()):\n            rv[self.axis_name[i]] = rv[i]\n            rv[self.axis_name[i].upper()] = rv[i]\n        self._image_axis_name = rv\n        return rv\n\n    def convert_from_cartesian(self, coord):\n        return cartesian_to_cylindrical(coord)\n\n    def convert_to_cartesian(self, coord):\n        return cylindrical_to_cartesian(coord)\n\n    def convert_to_cylindrical(self, coord):\n        return coord\n\n    def convert_from_cylindrical(self, coord):\n        return coord\n\n    def convert_to_spherical(self, coord):\n        raise NotImplementedError\n\n    def convert_from_spherical(self, coord):\n        raise NotImplementedError\n\n    @property\n    def period(self):\n        return np.array([0.0, 0.0, 2.0*np.pi])\n\n    def sanitize_center(self, center, axis):\n        center, display_center = super(\n            CylindricalCoordinateHandler, self).sanitize_center(center, axis)\n        display_center = [0.0 * display_center[0],\n                          0.0 * display_center[1],\n                          0.0 * display_center[2]]\n        ax_name = self.axis_name[axis]\n        r_ax = self.axis_id['r']\n        theta_ax = self.axis_id['theta']\n        z_ax = self.axis_id['z']\n        if ax_name == \"r\":\n            display_center[theta_ax] = self.ds.domain_center[theta_ax]\n            display_center[z_ax] = self.ds.domain_center[z_ax]\n        elif ax_name == \"theta\":\n            # use existing center value\n            for idx in (r_ax, z_ax): display_center[idx] = center[idx]\n        return center, display_center\n\n    def sanitize_width(self, axis, width, depth):\n        name = self.axis_name[axis]\n        r_ax, theta_ax, z_ax = (self.ds.coordinates.axis_id[ax]\n                                for ax in ('r', 'theta', 'z'))\n        if width is not None:\n             width = super(CylindricalCoordinateHandler,\n                           self).sanitize_width(axis, width, depth)\n        # Note: regardless of axes, these are set up to give consistent plots\n        # when plotted, which is not strictly a \"right hand rule\" for axes.\n        elif name == \"r\": # soup can label\n            width = [2.0 * np.pi * self.ds.domain_width.uq,\n                     self.ds.domain_width[z_ax]]\n        elif name == \"theta\":\n            width = [self.ds.domain_right_edge[r_ax],\n                     self.ds.domain_width[z_ax]]\n        elif name == \"z\":\n            width = [2.0*self.ds.domain_right_edge[r_ax],\n                     2.0*self.ds.domain_right_edge[r_ax]]\n        return width\n", "path": "yt/geometry/coordinates/cylindrical_coordinates.py"}]}