From 2c0d24c169d2863a78b3c52564f343c6f354cb39 Mon Sep 17 00:00:00 2001 From: "Brian.D.Jamison" Date: Fri, 5 Jan 2024 23:41:37 +0000 Subject: [PATCH] Changed contour labels by removing the black bounding box and changing the font color to black. This avoids proliferating labels from obfuscating other data. The number of contours for MSLP on large domains was reduced for the same reason. Also, the new temperature color table developed by Craig is included to make this consistent between models. These changes were in response to an email from Tanya concerning these issues. --- adb_graphics/default_specs.yml | 4 ++-- adb_graphics/figures/maps.py | 33 ++++++++++++++++++--------------- adb_graphics/specs.py | 16 ++++++++++------ 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/adb_graphics/default_specs.yml b/adb_graphics/default_specs.yml index 3e71df8..11b0724 100644 --- a/adb_graphics/default_specs.yml +++ b/adb_graphics/default_specs.yml @@ -1577,8 +1577,8 @@ temp: # Temperature wind: False 2m: &sfc_temp annotate: True - clevs: !!python/object/apply:numpy.arange [-50, 141, 10] - cmap: gist_ncar + clevs: !!python/object/apply:numpy.arange [-60, 121, 4] + cmap: jet colors: tsfc_colors ncl_name: TMP_P0_L103_{grid} ticks: 10 diff --git a/adb_graphics/figures/maps.py b/adb_graphics/figures/maps.py index 10402e5..bf1c653 100644 --- a/adb_graphics/figures/maps.py +++ b/adb_graphics/figures/maps.py @@ -397,21 +397,16 @@ def _draw_contours(self, ax, not_labeled): ''' Draw the contour fields requested. ''' model_name = self.model_name - print(f'model_name = {model_name}') main_field = self.field.short_name - print(f'main_field = {main_field}') for contour_field in self.contour_fields: levels = contour_field.contour_kwargs.pop('levels', contour_field.clevs) - print(f'levels are {levels}') - print(f'contour_field.short_name = {contour_field.short_name}') - print(f'self.map.tile = {self.map.tile}') - if model_name == "RRFS NA 3km" and main_field == "totp" and \ - contour_field.short_name == "pres" and self.map.tile == "full": - levels = np.arange(650, 1051, 8) - print(f'levels are now {levels}') + if model_name in ["RAP-NCEP", "RRFS-NCEP", "RRFS NA 3km"]: + if main_field == "totp" and contour_field.short_name == "pres" and \ + self.map.tile == "full": + levels = np.arange(650, 1051, 8) cc = self._draw_field(ax=ax, field=contour_field, @@ -421,12 +416,20 @@ def _draw_contours(self, ax, not_labeled): ) if contour_field.short_name not in not_labeled: try: - clab = plt.clabel(cc, levels[::4], - colors='k', - fmt='%1.0f', - fontsize=10, - inline=1, - ) + plt.clabel(cc, levels[::4], + colors='k', + fmt='%1.0f', + fontsize=10, + inline=1, + ) + # + # #old routine, makes white text on black bounding box + # clab = plt.clabel(cc, levels[::4], + # colors='k', + # fmt='%1.0f', + # fontsize=10, + # inline=1, + # ) # # Set the background color for the line labels to black # _ = [txt.set_bbox(dict(color='k')) for txt in clab] diff --git a/adb_graphics/specs.py b/adb_graphics/specs.py index e0386a1..d4e5edd 100644 --- a/adb_graphics/specs.py +++ b/adb_graphics/specs.py @@ -445,13 +445,17 @@ def t_colors(self) -> np.ndarray: @property def tsfc_colors(self) -> np.ndarray: - ''' Default color map for Surface Temperature ''' + ''' Default color map for Surface Temperature ''' # WeatherBell-inspired scheme - purples = cm.get_cmap('Purples', 16)([14, 12, 8, 6, 4, 2]) - ncar = cm.get_cmap(self.vspec.get('cmap'), 128) \ - ([15, 20, 25, 33, 50, 60, 70, 80, 85, 90, 115]) - grays = cm.get_cmap('Greys', 15)([2, 4, 6, 8]) - return np.concatenate((purples, ncar, grays)) + temp1 = cm.get_cmap('cool_r', 8)(range(0, 8)) + temp2 = cm.get_cmap('BuGn', 6)(range(2, 6)) + temp3 = cm.get_cmap('Greens_r', 4)(range(0, 4)) + temp4 = cm.get_cmap('RdPu_r', 8)(range(0, 8)) + temp5 = cm.get_cmap('BuPu', 5)(range(0, 4)) + temp6 = cm.get_cmap('RdYlBu_r', 10)(range(1, 10)) + temp7 = cm.get_cmap('RdYlGn', 10)(range(0, 10)) + + return np.concatenate((temp1, temp2, temp3, temp4, temp5, temp6, temp7)) @property def terrain_colors(self) -> np.ndarray: