Repository: yt-project/yt

Issue:
Latest ver of yt (3.5dev) breaks clump finding on FITS files
<!--To help us understand and resolve your issue, please fill out the form to
the best of your ability.-->
<!--You can feel free to delete the sections that do not apply.-->

### Bug report

**Bug summary**

When attempting to use the find_clumps function on a master_clump created from a FITS file, the code fails. This functionality works fine with yt ver 3.2.3.

**Code for reproduction**

<!--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

# dataset for this code can be found at: http://use.yt/upload/acccd520

import yt
from yt.mods import *
from yt.analysis_modules.level_sets.api import *

pf2 = load("function05_fits_018_2_proj.fits")
master_clump = Clump(pf2.all_data(), "density")
c_max = 10**np.floor(np.log10(pf2.all_data()['density']).max()+1)
c_min = 2e-4
find_clumps(master_clump, c_min, c_max, 1.5)
```

**Actual outcome**

<!--The output produced by the above code, which may be a screenshot, console
output, etc.-->

```
/nobackupp8/afitts/yt/yt/analysis_modules/level_sets/contour_finder.pyc in identify_contours(data_source, field, min_val, max_val, cached_fields)
     43         nid = node.node_id
     44         node_ids.append(nid)
---> 45         values = g[field][sl].astype("float64")

IndexError: too many indices for array
```

**Expected outcome**

<!--A description of the expected outcome from the code snippet-->
<!--If this used to work in an earlier version of yt, please note the
version it used to work on-->

The contour finder should have no trouble passing the sl variable to g[field] (and the find_clumps function should go off without a hitch! works in yt 3.2.3)

**Version Information**
<!--Please specify your platform and versions of the relevant libraries you are
using:-->
  * Operating System: Linux
  * Python Version: 2.7.12
  * yt version: 3.5dev
  * 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-->



Discussion:
@afitts sorry I haven't figured this out yet--I'll try to get to it soon.
No worries @jzuhone, I'm using yt 3.2.3 for the time being.
Bisected to 9c913f66c, although the problem initially crops up with a slightly different error in ffd9edfbbfd. So this has something to do with adding support for nodal fields.

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
@@ -95,8 +95,10 @@ def __getitem__(self, key):
         finfo = self.ds._get_field_info(*fields[0])
         if not finfo.particle_type:
             num_nodes = 2**sum(finfo.nodal_flag)
-            new_shape = list(self.ActiveDimensions) + [num_nodes]
-            return np.squeeze(tr.reshape(new_shape))
+            new_shape = list(self.ActiveDimensions)
+            if num_nodes > 1:
+                new_shape += [num_nodes]
+            return tr.reshape(new_shape)
         return tr
 
     def convert(self, datatype):


Test patch:
diff --git a/yt/frontends/enzo/tests/test_outputs.py b/yt/frontends/enzo/tests/test_outputs.py
--- a/yt/frontends/enzo/tests/test_outputs.py
+++ b/yt/frontends/enzo/tests/test_outputs.py
@@ -219,3 +219,12 @@ def test_deeply_nested_zoom():
     assert_allclose_units(c, c_actual)
 
     assert_equal(max([g['density'].max() for g in ds.index.grids]), v)
+
+@requires_file(kh2d)
+def test_2d_grid_shape():
+    # see issue #1601
+    # we want to make sure that accessing data on a grid object
+    # returns a 3D array with a dummy dimension.
+    ds = data_dir_load(kh2d)
+    g = ds.index.grids[1]
+    assert g['density'].shape == (128, 100, 1)