From ab69d766d99443766e87e799c016092d207df4f6 Mon Sep 17 00:00:00 2001 From: syedhamidali Date: Tue, 17 Sep 2024 00:21:02 -0400 Subject: [PATCH 1/3] FIX: Fix errors in docstrings and comments in CAPPI and MAX_CAPPI --- examples/plotting/plot_cappi.py | 5 ++--- examples/plotting/plot_max_cappi.py | 2 +- pyart/graph/max_cappi.py | 26 +++++++++++++++++--------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/examples/plotting/plot_cappi.py b/examples/plotting/plot_cappi.py index 7a0b9a17f5..3636ba953e 100644 --- a/examples/plotting/plot_cappi.py +++ b/examples/plotting/plot_cappi.py @@ -7,8 +7,7 @@ and CAPPI (Constant Altitude Plan Position Indicator) plots using radar data. In this example, we load sample radar data, create a CAPPI at 2,000 meters -for the 'reflectivity' field, and then plot -both the PPI and CAPPI for comparison. +for the 'reflectivity' field, and then plot both the PPI and CAPPI for comparison. """ @@ -30,7 +29,7 @@ gatefilter = pyart.filters.GateFilter(radar) gatefilter.exclude_transition() -# Create CAPPI at 2,000 meters for the 'reflectivity' and 'differential_reflectivity' fields +# Create CAPPI at 2,000 meters for the 'reflectivity' field cappi = pyart.retrieve.create_cappi( radar, fields=["reflectivity"], height=2000, gatefilter=gatefilter ) diff --git a/examples/plotting/plot_max_cappi.py b/examples/plotting/plot_max_cappi.py index 823ae95856..3ba1a8c268 100644 --- a/examples/plotting/plot_max_cappi.py +++ b/examples/plotting/plot_max_cappi.py @@ -36,7 +36,7 @@ ######################################### # ** Second Example # -# Let's read in a cfradial file and create a grid. +# Let's read in a Nexrad data and create a grid. import logging diff --git a/pyart/graph/max_cappi.py b/pyart/graph/max_cappi.py index a4dca51f0b..957b8ff435 100644 --- a/pyart/graph/max_cappi.py +++ b/pyart/graph/max_cappi.py @@ -43,7 +43,7 @@ def plot_maxcappi( **kwargs, ): """ - Plots a Constant Altitude Plan Position Indicator (CAPPI) using an xarray Dataset. + Plot a Maximum Constant Altitude Plan Position Indicator (Max-CAPPI) using an xarray Dataset. Parameters ---------- @@ -52,11 +52,11 @@ def plot_maxcappi( field : str The radar field to be plotted (e.g., "REF", "VEL", "WIDTH"). cmap : str or matplotlib colormap, optional - Colormap to use for the plot. Default is "SyedSpectral" if available, otherwise "HomeyerRainbow". + Colormap to use for the plot. Default is "pyart_NWSRef". vmin : float, optional - Minimum value for the color scaling. Default is None, which sets it to the minimum value of the data. + Minimum value for the color scaling. Default is set to the minimum value of the data if not provided. vmax : float, optional - Maximum value for the color scaling. Default is None, which sets it to the maximum value of the data. + Maximum value for the color scaling. Default is set to the maximum value of the data if not provided. title : str, optional Title of the plot. If None, the title is set to "Max-{field}". lat_lines : array-like, optional @@ -66,28 +66,36 @@ def plot_maxcappi( add_map : bool, optional Whether to include a map background in the plot. Default is True. projection : cartopy.crs.Projection, optional - The map projection for the plot. Default is cartopy.crs.LambertAzimuthalEqualArea(). + The map projection for the plot. Default is automatically determined based on dataset coordinates. colorbar : bool, optional Whether to include a colorbar in the plot. Default is True. range_rings : bool, optional - Whether to include range rings at 50 km intervals. Default is True. + Whether to include range rings at 50 km intervals. Default is False. dpi : int, optional DPI (dots per inch) for the plot. Default is 100. savedir : str, optional Directory where the plot will be saved. If None, the plot is not saved. show_figure : bool, optional Whether to display the plot. Default is True. + add_slogan : bool, optional + Whether to add a slogan like "Powered by Py-ART" to the plot. Default is False. **kwargs : dict, optional Additional keyword arguments to pass to matplotlib's `pcolormesh` function. Returns ------- None - This function does not return any value. It generates and optionally displays/saves a plot. + This function does not return any value. It generates and optionally displays or saves a plot. Notes ----- - Author : Hamid Ali Syed (@syedhamidali) + - The function extracts the maximum value across the altitude (z) dimension to create the Max-CAPPI. + - It supports customizations such as map projections, color scales, and range rings. + - If the radar_name attribute in the dataset is a byte string, it will be decoded and limited to 4 characters. + - If add_map is True, map features and latitude/longitude lines are included. + - The plot can be saved to a specified directory in PNG format. + + Author: Syed Hamid Ali (@syedhamidali) """ ds = grid.to_xarray().squeeze() @@ -127,7 +135,7 @@ def plot_maxcappi( sideticks = np.arange(max_height / 4, max_height + 1, max_height / 4).astype(int) if cmap is None: - cmap = "pyart_Carbone42" + cmap = "pyart_NWSRef" if vmin is None: vmin = grid.fields[field]["data"].min() if vmax is None: From 31c36a7be91917567528ee9e1544a0d55f469d01 Mon Sep 17 00:00:00 2001 From: Hamid Ali Syed <35923822+syedhamidali@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:40:34 -0400 Subject: [PATCH 2/3] Update pyart/graph/max_cappi.py Co-authored-by: Zach Sherman <19153455+zssherman@users.noreply.github.com> --- pyart/graph/max_cappi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyart/graph/max_cappi.py b/pyart/graph/max_cappi.py index 957b8ff435..34b68573df 100644 --- a/pyart/graph/max_cappi.py +++ b/pyart/graph/max_cappi.py @@ -135,7 +135,7 @@ def plot_maxcappi( sideticks = np.arange(max_height / 4, max_height + 1, max_height / 4).astype(int) if cmap is None: - cmap = "pyart_NWSRef" + cmap = "pyart_HomeyerRainbow" if vmin is None: vmin = grid.fields[field]["data"].min() if vmax is None: From bfba4e544801ee473c72e427d4fcabe8797e66c6 Mon Sep 17 00:00:00 2001 From: Hamid Ali Syed <35923822+syedhamidali@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:40:50 -0400 Subject: [PATCH 3/3] Update pyart/graph/max_cappi.py Co-authored-by: Zach Sherman <19153455+zssherman@users.noreply.github.com> --- pyart/graph/max_cappi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyart/graph/max_cappi.py b/pyart/graph/max_cappi.py index 34b68573df..f3a2ddd542 100644 --- a/pyart/graph/max_cappi.py +++ b/pyart/graph/max_cappi.py @@ -52,7 +52,7 @@ def plot_maxcappi( field : str The radar field to be plotted (e.g., "REF", "VEL", "WIDTH"). cmap : str or matplotlib colormap, optional - Colormap to use for the plot. Default is "pyart_NWSRef". + Colormap to use for the plot. Default is "pyart_HomeyerRainbow". vmin : float, optional Minimum value for the color scaling. Default is set to the minimum value of the data if not provided. vmax : float, optional