From 3046a769538ee760dea86b1c859144df25269272 Mon Sep 17 00:00:00 2001 From: Zach Sherman Date: Thu, 11 Apr 2024 09:28:48 -0500 Subject: [PATCH] ENH: Update the cb_friendly to match cvd_friendly. (#820) * ENH: Update the cb_friendly to match cvd_friendly. This is so that the code matches the correct terminology. * STY: PEP8 fix for long line. --- act/plotting/timeseriesdisplay.py | 22 +++++++++---------- examples/io/plot_sodar.py | 2 +- examples/plotting/plot_ceil.py | 4 ++-- examples/plotting/plot_time_height_scatter.py | 2 +- examples/qc/plot_qc_bsrn.py | 8 +++---- .../notebook_and_blog_template.ipynb | 2 +- tests/plotting/test_timeseriesdisplay.py | 10 ++++++--- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/act/plotting/timeseriesdisplay.py b/act/plotting/timeseriesdisplay.py index 56d7990b28..196180a6f7 100644 --- a/act/plotting/timeseriesdisplay.py +++ b/act/plotting/timeseriesdisplay.py @@ -319,7 +319,7 @@ def plot( cbar_h_adjust=None, y_axis_flag_meanings=False, colorbar_labels=None, - cb_friendly=False, + cvd_friendly=False, match_line_label_color=False, **kwargs, ): @@ -412,8 +412,8 @@ def plot( 1: {'text': 'Liquid', 'color': 'green'}, 2: {'text': 'Ice', 'color': 'blue'}, 3: {'text': 'Mixed phase', 'color': 'purple'}} - cb_friendly : boolean - Set to true if you want to use the integrated colorblind friendly + cvd_friendly : boolean + Set to true if you want to use the integrated color vision deficiency (CVD) friendly colors for green/red based on the Homeyer colormap. match_line_label_color : boolean Will set the y label to match the line color in the plot. This @@ -440,7 +440,7 @@ def plot( if y_axis_flag_meanings: kwargs['linestyle'] = '' - if cb_friendly: + if cvd_friendly: cmap = 'HomeyerRainbow' assessment_overplot_category_color['Bad'] = ( 0.9285714285714286, @@ -1278,7 +1278,7 @@ def time_height_scatter( cb_label=None, subplot_index=(0,), plot_alt_field=False, - cb_friendly=False, + cvd_friendly=False, day_night_background=False, set_title=None, **kwargs, @@ -1309,7 +1309,7 @@ def time_height_scatter( The index of the subplot to set the x range of. plot_alt_field : boolean Set to true to plot the altitude field on the secondary y-axis - cb_friendly : boolean + cvd_friendly : boolean If set to True will use the Homeyer colormap day_night_background : boolean If set to True will plot the day_night_background @@ -1339,7 +1339,7 @@ def time_height_scatter( self.axes = np.array([plt.axes()]) self.fig.add_axes(self.axes[0]) - if cb_friendly: + if cvd_friendly: cmap = 'HomeyerRainbow' ax = self.axes[subplot_index] @@ -1436,7 +1436,7 @@ def qc_flag_block_plot( assessment_color=None, edgecolor='face', set_shading='auto', - cb_friendly=False, + cvd_friendly=False, **kwargs, ): """ @@ -1465,8 +1465,8 @@ def qc_flag_block_plot( set_shading : string Option to to set the matplotlib.pcolormesh shading parameter. Default to 'auto' - cb_friendly : boolean - Set to true if you want to use the integrated colorblind friendly + cvd_friendly : boolean + Set to true if you want to use the integrated color vision deficiency (CVD) friendly colors for green/red based on the Homeyer colormap **kwargs : keyword arguments The keyword arguments for :func:`plt.broken_barh`. @@ -1482,7 +1482,7 @@ def qc_flag_block_plot( 'Not Failing': 'green', 'Acceptable': 'green', } - if cb_friendly: + if cvd_friendly: color_lookup['Bad'] = (0.9285714285714286, 0.7130901016453677, 0.7130901016453677) color_lookup['Incorrect'] = (0.9285714285714286, 0.7130901016453677, 0.7130901016453677) color_lookup['Not Failing'] = (0.0, 0.4240129715562796, 0.4240129715562796) diff --git a/examples/io/plot_sodar.py b/examples/io/plot_sodar.py index c22a0c15a1..a240d5ff18 100644 --- a/examples/io/plot_sodar.py +++ b/examples/io/plot_sodar.py @@ -28,6 +28,6 @@ # Plot shear with a wind barb overlay, while using a color vision # deficiency (CVD) colormap. -display.plot('shear', subplot_index=(0,), cb_friendly=True) +display.plot('shear', subplot_index=(0,), cvd_friendly=True) display.plot_barbs_from_spd_dir('speed', 'dir') plt.show() diff --git a/examples/plotting/plot_ceil.py b/examples/plotting/plot_ceil.py index 2fe687f2d4..626b075d13 100644 --- a/examples/plotting/plot_ceil.py +++ b/examples/plotting/plot_ceil.py @@ -33,8 +33,8 @@ # Adjust ceilometer data for plotting ceil_ds = act.corrections.ceil.correct_ceil(ceil_ds, -9999.0) -# Plot up ceilometer backscatter using HomeyerRainbow cb friendly colormap +# Plot up ceilometer backscatter using HomeyerRainbow CVD friendly colormap # The same could be done with keyword 'cmap='HomeyerRainbow' display = act.plotting.TimeSeriesDisplay(ceil_ds, subplot_shape=(1,), figsize=(15, 5)) -display.plot('backscatter', subplot_index=(0,), cb_friendly=True) +display.plot('backscatter', subplot_index=(0,), cvd_friendly=True) plt.show() diff --git a/examples/plotting/plot_time_height_scatter.py b/examples/plotting/plot_time_height_scatter.py index 71b5df4196..b36bd7b4cf 100644 --- a/examples/plotting/plot_time_height_scatter.py +++ b/examples/plotting/plot_time_height_scatter.py @@ -16,7 +16,7 @@ # Create scatter plots of the sonde data display = act.plotting.TimeSeriesDisplay(ds, figsize=(7, 6), subplot_shape=(2,)) display.time_height_scatter('tdry', plot_alt_field=True, subplot_index=(0,)) -display.time_height_scatter('rh', subplot_index=(1,), cb_friendly=True, day_night_background=True) +display.time_height_scatter('rh', subplot_index=(1,), cvd_friendly=True, day_night_background=True) plt.tight_layout() ds.close() diff --git a/examples/qc/plot_qc_bsrn.py b/examples/qc/plot_qc_bsrn.py index a06400909d..37e3d907e7 100644 --- a/examples/qc/plot_qc_bsrn.py +++ b/examples/qc/plot_qc_bsrn.py @@ -25,10 +25,10 @@ display = act.plotting.TimeSeriesDisplay(ds, figsize=(15, 10), subplot_shape=(2,)) # Plot radiation data in top plot -display.plot(variable, subplot_index=(0,), day_night_background=True, cb_friendly=True) +display.plot(variable, subplot_index=(0,), day_night_background=True, cvd_friendly=True) # Plot ancillary QC data in bottom plot -display.qc_flag_block_plot(variable, subplot_index=(1,), cb_friendly=True) +display.qc_flag_block_plot(variable, subplot_index=(1,), cvd_friendly=True) plt.show() # Add initial BSRN QC tests to ancillary QC varialbles. Use defualts for @@ -74,9 +74,9 @@ subplot_index=(0,), day_night_background=True, assessment_overplot=True, - cb_friendly=True, + cvd_friendly=True, ) # Plot ancillary QC data in bottom plot -display.qc_flag_block_plot(variable, subplot_index=(1,), cb_friendly=True) +display.qc_flag_block_plot(variable, subplot_index=(1,), cvd_friendly=True) plt.show() diff --git a/examples/templates/notebook_and_blog_template.ipynb b/examples/templates/notebook_and_blog_template.ipynb index a130b83369..0366a89eeb 100644 --- a/examples/templates/notebook_and_blog_template.ipynb +++ b/examples/templates/notebook_and_blog_template.ipynb @@ -255,7 +255,7 @@ "\n", "# Plot shear with a wind barb overlay, while using a color vision\n", "# deficiency (CVD) colormap.\n", - "display.plot('shear', subplot_index=(0,), cb_friendly=True)\n", + "display.plot('shear', subplot_index=(0,), cvd_friendly=True)\n", "display.plot_barbs_from_spd_dir('speed', 'dir')\n", "plt.show()" ] diff --git a/tests/plotting/test_timeseriesdisplay.py b/tests/plotting/test_timeseriesdisplay.py index 88c58fac70..2b43398bf1 100644 --- a/tests/plotting/test_timeseriesdisplay.py +++ b/tests/plotting/test_timeseriesdisplay.py @@ -220,10 +220,14 @@ def test_time_height_scatter2(): {'sgpsondewnpnC1.b1': sonde_ds}, figsize=(8, 10), subplot_shape=(2,) ) display.time_height_scatter( - 'tdry', day_night_background=True, subplot_index=(0,), cb_friendly=True, plot_alt_field=True + 'tdry', + day_night_background=True, + subplot_index=(0,), + cvd_friendly=True, + plot_alt_field=True, ) display.time_height_scatter( - 'rh', day_night_background=True, subplot_index=(1,), cb_friendly=True + 'rh', day_night_background=True, subplot_index=(1,), cvd_friendly=True ) sonde_ds.close() @@ -310,7 +314,7 @@ def test_qc_flag_block_plot(): display.plot('surface_albedo_mfr_narrowband_10m', force_line_plot=True, labels=True) display.qc_flag_block_plot( - 'surface_albedo_mfr_narrowband_10m', subplot_index=(1,), cb_friendly=True + 'surface_albedo_mfr_narrowband_10m', subplot_index=(1,), cvd_friendly=True ) ds.close()