Repository: Unidata/MetPy

Issue:
gdxarray() should assign units to x and y coordinates
Is there a way to construct the proper `Dataset` with the current MetPy functionality so my attempt to plot wind barbs works?

Here's my attempt:
```python
from datetime import datetime

import xarray as xr
import metpy
from metpy.units import units
from metpy.io import GempakGrid
from metpy.plots.declarative import ContourPlot, FilledContourPlot, BarbPlot, MapPanel, PanelContainer

print(metpy.__version__)

MODEL = '/ldmdata/gempak/model/'
gem_file_name = MODEL + 'nam/21092012_nam211.gem'
gem_file = GempakGrid(gem_file_name)

plot_time = datetime(2021, 9, 20, 12)

u500 = gem_file.gdxarray(parameter='UREL', date_time=plot_time, level=500)[0]
v500 = gem_file.gdxarray(parameter='VREL', date_time=plot_time, level=500)[0]
u500 = u500 * units('m/s')
v500 = v500 * units('m/s')

wind = xr.merge([u500, v500])

barbs = BarbPlot()
barbs.data = wind
barbs.time = plot_time
barbs.field = ['urel', 'vrel']
barbs.earth_relative = False   # I get a plot w/o this line, but obviously the winds aren't rotated correctly
barbs.skip = (3, 3)
barbs.plot_units = 'knot'

panel = MapPanel()
panel.area = [-120, -74, 22, 55]
panel.projection = 'lcc'
panel.layers = ['states', 'coastline', 'borders']
panel.title = f'500-mb Winds at {plot_time}'
panel.plots = [barbs]

pc = PanelContainer()
pc.size = (15, 15)
pc.panels = [panel]
pc.show()
```

The result:
```
1.1.0.post39+gd43d5eb02.d20210825
Traceback (most recent call last):
  File "/home/decker/classes/met433/new_labs/barb_issue.py", line 42, in <module>
    pc.show()
  File "/home/decker/src/git_repos/metpy/src/metpy/plots/declarative.py", line 589, in show
    self.draw()
  File "/home/decker/src/git_repos/metpy/src/metpy/plots/declarative.py", line 576, in draw
    panel.draw()
  File "/home/decker/src/git_repos/metpy/src/metpy/plots/declarative.py", line 846, in draw
    p.draw()
  File "/home/decker/src/git_repos/metpy/src/metpy/plots/declarative.py", line 1480, in draw
    self._build()
  File "/home/decker/src/git_repos/metpy/src/metpy/plots/declarative.py", line 1504, in _build
    x_like, y_like, u, v = self.plotdata
  File "/home/decker/src/git_repos/metpy/src/metpy/plots/declarative.py", line 1465, in plotdata
    if 'degree' in x.units:
  File "/home/decker/local/miniconda3/envs/devel21/lib/python3.9/site-packages/xarray/core/common.py", line 239, in __getattr__
    raise AttributeError(
AttributeError: 'DataArray' object has no attribute 'units'
```

Comments:

Patch:
diff --git a/ci/doc_requirements.txt b/ci/doc_requirements.txt
index 9a7099ca6d..e4e7c0c43e 100644
--- a/ci/doc_requirements.txt
+++ b/ci/doc_requirements.txt
@@ -1,7 +1,7 @@
 sphinx==4.5.0
 pydata-sphinx-theme==0.8.1
 sphinx-gallery==0.11.1
-myst-parser==0.18.0
+myst-parser==0.18.1
 netCDF4==1.6.1
 geopandas==0.11.1
 rtree==1.0.0
diff --git a/ci/linting_requirements.txt b/ci/linting_requirements.txt
index dee85eb267..7e1b9024d1 100644
--- a/ci/linting_requirements.txt
+++ b/ci/linting_requirements.txt
@@ -2,7 +2,7 @@ flake8==5.0.4
 pycodestyle==2.9.1
 pyflakes==2.5.0
 
-flake8-bugbear==22.9.11
+flake8-bugbear==22.9.23
 flake8-builtins==1.5.3
 flake8-comprehensions==3.10.0
 flake8-continuation==1.0.5
diff --git a/src/metpy/io/gempak.py b/src/metpy/io/gempak.py
index bff5f9d292..15c5b0226f 100644
--- a/src/metpy/io/gempak.py
+++ b/src/metpy/io/gempak.py
@@ -1362,6 +1362,9 @@ class GempakGrid(GempakFile):
                             'gempak_grid_type': ftype,
                         }
                     )
+                    xrda = xrda.metpy.assign_latitude_longitude()
+                    xrda['x'].attrs['units'] = 'meters'
+                    xrda['y'].attrs['units'] = 'meters'
                     grids.append(xrda)
 
                 else:


Test patch:
diff --git a/tests/io/test_gempak.py b/tests/io/test_gempak.py
index 1883b71033..3cb09a20d6 100644
--- a/tests/io/test_gempak.py
+++ b/tests/io/test_gempak.py
@@ -249,9 +249,14 @@ def test_coordinates_creation(proj_type):
 def test_metpy_crs_creation(proj_type, proj_attrs):
     """Test grid mapping metadata."""
     grid = GempakGrid(get_test_data(f'gem_{proj_type}.grd'))
-    metpy_crs = grid.gdxarray()[0].metpy.crs
+    arr = grid.gdxarray()[0]
+    metpy_crs = arr.metpy.crs
     for k, v in proj_attrs.items():
         assert metpy_crs[k] == v
+    x_unit = arr['x'].units
+    y_unit = arr['y'].units
+    assert x_unit == 'meters'
+    assert y_unit == 'meters'
 
 
 def test_date_parsing():