Repository: yt-project/yt

Issue:
Units error when working with a surface object
### Bug report


**Code for reproduction**

When running the following script:

<!--A minimum code snippet required to reproduce the bug, also minimizing the
number of dependencies required.-->

<!-- If you need to use a data file to trigger the issue you're having, consider
using one of the datasets from the yt data hub (http://yt-project.org/data). If
your issue cannot be triggered using a public dataset, you can use the yt
curldrop (https://docs.hub.yt/services.html#curldrop) to share data
files. Please include a link to the dataset in the issue if you use the
curldrop.-->

```python
import yt

FNAME = 'IsolatedGalaxy/galaxy0030/galaxy0030'
ds = yt.load(FNAME)
x = y = z = .5
sp1 = ds.sphere((x,y,z), (300, 'kpc'))
Nmax = sp1.max('HI_Density')
sur = ds.surface(sp1,"HI_Density", .5*Nmax)
print(sur['x'][0])
```

I get the following error:

```
Traceback (most recent call last):
  File "test.py", line 9, in <module>
    print(sur['x'][0])
  File "/Users/goldbaum/Documents/yt-git/yt/data_objects/data_containers.py", line 281, in __getitem__
    self.get_data(f)
  File "/Users/goldbaum/Documents/yt-git/yt/data_objects/construction_data_containers.py", line 1144, in get_data
    mask, fields, sample_type, no_ghost=no_ghost)
  File "/Users/goldbaum/Documents/yt-git/yt/data_objects/construction_data_containers.py", line 1171, in _extract_isocontours_from_grid
    svals = grid.get_vertex_centered_data([sample_values])[sample_values]
  File "/Users/goldbaum/Documents/yt-git/yt/data_objects/grid_patch.py", line 293, in get_vertex_centered_data
    np.add(new_fields[field], cg[field][1: ,1: ,1: ], new_fields[field])
  File "/Users/goldbaum/Documents/yt-git/yt/units/yt_array.py", line 1225, in __array_wrap__
    raise YTUfuncUnitError(context[0], unit1, unit2)
yt.utilities.exceptions.YTUfuncUnitError: The NumPy <ufunc 'add'> operation is only allowed on objects with identical units. Convert one of the arrays to the other's units first. Received units (code_length) and (cm).
```

**Expected outcome**

There should be no error.



Discussion:

Resolving patch:
diff --git a/yt/data_objects/grid_patch.py b/yt/data_objects/grid_patch.py
--- a/yt/data_objects/grid_patch.py
+++ b/yt/data_objects/grid_patch.py
@@ -274,7 +274,7 @@ def get_vertex_centered_data(self, fields, smoothed=True, no_ghost=False):
         for field in fields:
             finfo = self.ds._get_field_info(field)
             new_fields[field] = self.ds.arr(
-                np.zeros(self.ActiveDimensions + 1), finfo.units)
+                np.zeros(self.ActiveDimensions + 1), finfo.output_units)
         if no_ghost:
             for field in fields:
                 # Ensure we have the native endianness in this array.  Avoid making


Test patch:
diff --git a/yt/data_objects/tests/test_fluxes.py b/yt/data_objects/tests/test_fluxes.py
--- a/yt/data_objects/tests/test_fluxes.py
+++ b/yt/data_objects/tests/test_fluxes.py
@@ -101,3 +101,13 @@ def _Emissivity(field, data):
 
         assert os.path.exists('my_galaxy_emis.obj')
         assert os.path.exists('my_galaxy_emis.mtl')
+
+@requires_file(ISOGAL)
+def test_correct_output_unit():
+    # see issue #1368
+    ds = load(ISOGAL)
+    x = y = z = .5
+    sp1 = ds.sphere((x,y,z), (300, 'kpc'))
+    Nmax = sp1.max('HI_Density')
+    sur = ds.surface(sp1,"HI_Density", .5*Nmax)
+    sur['x'][0]