I'm trying to follow the MetPy cross-section plotting example (https://unidata.github.io/MetPy/latest/examples/cross_section.html), but applying it to WRF output data. I read in the WRF file as an xarray dataset, and then apply metpy.parse_cf().squeeze() to it, as in the example. However, I get this set of errors:
Traceback (most recent call last):
File "plot_wrf_cross_overlays.py", line 252, in <module>
main(init_dt_first, init_dt_last, init_stride_h, plot_beg_lead_time, plot_end_lead_time, plot_stride, domain)
File "plot_wrf_cross_overlays.py", line 236, in main
DS_wrf_xr = DS_wrf_xr.metpy.parse_cf().squeeze()
File "/glade/work/jaredlee/python/my_npl_clone_20200417_cheyenne_3.7.5/lib/python3.7/site-packages/metpy/xarray.py", line 521, in parse_cf
for single_varname in varname])
File "/glade/work/jaredlee/python/my_npl_clone_20200417_cheyenne_3.7.5/lib/python3.7/site-packages/metpy/xarray.py", line 521, in <listcomp>
for single_varname in varname])
File "/glade/work/jaredlee/python/my_npl_clone_20200417_cheyenne_3.7.5/lib/python3.7/site-packages/metpy/xarray.py", line 537, in parse_cf
var = self._fixup_coords(var)
File "/glade/work/jaredlee/python/my_npl_clone_20200417_cheyenne_3.7.5/lib/python3.7/site-packages/metpy/xarray.py", line 566, in _fixup_coords
var = var.metpy.convert_coordinate_units(coord_name, 'meter')
File "/glade/work/jaredlee/python/my_npl_clone_20200417_cheyenne_3.7.5/lib/python3.7/site-packages/metpy/xarray.py", line 159, in convert_coordinate_units
data=self._data_array[coord].metpy.unit_array.m_as(units)
File "/glade/work/jaredlee/python/my_npl_clone_20200417_cheyenne_3.7.5/lib/python3.7/site-packages/metpy/xarray.py", line 135, in unit_array
return self._data_array.values * self.units
File "/glade/work/jaredlee/python/my_npl_clone_20200417_cheyenne_3.7.5/lib/python3.7/site-packages/pint/quantity.py", line 1540, in __array_ufunc__
return numpy_wrap("ufunc", ufunc, inputs, kwargs, types)
File "/glade/work/jaredlee/python/my_npl_clone_20200417_cheyenne_3.7.5/lib/python3.7/site-packages/pint/numpy_func.py", line 894, in numpy_wrap
return handled[name](*args, **kwargs)
File "/glade/work/jaredlee/python/my_npl_clone_20200417_cheyenne_3.7.5/lib/python3.7/site-packages/pint/numpy_func.py", line 289, in implementation
result_magnitude = func(*stripped_args, **stripped_kwargs)
numpy.core._exceptions.UFuncTypeError: ufunc 'multiply' cannot use operands with types dtype('<M8[ns]') and dtype('int64')
I get the same thing even when I drop the squeeze() function call at the end. Any ideas what's causing this, or how to fix this? This is a standard wrfout file from WRF v4.2. I know WRF unfortunately doesn't follow CF-compliant conventions, and that's probably what's causing this problem, but surely this is a problem that others have had, so I'm hoping someone can help point me in the right direction here so that I could still hopefully use MetPy for WRF cross-section plots.