diff --git a/docs/conf.py b/docs/conf.py index e17a7684..5cb1b961 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,6 +12,8 @@ # # -- Project information ----------------------------------------------------- +import datetime +import geocat.viz as gv import os import sys import pathlib @@ -22,8 +24,6 @@ print("sys.path:", sys.path) -import geocat.viz as gv - LOGGER = logging.getLogger("conf") try: @@ -128,7 +128,7 @@ def __getattr__(cls, name): # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: -# source_suffix = ['.rst', '.md'] +#source_suffix = ['.rst', '.md'] source_suffix = { '.rst': 'restructuredtext', '.ipynb': 'myst-nb', @@ -144,8 +144,6 @@ def __getattr__(cls, name): # General information about the project. project = u'GeoCAT-viz' -import datetime - current_year = datetime.datetime.now().year copyright = u'{}, University Corporation for Atmospheric Research'.format( current_year) @@ -326,7 +324,7 @@ def __getattr__(cls, name): nb_execution_mode = "off" # generate warning for all invalid links -# nitpicky = True +#nitpicky = True # Allow for changes to be made to the css in the theme_overrides file diff --git a/docs/user_api/index.rst b/docs/user_api/index.rst index ff97e86d..ba6df7f1 100644 --- a/docs/user_api/index.rst +++ b/docs/user_api/index.rst @@ -42,12 +42,25 @@ GeoCAT-viz Utility Functions set_map_boundary - findLocalExtrema + find_local_extrema - plotCLabels + plot_contour_labels - plotELabels + plot_extrema_labels set_vector_density get_skewt_vars + +Deprecated Functions +-------------------- +Util +^^^^^^^^^^^^^ +.. currentmodule:: geocat.viz.util +.. autosummary:: + :nosignatures: + :toctree: ./generated/ + + findLocalExtrema + plotCLabels + plotELabels diff --git a/gallery/util/add_height_from_pressure_axis.ipynb b/gallery/util/add_height_from_pressure_axis.ipynb new file mode 100644 index 00000000..d37b2479 --- /dev/null +++ b/gallery/util/add_height_from_pressure_axis.ipynb @@ -0,0 +1,100 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "# Import Packages:\n", + "\n", + "import numpy as np\n", + "import xarray as xr\n", + "import matplotlib.pyplot as plt\n", + "from matplotlib.ticker import ScalarFormatter\n", + "import cmaps\n", + "import metpy.calc as mpcalc\n", + "from metpy.units import units\n", + "\n", + "import scipy\n", + "\n", + "#import geocat.datafiles as gdf\n", + "import geocat.viz as gv" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "# Open a netCDF data file using xarray default engine and load the data into xarrays\n", + "ds = xr.open_dataset(gdf.get(\"netcdf_files/mxclim.nc\"))\n", + "\n", + "# Extract variables\n", + "U = ds.U[0, :, :]" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAscAAAKTCAYAAAD16aXPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAm0ElEQVR4nO3de3CV9Z348c+BYEAEagQxkoBAFQ3eA1FxLegqjF21yjLq2kHb6mxxqYWl9YqrLeOOl13RaqNr6w1n1MUbbsfBC2UNYu0satGq0alyTVREYOQSQQSe3x/9kl+5Kbmf4Os1k5me5zznfD/0O9i3T895ksuyLAsAACA6tPUAAACQL8QxAAAk4hgAABJxDAAAiTgGAIBEHAMAQCKOAQAgKWjrARpq06ZNMX/+/Ojdu3d06KDtAQDyzZYtW+KTTz6JY445JgoK2ldutq9pI2L+/PlRUVHR1mMAAPA15s2bF0OHDm3rMRqk3cVx7969I+Kv/2UXFxe38TQAAGzv448/joqKivpua0/aXRxv/ShFcXFxlJSUtPE0AADsSnv8CGz7mxgAAFqIOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACBpkzg+55xzYt99940xY8a0xfIAALBTbRLHP/3pT+Ohhx5qi6UBAGCX2iSOTz755OjW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xwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACQFbT0AAAB8neXLl8eSJUvi008/jfXr10fPnj2jV69eMWjQoOjYsWOzrSOOAQDIS7NmzYrp06fHSy+9FAsWLNjpOXvvvXccf/zxMWrUqBg7dmz07t27SWvmsizLmvQOray2tjZKS0ujpqYmSkpK2nocAAC205Re27BhQ9x5551x9913x5IlS2Jrqnbp0iX233//KCoqii5dusSqVati1apVsXz58oiIyOVyUVBQEGeccUZcc801UV5e3qjZXTkGACAv3H///XH99dfHhx9+GIWFhXHWWWfFGWecERUVFTF48ODo0GHHr8utWrUq5s2bFy+//HI89thjMWPGjHj66afj3HPPjZtuuin69evXoBlcOQYAoFk1ttc6dOgQAwYMiCuuuCLOP//86N69e4PXfv311+OOO+6IRx99NK699tq47rrrGvR6V44BAMgL06ZNiwsuuKBJX7ArLy+PadOmxS9+8Yuora1t8OvbTRxXVlZGZWVlbNy4sa1HAQCgBYwdO7bZ3qt///7Rv3//Br+u3dznePz48VFdXR1VVVVtPQoAAHuodhPHAADQ0trNxyoAAPjmev755+O5556LhQsXxrp162JX95TI5XIxe/bsRq8jjgEAyFtr1qyJs88+O+bMmbPLIP5buVyuSeuJYwAA8taVV14ZVVVVUVRUFP/8z/8cxxxzTPTq1avJEbwr4hgAgLz11FNPRadOnWLOnDkxePDgFl/PF/IAAMhbdXV1MWjQoFYJ4whxDABAHjv00ENj/fr1rbaeOAYAIG+NHz8+FixY0Gq/60IcAwCQt374wx/GZZddFqNHj44777wz1q1b16Lr+UIeAAB57ZZbbomampqYOHFiTJw4MXr16hV77733Ts/N5XKxYMGCRq8ljgEAyFuffPJJnHrqqVFdXV1/n+Ply5fv8nz3OQYAYI915ZVXxjvvvBPf/va34/LLL4+jjz7afY4BAPhmeu6556Jz585RVVUVBx54YIuv5wt5AADkrbq6ujj00ENbJYwjxDEAAHnsiCOOiJUrV7baeuIYAIC8dfnll0dNTU089thjrbKeOAYAIG+dc845cccdd8Qll1wSP/vZz+Kdd96JDRs2tNh6vpAHAEDe6tixY/1/vv322+P222//yvNzuVxs2rSp0euJYwAA8tbWexu31PnbE8cAAOStLVu2tOp6PnMMAACJOAYAIG+9+eabDTr/rrvuatJ64hgAgLw1atSoeP/993fr3Ntuuy0uu+yyJq0njgEAyFvLly+P0047LWpqar7yvJtuuil+9rOfRdeuXZu0njgGACBv3XLLLbF06dI49dRTY/ny5Ts95xe/+EVcc8010a1bt3j22WebtJ44BgAgb/385z+Pa6+9Nt5///0YOXJkfPbZZ9s8f/XVV8eUKVOiR48eMWvWrDjxxBObtJ44BgAgr02ZMiUuu+yy+POf/xynn3561NXVRUTEpEmT4uabb46ioqKYPXt2VFRUNHkt9zkGACDv/epXv4o1a9bEtGnT4swzz4xBgwbFPffcE7169Yrf//73ccQRRzTLOuIYAIB24b777ou1a9fGU089FXPmzIkDDjggZs+eHYcddlizrSGOAQDIC0uXLv3ac2688cZYvHhxLFiwIB566KHo2rXrDq/r27dvo2cQxwAA5IWDDjoocrncbp8/atSoHY7lcrnYtGlTo2cQxwAA5IW+ffs2KI5bgjgGACAvLF68uK1HcCs3AADYShwDAEAijgEAyAu1tbXN+n4fffRRg18jjgEAyAsDBw6MSy+9NJYsWdLo99iyZUs88sgjMXjw4Lj33nsb/HpxDABAXvje974X99xzTwwcODD+/u//Pu69997duvr75ZdfxiuvvBITJkyIPn36xNixY2P16tVx0kknNXgGd6sAACAvPPbYY/Hqq6/GVVddFS+++GJUVVVFRERxcXGUl5dHcXFxFBUVRWFhYXz22WexatWqePfdd+Ott96KjRs3RpZlse+++8YNN9wQEydOjC5dujR4BnEMAEDeGDp0aMyePTvee++9uOeee+Lxxx+Pjz76qP4K8tb7IGdZVv+aTp06xfDhw+Piiy+OMWPGRGFhYaPXz2V/+87tQG1tbZSWlkZNTU2UlJS09TgAAGynuXttwYIF8corr8SSJUtixYoVsWHDhigqKor9998/jj766DjuuOMadZV4Z1w5BgAgrw0cODAGDhzYKmv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YAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBAIo4BACARxwAAkIhjAABIxDEAACTiGAAAEnEMAACJOAYAgEQcAwBA0iZx/Mwzz8SgQYPi4IMPjnvvvbctRgAAgB0UtPaCmzZtikmTJsWLL74Y3bt3j2OPPTZGjx4dRUVFrT0KAABso9WvHM+bNy8GDx4cffr0iW7dusV3v/vdeP7551t7DAAA2EGD4/ill16KM888Mw488MDI5XLx9NNP73DOXXfdFf3794/OnTtHeXl5zJ07t/65jz76KPr06VP/uKSkJD788MPGTQ8AAM2owXFcV1cXRx11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XZvPnz8/mz5+fRUQ2derUbP78+fW37mvPvZZ3cZxlWVZZWZn169cv22uvvbJjjz02mzNnTv1zF110UTZ8+PBtzq+qqsqOOeaYbK+99soOOuig7O67727liWmKhuz38OHDs4jY4eeiiy5q/cFplIb+/f5b4rj9aeh+v/vuu9mpp56adenSJSspKckmTZqUff755608NY3V0P2+4447srKysqxLly5ZcXFx9v3vfz+rra1t5alpjBdffPEr//e4PfdaLsv8fxcAABCRZ585BgCAtiSOAQAgEccAAJCIYwAASMQxAAAk4hgAABJxDAAAiTgGAIBEHAMAQCKOAQAgEccAAJD8P07w49W+NtKxAAAAAElFTkSuQmCC", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Generate figure (set its size (width, height) in inches) and axes\n", + "plt.figure(figsize=(8, 8))\n", + "ax = plt.axes()\n", + "\n", + "# Set y-axis to have log-scale\n", + "plt.yscale('log')\n", + "\n", + "# Specify which contours should be drawn\n", + "levels = np.linspace(-55, 55, 23)\n", + "\n", + "# Plot contour lines\n", + "lines = U.plot.contour(ax=ax,\n", + " levels=levels,\n", + " colors='black',\n", + " linewidths=0.5,\n", + " linestyles='solid',\n", + " add_labels=False)\n", + "\n", + "# Create second y-axis to show geo-potential height.\n", + "axRHS = gv.add_height_from_pressure_axis(ax, heights=[4, 8])\n", + "\n", + "plt.show();" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "geocat_viz_build", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.0" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/src/geocat/viz/taylor.py b/src/geocat/viz/taylor.py index 3100a89a..f4abde50 100644 --- a/src/geocat/viz/taylor.py +++ b/src/geocat/viz/taylor.py @@ -159,20 +159,20 @@ def __init__(self, self.ax = ax.get_aux_axes(tr) # Polar coordinates # Add reference point stddev contour - t = np.linspace(0, np.pi / 2) - r = np.zeros_like(t) + self.refstd - h, = self.ax.plot(t, - r, - linewidth=1, - linestyle=(0, (9, 5)), - color='black', - zorder=1) + t_array = np.linspace(0, np.pi / 2) + r_array = np.zeros_like(t_array) + self.refstd + h_plot, = self.ax.plot(t_array, + r_array, + linewidth=1, + linestyle=(0, (9, 5)), + color='black', + zorder=1) # Set aspect ratio self.ax.set_aspect('equal') # Store the reference line - self.referenceLine = h + self.referenceLine = h_plot # Collect sample points for latter use (e.g. legend) self.modelMarkerSet = [] @@ -317,8 +317,8 @@ def add_model_set(self, else: label = kwargs.get('label') if percent_bias_on: - handle = plt.scatter(1, 2, color=color, label=label) - self.modelMarkerSet.append(handle) + plot_handle = plt.scatter(1, 2, color=color, label=label) + self.modelMarkerSet.append(plot_handle) # Annotate model markers if annotate_on is True if annotate_on: @@ -461,15 +461,15 @@ def add_ygrid(self, - `NCL_taylor_2.py `_ """ - t = np.linspace(0, np.pi / 2) + t_array = np.linspace(0, np.pi / 2) for value in arr: - r = np.zeros_like(t) + value - h, = self.ax.plot(t, - r, - color=color, - linestyle=linestyle, - linewidth=linewidth, - **kwargs) + r_array = np.zeros_like(t_array) + value + h_plot, = self.ax.plot(t_array, + r_array, + color=color, + linestyle=linestyle, + linewidth=linewidth, + **kwargs) def add_grid(self, *args, **kwargs): """Add a grid. diff --git a/src/geocat/viz/util.py b/src/geocat/viz/util.py index 578a826c..10a98c12 100644 --- a/src/geocat/viz/util.py +++ b/src/geocat/viz/util.py @@ -841,7 +841,8 @@ def set_map_boundary(ax: matplotlib.axes.Axes, [(lon_range[1], lat) for lat in range(lat_range[0], lat_range[1] + 1, res)] + \ [(lon, lat_range[1]) for lon in range(lon_range[1], -180 - 1, -res)] + \ [(lon, lat_range[1]) for lon in range(180, lon_range[0] - 1, -res)] + \ - [(lon_range[0], lat) for lat in range(lat_range[1], lat_range[0] - 1, -res)] + [(lon_range[0], lat) + for lat in range(lat_range[1], lat_range[0] - 1, -res)] path = mpath.Path(vertices) elif ((lon_range[0] == 180 or lon_range[0] == -180) and (lon_range[1] == 180 or lon_range[1] == -180)): @@ -851,7 +852,8 @@ def set_map_boundary(ax: matplotlib.axes.Axes, vertices = [(lon, lat_range[0]) for lon in range(lon_range[0], lon_range[1] + 1, res)] + \ [(lon_range[1], lat) for lat in range(lat_range[0], lat_range[1] + 1, res)] + \ [(lon, lat_range[1]) for lon in range(lon_range[1], lon_range[0] - 1, -res)] + \ - [(lon_range[0], lat) for lat in range(lat_range[1], lat_range[0] - 1, -res)] + [(lon_range[0], lat) + for lat in range(lat_range[1], lat_range[0] - 1, -res)] path = mpath.Path(vertices) proj_to_data = ccrs.PlateCarree()._as_mpl_transform(ax) - ax.transData @@ -869,6 +871,63 @@ def findLocalExtrema(da: xr.DataArray, lowVal: int = 1000, eType: str = 'Low', eps: float = 10) -> list: + r""".. deprecated:: 2023.02.0 The ``findLocalExtrema`` function is deprecated due to naming conventions. Use :func:`find_local_extrema` instead. + + Utility function to find local low/high field variable coordinates on a + contour map. To classify as a local high, the data point must be greater + than highval, and to classify as a local low, the data point must be less + than lowVal. + + Parameters + ---------- + da : :class:`xarray.DataArray` + Xarray data array containing the lat, lon, and field variable (ex. pressure) data values + + highVal : int + Data value that the local high must be greater than to qualify as a "local high" location. + Default highVal is 0. + + lowVal : int + Data value that the local low must be less than to qualify as a "local low" location. + Default lowVal is 1000. + + eType : str + 'Low' or 'High' + Determines which extrema are being found- minimum or maximum, respectively. + Default eType is 'Low'. + + eps : float + Parameter supplied to sklearn.cluster.DBSCAN determining the maximum distance between two samples + for one to be considered as in the neighborhood of the other. + Default eps is 10. + + Returns + ------- + clusterExtremas : list + List of coordinate tuples in GPS form (lon in degrees, lat in degrees) + that specify local low/high locations + + Examples + -------- + All usage examples are within the GeoCAT-Examples Gallery. To see more usage cases, search the function on the `website `_. + + - `NCL_sat_1.py `_ + + - `NCL_sat_2.py `_ + """ + + warnings.warn( + 'This function is deprecated. Call `find_local_extrema` instead.', + PendingDeprecationWarning) + + return find_local_extrema(da, highVal, lowVal, eType, eps) + + +def find_local_extrema(da: xr.DataArray, + highVal: int = 0, + lowVal: int = 1000, + eType: str = 'Low', + eps: float = 10) -> list: """Utility function to find local low/high field variable coordinates on a contour map. To classify as a local high, the data point must be greater than highval, and to classify as a local low, the data point must be less @@ -962,19 +1021,19 @@ def findLocalExtrema(da: xr.DataArray, for key in coordsAndLabels: # Create array to hold all the field variable values for that cluster - datavals = [] + data_vals = [] for coord in coordsAndLabels[key]: # Find pressure data at that coordinate cond = np.logical_and(coordarr[:, :, 0] == coord[0], coordarr[:, :, 1] == coord[1]) x, y = np.where(cond) - datavals.append(da.data[x[0]][y[0]]) + data_vals.append(da.data[x[0]][y[0]]) # Find the index of the smallest/greatest field variable value of each cluster if eType == 'Low': - index = np.argmin(np.array(datavals)) + index = np.argmin(np.array(data_vals)) if eType == 'High': - index = np.argmax(np.array(datavals)) + index = np.argmax(np.array(data_vals)) # Append the coordinate corresponding to that index to the array to be returned clusterExtremas.append( @@ -991,6 +1050,72 @@ def plotCLabels(ax: matplotlib.axes.Axes, fontsize: int = 12, whitebbox: bool = False, horizontal: bool = False) -> list: + r""".. deprecated:: 2023.02.0 The ``plotCLabels`` function is deprecated due to naming conventions. Use :func:`plot_contour_levels` instead. + + Utility function to plot contour labels by passing in a coordinate to + the clabel function. + + This allows the user to specify the exact locations of the labels, rather than having matplotlib + plot them automatically. + + + Parameters + ---------- + ax : :class:`matplotlib.axes.Axes` + Axis containing the contour set. + + contours : :class:`matplotlib.contour.QuadContourSet` + Contour set that is being labeled. + + transform : :class:`cartopy.crs.CRS` + Instance of CRS that represents the source coordinate system of coordinates. + (ex. ccrs.Geodetic()). + + proj : :class:`cartopy.crs.CRS` + Projection 'ax' is defined by. + This is the instance of CRS that the coordinates will be transformed to. + + clabel_locations : list + List of coordinate tuples in GPS form (lon in degrees, lat in degrees) + that specify where the contours with regular field variable values should be plotted. + + fontsize : int + Font size of contour labels. + + whitebbox : bool + Setting this to "True" will cause all labels to be plotted with white backgrounds + + horizontal : bool + Setting this to "True" will cause the contour labels to be horizontal. + + Returns + ------- + cLabels : list + List of text instances of all contour labels + + Examples + -------- + All usage examples are within the GeoCAT-Examples Gallery. To see more usage cases, search the function on the `website `_. + + - `NCL_sat_1.py `_ + """ + + warnings.warn( + 'This function is deprecated. Call `plot_contour_labels` instead.', + PendingDeprecationWarning) + + return plot_contour_labels(ax, contours, transform, proj, clabel_locations, + fontsize, whitebbox, horizontal) + + +def plot_contour_labels(ax: matplotlib.axes.Axes, + contours, + transform: cartopy.crs.CRS, + proj: cartopy.crs.CRS, + clabel_locations: list = [], + fontsize: int = 12, + whitebbox: bool = False, + horizontal: bool = False) -> list: """Utility function to plot contour labels by passing in a coordinate to the clabel function. @@ -1053,7 +1178,7 @@ def plotCLabels(ax: matplotlib.axes.Axes, inline=True, fontsize=fontsize, colors='black', - fmt="%.0f") + fmt='%.0f') [cLabels.append(txt) for txt in contours.labelTexts] if horizontal is True: @@ -1076,6 +1201,74 @@ def plotELabels(da: xr.DataArray, fontsize: int = 22, whitebbox: bool = False, horizontal: bool = True) -> list: + r""".. deprecated:: 2023.02.0 The ``plotELabels`` function is deprecated due to naming conventions. Use :func:`plot_extrema_labels` instead. + + Utility function to plot high/low contour labels. + + High/Low contour labels will be plotted using text boxes for more accurate label values + and placement. + This function is exemplified in the python version of `sat_1_lg `__ + + Parameters + ---------- + da : :class:`xarray.DataArray` + Xarray data array containing the lat, lon, and field variable data values. + + transform : :class:`cartopy.crs.CRS` + Instance of CRS that represents the source coordinate system of coordinates. + (ex. ccrs.Geodetic()). + + proj : :class:`cartopy.crs.CRS` + Projection 'ax' is defined by. + This is the instance of CRS that the coordinates will be transformed to. + + clabel_locations : list + List of coordinate tuples in GPS form (lon in degrees, lat in degrees) + that specify where the contour labels should be plotted. + + label : str + ex. 'L' or 'H' + The data value will be plotted as a subscript of this label. + + fontsize : int + Font size of regular contour labels. + + horizontal : bool + Setting this to "True" will cause the contour labels to be horizontal. + + whitebbox : bool + Setting this to "True" will cause all labels to be plotted with white backgrounds + + Returns + ------- + extremaLabels : list + List of text instances of all contour labels + + Examples + -------- + All usage examples are within the GeoCAT-Examples Gallery. To see more usage cases, search the function on the `website `_. + + - `NCL_sat_1.py `_ + + - `NCL_sat_2.py `_ + """ + + warnings.warn( + 'This function is deprecated. Please use `plot_extrema_labels` instead.', + PendingDeprecationWarning) + + return plot_extrema_labels(da, transform, proj, clabel_locations, label, + fontsize, whitebbox, horizontal) + + +def plot_extrema_labels(da: xr.DataArray, + transform: cartopy.crs.CRS, + proj: cartopy.crs.CRS, + label_locations: list = [], + label: str = 'L', + fontsize: int = 22, + whitebbox: bool = False, + horizontal: bool = True) -> list: """Utility function to plot contour labels. High/Low contour labels will be plotted using text boxes for more accurate label values @@ -1095,7 +1288,7 @@ def plotELabels(da: xr.DataArray, Projection 'ax' is defined by. This is the instance of CRS that the coordinates will be transformed to. - clabel_locations : list + label_locations : list List of coordinate tuples in GPS form (lon in degrees, lat in degrees) that specify where the contour labels should be plotted. @@ -1140,23 +1333,23 @@ def plotELabels(da: xr.DataArray, # Plot any low contour levels clabel_points = proj.transform_points( - transform, np.array([x[0] for x in clabel_locations]), - np.array([x[1] for x in clabel_locations])) + transform, np.array([x[0] for x in label_locations]), + np.array([x[1] for x in label_locations])) transformed_locations = [(x[0], x[1]) for x in clabel_points] - for x in range(len(transformed_locations)): + for loc in range(len(transformed_locations)): try: # Find field variable data at that coordinate - coord = clabel_locations[x] + coord = label_locations[loc] cond = np.logical_and(coordarr[:, :, 0] == coord[0], coordarr[:, :, 1] == coord[1]) - z, y = np.where(cond) - p = int(round(da.data[z[0]][y[0]])) + z_loc, y_loc = np.where(cond) + p_loc = int(round(da.data[z_loc[0]][y_loc[0]])) - lab = plt.text(transformed_locations[x][0], - transformed_locations[x][1], - label + "$_{" + str(p) + "}$", + lab = plt.text(transformed_locations[loc][0], + transformed_locations[loc][1], + label + '$_{' + str(p_loc) + '}$', fontsize=fontsize, horizontalalignment='center', verticalalignment='center') @@ -1206,7 +1399,7 @@ def set_vector_density(data: xr.DataArray, import warnings if minDistance <= 0: - raise Exception("minDistance cannot be negative or zero.") + raise Exception('minDistance cannot be negative or zero.') else: lat_every = 1 lon_every = 1 @@ -1248,22 +1441,59 @@ def set_vector_density(data: xr.DataArray, return ds -def get_skewt_vars(p: Quantity, tc: Quantity, tdc: Quantity, - pro: Quantity) -> str: +def get_skewt_vars(pressure: Quantity = None, + temperature: Quantity = None, + dewpoint: Quantity = None, + profile: Quantity = None, + p: Quantity = None, + tc: Quantity = None, + tdc: Quantity = None, + pro: Quantity = None) -> str: """This function processes the dataset values and returns a string element which can be used as a subtitle to replicate the styles of NCL Skew-T Diagrams. Parameters ---------- + pressure : :class:`pint.Quantity` + Pressure level input from dataset. Renamed from deprecated kwarg `p`. + temperature : :class:`pint.Quantity` + Temperature for parcel from dataset. Renamed from deprecated kwarg `tc`. + dewpoint : :class:`pint.Quantity` + Dew point temperature for parcel from dataset. Renamed from deprecated kwarg `tdc`. + profile : :class:`pint.Quantity` + Parcel profile temperature converted to degC. Renamed from deprecated kwarg `pro`. p : :class:`pint.Quantity` - Pressure level input from dataset + Pressure level input from dataset. + + .. deprecated:: 2023.06.0 + In an effort to refactor the codebase to follow naming conventions, + keyword arguments have been renamed to more meaningful values. + ``p`` parameter has been deprecated in favor of ``pressure`. + tc : :class:`pint.Quantity` - Temperature for parcel from dataset + Temperature for parcel from dataset. + + .. deprecated:: 2023.06.0 + In an effort to refactor the codebase to follow naming conventions, + keyword arguments have been renamed to more meaningful values. + ``tc`` parameter has been deprecated in favor of ``temperature``. + tdc : :class:`pint.Quantity` - Dew point temperature for parcel from dataset + Dew point temperature for parcel from dataset. + + .. deprecated:: 2023.06.0 + In an effort to refactor the codebase to follow naming conventions, + keyword arguments have been renamed to more meaningful values. + ``tdc`` parameter has been deprecated in favor of ``dewpoint``. + pro : :class:`pint.Quantity` - Parcel profile temperature converted to degC + Parcel profile temperature converted to degC. + + .. deprecated:: 2023.06.0 + In an effort to refactor the codebase to follow naming conventions, + keyword arguments have been renamed to more meaningful values. + ``pro`` parameter has been deprecated in favor of ``profile``. Returns ------- @@ -1281,40 +1511,61 @@ def get_skewt_vars(p: Quantity, tc: Quantity, tdc: Quantity, `skewT_PlotData `_, `skewt_BackGround `_ - Examples + Examples -------- All usage examples are within the GeoCAT-Examples Gallery. To see more usage cases, search the function on the `website `_. - `NCL_skewt_2_2 `_ """ + # Support for deprecating kwargs + if p: + pressure = p + warnings.warn( + 'The keyword argument `p` is deprecated. Use `pressure` instead.', + PendingDeprecationWarning) + if tc: + temperature = tc + warnings.warn( + 'The keyword argument `tc` is deprecated. Use `temperature` instead.', + PendingDeprecationWarning) + if tdc: + dewpoint = tdc + warnings.warn( + 'The keyword argument `tdc` is deprecated. Use `dewpoint` instead.', + PendingDeprecationWarning) + if pro: + profile = pro + warnings.warn( + 'The keyword argument `pro` is deprecated. Use `profile` instead.', + PendingDeprecationWarning) # CAPE - cape = mpcalc.cape_cin(p, tc, tdc, pro) + cape = mpcalc.cape_cin(pressure, temperature, dewpoint, profile) cape = cape[0].magnitude # Precipitable Water - pwat = mpcalc.precipitable_water(p, tdc) + pwat = mpcalc.precipitable_water(pressure, dewpoint) pwat = (pwat.magnitude / 10) * units.cm # Convert mm to cm pwat = pwat.magnitude # Pressure and temperature of lcl - lcl = mpcalc.lcl(p[0], tc[0], tdc[0]) + lcl = mpcalc.lcl(pressure[0], temperature[0], dewpoint[0]) plcl = lcl[0].magnitude tlcl = lcl[1].magnitude # Showalter index - shox = mpcalc.showalter_index(p, tc, tdc) + shox = mpcalc.showalter_index(pressure, temperature, dewpoint) shox = shox[0].magnitude # Place calculated values in iterable list - vals = [plcl, tlcl, shox, pwat, cape] - vals = np.round(vals).astype(int) + val_list = [plcl, tlcl, shox, pwat, cape] + val_ints = np.round(val_list).astype(int) # Define variable names for calculated values names = ['Plcl=', 'Tlcl[C]=', 'Shox=', 'Pwat[cm]=', 'Cape[J]='] # Combine the list of values with their corresponding labels - lst = list(chain.from_iterable(zip(names, vals))) + lst = list(chain.from_iterable(zip(names, val_ints))) lst = map(str, lst) # Create one large string for later plotting use