Repository: NCAR/geocat-comp

Issue:
Upstream CI: Pint 
In the most recent releases of geocat-comp, we've opted for pinning pint to >0.20, but we'll need to update our codebase to reflect the most recent update.

See [failing upstream CI tests](https://github.com/NCAR/geocat-comp/actions/runs/3560640392/jobs/5980811808#step:6:152)

Discussion:

Patch:
diff --git a/build_envs/docs.yml b/build_envs/docs.yml
index ff1762e..436bd62 100644
--- a/build_envs/docs.yml
+++ b/build_envs/docs.yml
@@ -9,7 +9,7 @@ dependencies:
     - geocat-viz
     - xarray
     - netcdf4
-    - pint<0.20
+    - pint
     - ipykernel
     - ipython
     - jupyter_client
diff --git a/build_envs/environment.yml b/build_envs/environment.yml
index 205c76d..80f37ed 100644
--- a/build_envs/environment.yml
+++ b/build_envs/environment.yml
@@ -11,7 +11,7 @@ dependencies:
   - geocat-f2py
   - metpy
   - numpy
-  - pint<0.20           # pint 0.20+ currently breaks geocat-comp
+  - pint
   - xarray
   - xskillscore
 # Packages listed below are for testing
diff --git a/docs/user_api/index.rst b/docs/user_api/index.rst
index ef4d086..cc4e6d0 100644
--- a/docs/user_api/index.rst
+++ b/docs/user_api/index.rst
@@ -59,7 +59,6 @@ Meteorology
    relhum_water
    saturation_vapor_pressure
    saturation_vapor_pressure_slope
-   showalter_index
 
 Spherical Harmonics
 ^^^^^^^^^^^^^^^^^^^
@@ -127,6 +126,15 @@ EOF Functions
    eofunc_eofs
    eofunc_pcs
 
+Meteorology
+^^^^^^^^^^^
+.. currentmodule:: geocat.comp.meteorology
+.. autosummary::
+   :nosignatures:
+   :toctree: ./generated/
+
+   showalter_index
+
 Polynomial
 ^^^^^^^^^^
 .. currentmodule:: geocat.comp.polynomial
diff --git a/src/geocat/comp/meteorology.py b/src/geocat/comp/meteorology.py
index 135301c..b8a608b 100644
--- a/src/geocat/comp/meteorology.py
+++ b/src/geocat/comp/meteorology.py
@@ -1,7 +1,7 @@
 import dask.array as da
 import metpy.calc as mpcalc
 import numpy as np
-import pint.quantity
+import pint
 import typing
 import warnings
 import xarray as xr
@@ -995,9 +995,15 @@ def relhum_water(temperature: typing.Union[np.ndarray, list, float],
     return relative_humidity
 
 
-def showalter_index(pressure: pint.Quantity, temperature: pint.Quantity,
-                    dewpt: pint.Quantity) -> pint.Quantity:
-    """Calculate Showalter Index from pressure temperature and 850 hPa lcl.
+def showalter_index(
+        pressure: typing.Union[pint.Quantity, list, float, int],
+        temperature: typing.Union[pint.Quantity, list, float, int],
+        dewpt: typing.Union[pint.Quantity, list, float, int]) -> pint.Quantity:
+    r"""
+    .. deprecated:: 2022.12.0 ``showalter_index`` is deprecated. Use ``metpy.calc.showalter_index``
+        instead. See the MetPy `documentation <https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.showalter_index.html>`_.
+
+    Calculate Showalter Index from pressure temperature and 850 hPa lcl.
     Showalter Index derived from `Gallway 1956 <https://journals.ametsoc.org/do
     wnloadpdf/journals/bams/37/10/1520-0477-37_10_528.xml>`__.
 
@@ -1008,21 +1014,37 @@ def showalter_index(pressure: pint.Quantity, temperature: pint.Quantity,
 
     Parameters
     ----------
-    pressure : :class:`pint.Quantity`
+    pressure : :class:`pint.Quantity`, array-like, int, float
         Atmospheric pressure level(s) of interest, in order from highest
-        to lowest pressure
-    temperature : :class:`pint.Quantity`
-        Parcel temperature for corresponding pressure
-    dewpt : :class:`pint.Quantity`
-        Parcel dew point temperatures for corresponding pressure
+        to lowest pressure in hectoPascals
+    temperature : :class:`pint.Quantity`, array-like, int, float
+        Parcel temperature for corresponding pressure in degrees Celcius
+    dewpt : :class:`pint.Quantity`, array-like, int, float
+        Parcel dew point temperatures for corresponding pressure in degrees Celcius
 
     Returns
     -------
-    shox : :class:`pint.Quantity`
-       Showalter index in delta degrees celsius
+    shox : same type as input
+       Showalter index in delta degrees Celsius
+
+    Note
+    ----
+    ``pressure``, ``temperature``, and ``dewpt`` must all be ``pint.Quantity`` objects or all plain, unitless numbers.
     """
-    shox = mpcalc.showalter_index(pressure, temperature, dewpt)
-    return shox
+    warnings.warn(
+        'showalter_index is deprecated in favor of metpy.calc.showalter_index',
+        DeprecationWarning,
+        stacklevel=2)
+
+    if not (isinstance(pressure, pint.Quantity)\
+            and isinstance(temperature, pint.Quantity)\
+            and isinstance(dewpt, pint.Quantity)):
+        pressure = pressure * units.hPa
+        temperature = temperature * units.degC
+        dewpt = dewpt * units.degC
+        return mpcalc.showalter_index(pressure, temperature, dewpt).magnitude
+    else:
+        return mpcalc.showalter_index(pressure, temperature, dewpt)
 
 
 def max_daylight(
diff --git a/src/geocat/comp/skewt_params.py b/src/geocat/comp/skewt_params.py
index c5a030b..1968a61 100644
--- a/src/geocat/comp/skewt_params.py
+++ b/src/geocat/comp/skewt_params.py
@@ -2,18 +2,17 @@ from itertools import chain
 
 import metpy.calc as mpcalc
 import numpy as np
-import pint.quantity
 from metpy.units import units
+import pint
 import warnings
 from .meteorology import showalter_index as showalter
 
 
 def showalter_index(pressure: pint.Quantity, temperature: pint.Quantity,
                     dewpt: pint.Quantity) -> pint.Quantity:
-    r""".. deprecated:: 2022.10.0 The ``skewt_params`` module is deprecated, and
-        ``showalter_index`` has been moved to the ``meteorology`` module for future
-        use. Use ``geocat.comp.showalter_index`` or ``geocat.comp.meteorology.showalter_index``
-        for the same functionality.
+    r""".. deprecated:: 2022.10.0 The ``skewt_params`` module is deprecated.
+        Use ``metpy.calc.showalter_index`` instead. See the MetPy
+        `documentation <https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.showalter_index.html>`_.
 
     Calculate Showalter Index from pressure temperature and 850 hPa lcl.
     Showalter Index derived from `Gallway 1956 <https://journals.ametsoc.org/do


Test patch:
diff --git a/test/test_meteorology.py b/test/test_meteorology.py
index b1f0ef8..90067be 100644
--- a/test/test_meteorology.py
+++ b/test/test_meteorology.py
@@ -319,15 +319,20 @@ class Test_showalter_index(unittest.TestCase):
     NCL_shox = int(Shox[0])  # Convert to int
 
     def test_shox_vals(self):
-        # Showalter index
-        shox = showalter_index(self.p, self.tc, self.tdc)
-        shox = shox[0].magnitude
-
-        # Place calculated values in iterable list
-        vals = np.round(shox).astype(int)
-
-        # Compare calculated values with expected
-        np.testing.assert_equal(vals, self.NCL_shox)
+        self.assertWarns(DeprecationWarning)
+        parameters = [((self.p, self.tc, self.tdc),
+                       units.Quantity(self.NCL_shox, 'delta_degree_Celsius')),
+                      ((self.p.magnitude, self.tc.magnitude,
+                        self.tdc.magnitude), self.NCL_shox)]
+        for params in parameters:
+            # Showalter index
+            shox = showalter_index(*params[0])
+
+            # Place calculated values in iterable list
+            vals = np.round(shox).astype(int)
+
+            # Compare calculated values with expected
+            np.testing.assert_equal(vals, params[1])
 
 
 class Test_actual_saturation_vapor_pressure(unittest.TestCase):