Skip to content

Commit

Permalink
Changed contour labels by removing the black bounding box and changin…
Browse files Browse the repository at this point in the history
…g 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.
  • Loading branch information
Brian-Jamison committed Jan 5, 2024
1 parent 62b1b0b commit 2c0d24c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
4 changes: 2 additions & 2 deletions adb_graphics/default_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 18 additions & 15 deletions adb_graphics/figures/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]

Expand Down
16 changes: 10 additions & 6 deletions adb_graphics/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2c0d24c

Please sign in to comment.