Skip to content

Commit

Permalink
ENH: cmweather used to now import colormaps (#1452)
Browse files Browse the repository at this point in the history
* ENH: Update Py-ART to import colormaps from cmweather.

* DEL: Remove colormap testing.

* FIX: Update testing.

* FIX: Fix for cmweather import location.

* FIX: Missing import.

* MNT: Update linting.

* MNT: Linting.
  • Loading branch information
zssherman authored Sep 8, 2023
1 parent 3cd0acb commit 00dd386
Show file tree
Hide file tree
Showing 30 changed files with 88 additions and 2,990 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ The required dependencies to install Py-ART in addition to Python are:
* `pooch <https://pypi.org/project/pooch/>`_
* `Cython <https://cython.readthedocs.io/en/latest/>`_
* `setuptools <https://setuptools.pypa.io/en/latest/index.html>`_
* `cmweather <https://cmweather.readthedocs.io/en/latest/>`_

A working C/C++ compiler is required for some optional modules. An easy method
to install these dependencies is by using a
Expand Down
1 change: 1 addition & 0 deletions continuous_integration/environment-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
- setuptools
- shapely
- ruff
- cmweather
- pip
- pip:
- cibuildwheel
Expand Down
1 change: 1 addition & 0 deletions doc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies:
- sphinx-copybutton
- nbsphinx
- pre_commit
- cmweather
- pip
- pip:
- pooch
Expand Down
4 changes: 2 additions & 2 deletions doc/source/blog_posts/2022/hail-analysis-spc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
" ax=ax,\n",
" embellish=False,\n",
" add_grid_lines=True,\n",
" cmap=\"pyart_ChaseSpectral\",\n",
" cmap=\"ChaseSpectral\",\n",
" vmin=-20,\n",
" vmax=70,\n",
")\n",
Expand Down Expand Up @@ -1064,7 +1064,7 @@
" projection=projection,\n",
" resolution=\"10m\",\n",
" gatefilter=gatefilter,\n",
" cmap=\"pyart_ChaseSpectral\",\n",
" cmap=\"ChaseSpectral\",\n",
" colorbar_flag=False,\n",
" lat_lines=[0, 0],\n",
" lon_lines=[0, 0],\n",
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
- xarray
- xradar
- pip
- cmweather
- pip:
- wheel
- watchdog
Expand Down
4 changes: 2 additions & 2 deletions examples/mapping/plot_compare_two_radars_gatemapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
disp1 = pyart.graph.RadarMapDisplay(radar_se)
disp1.plot_ppi_map(
"reflectivity_bias",
cmap="pyart_balance",
cmap="balance",
title="Reflectivity Difference \n XSAPR Southwest - XSPAR Southeast",
sweep=1,
ax=ax,
Expand Down Expand Up @@ -215,7 +215,7 @@

# Create a 1-1 comparison
x, y = np.meshgrid((bins[:-1] + bins[1:]) / 2.0, (bins[:-1] + bins[1:]) / 2.0)
c = plt.pcolormesh(x, y, np.log10(hist.T), cmap="pyart_HomeyerRainbow")
c = plt.pcolormesh(x, y, np.log10(hist.T), cmap="HomeyerRainbow")

# Add a colorbar and labels
plt.colorbar(c, label="$log_{10}$ counts")
Expand Down
16 changes: 6 additions & 10 deletions examples/plotting/plot_choose_a_colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
######################################
# **Plot the available colormaps**
#
# Let's see which colormaps are available directly from Py-ART!
# Let's see which colormaps are available in Py-ART from the colormap package cmweather!
# We use a helper function from matplotlib to plot this.

# Setup some helper functions and ranges to visualize our colormaps, from matplotlib
Expand All @@ -39,11 +39,11 @@ def plot_color_gradients(cmap_category, cmap_list):
axs[0].set_title(cmap_category + " Colormaps", fontsize=14)

for ax, cmap_name in zip(axs, cmap_list):
ax.imshow(gradient, aspect="auto", cmap=f"pyart_{cmap_name}")
ax.imshow(gradient, aspect="auto", cmap=f"{cmap_name}")
ax.text(
-0.01,
0.5,
f"pyart_{cmap_name}",
f"{cmap_name}",
va="center",
ha="right",
fontsize=10,
Expand Down Expand Up @@ -157,14 +157,10 @@ def plot_color_gradients(cmap_category, cmap_list):
######################################
# **Plot Using a Colormap from Py-ART**
#
# Let's use one of our Py-ART's colorbars now! We need
# to remember to add the pyart_ string in front of the
# colormap, as shown below.
# Let's use one of our cmweather's colorbars now!
# Setup a display to plot the data

display = pyart.graph.RadarDisplay(radar)

# Start by plotting a regular matplotlib colormap (Spectral_r)
display.plot(
"reflectivity_horizontal", vmin=-32, vmax=64.0, cmap="pyart_HomeyerRainbow"
)
# Now let's plot with a CVD-friendly colormap (HomeyerRainbow)
display.plot("reflectivity_horizontal", vmin=-32, vmax=64.0, cmap="HomeyerRainbow")
4 changes: 2 additions & 2 deletions examples/plotting/plot_cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
display.plot_grid(
"corrected_reflectivity_horizontal",
ax=ax1,
cmap="pyart_HomeyerRainbow",
cmap="HomeyerRainbow",
vmin=-20,
vmax=70,
)
Expand All @@ -71,7 +71,7 @@
start,
end,
x_axis="lat",
cmap="pyart_HomeyerRainbow",
cmap="HomeyerRainbow",
vmin=-20,
vmax=70,
)
4 changes: 2 additions & 2 deletions examples/plotting/plot_modify_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
vmax=60,
embellish=False,
norm=None,
cmap="pyart_HomeyerRainbow",
cmap="HomeyerRainbow",
)

# Add gridlines
Expand Down Expand Up @@ -99,7 +99,7 @@
vmax=60,
embellish=False,
norm=None,
cmap="pyart_HomeyerRainbow",
cmap="HomeyerRainbow",
)

# Add gridlines
Expand Down
4 changes: 1 addition & 3 deletions examples/plotting/plot_ppi_mdv.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
display = pyart.graph.RadarDisplay(radar)
fig = plt.figure(figsize=[5, 5])
ax = fig.add_subplot(111)
display.plot(
"reflectivity", 0, vmin=-16.0, vmax=64, title="PPI", cmap="pyart_HomeyerRainbow"
)
display.plot("reflectivity", 0, vmin=-16.0, vmax=64, title="PPI", cmap="HomeyerRainbow")
display.set_limits(ylim=[-150, 150], xlim=[-150, 150])
plt.show()
2 changes: 1 addition & 1 deletion examples/plotting/plot_rhi_cfradial_singlescan.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
mask_outside=True,
title="RHI",
axislabels=(xlabel, ylabel),
cmap="pyart_HomeyerRainbow",
cmap="HomeyerRainbow",
colorbar_label=colorbar_label,
ax=ax,
)
Expand Down
5 changes: 1 addition & 4 deletions examples/plotting/plot_rhi_data_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
ax = fig.add_subplot(111)

# plot velocity
# cmap is the color ramp being used in this case blue to red no 18
# https://github.com/ARM-DOE/pyart/blob/master/pyart/graph/cm.py
# for more information

display.plot(
"velocity",
Expand All @@ -40,7 +37,7 @@
vmax=20.0,
fig=fig,
ax=ax,
cmap="pyart_BuDRd18",
cmap="balance",
colorbar_label="Velocity (m/s)",
)

Expand Down
2 changes: 1 addition & 1 deletion examples/plotting/plot_rhi_two_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Fields to plot and ranges
fields_to_plot = ["reflectivity_horizontal", "mean_doppler_velocity"]
ranges = [(-20, 20), (-17.0, 17.0)]
cmaps = ["pyart_HomeyerRainbow", "pyart_balance"]
cmaps = ["HomeyerRainbow", "balance"]

# Plot the data
nplots = len(fields_to_plot)
Expand Down
6 changes: 3 additions & 3 deletions examples/plotting/plot_three_panel_gridmapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
vmax=vmax,
ax=ax1,
projection=projection,
cmap="pyart_HomeyerRainbow",
cmap="HomeyerRainbow",
)
display.plot_crosshairs(lon=lon, lat=lat)

# Panel 2: longitude slice
ax2 = fig.add_axes(x_cut_panel_axes)
display.plot_longitude_slice(
"REF", lon=lon, lat=lat, ax=ax2, vmin=vmin, vmax=vmax, cmap="pyart_HomeyerRainbow"
"REF", lon=lon, lat=lat, ax=ax2, vmin=vmin, vmax=vmax, cmap="HomeyerRainbow"
)

ax2.set_ylim([0, 15])
Expand All @@ -65,7 +65,7 @@
# Panel 3: latitude slice
ax3 = fig.add_axes(y_cut_panel_axes)
display.plot_latitude_slice(
"REF", lon=lon, lat=lat, ax=ax3, vmin=vmin, vmax=vmax, cmap="pyart_HomeyerRainbow"
"REF", lon=lon, lat=lat, ax=ax3, vmin=vmin, vmax=vmax, cmap="HomeyerRainbow"
)
ax3.set_ylim([0, 15])
ax3.set_xlim([-50, 50])
Expand Down
14 changes: 7 additions & 7 deletions examples/plotting/radar-cross-section.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"display.plot_grid(\n",
" \"corrected_reflectivity_horizontal\",\n",
" ax=ax1,\n",
" cmap=\"pyart_HomeyerRainbow\",\n",
" cmap=\"HomeyerRainbow\",\n",
" vmin=-20,\n",
" vmax=70,\n",
")\n",
Expand All @@ -98,7 +98,7 @@
" start,\n",
" end,\n",
" x_axis=\"lat\",\n",
" cmap=\"pyart_HomeyerRainbow\",\n",
" cmap=\"HomeyerRainbow\",\n",
" vmin=-20,\n",
" vmax=70,\n",
")"
Expand Down Expand Up @@ -166,7 +166,7 @@
" start,\n",
" end,\n",
" x_axis=\"lon\",\n",
" cmap=\"pyart_HomeyerRainbow\",\n",
" cmap=\"HomeyerRainbow\",\n",
" vmin=-20,\n",
" vmax=70,\n",
")"
Expand Down Expand Up @@ -297,7 +297,7 @@
"ds.corrected_reflectivity_horizontal.isel(z=0).plot(\n",
" x=\"lon\",\n",
" y=\"lat\",\n",
" cmap=\"pyart_HomeyerRainbow\",\n",
" cmap=\"HomeyerRainbow\",\n",
" vmin=-20,\n",
" vmax=60,\n",
" ax=ax,\n",
Expand All @@ -318,7 +318,7 @@
"fig = plt.figure()\n",
"ax = plt.subplot(111)\n",
"ds.corrected_reflectivity_horizontal.isel(z=0).plot(\n",
" x=\"lon\", y=\"lat\", cmap=\"pyart_HomeyerRainbow\", vmin=-20, vmax=60, ax=ax\n",
" x=\"lon\", y=\"lat\", cmap=\"HomeyerRainbow\", vmin=-20, vmax=60, ax=ax\n",
")\n",
"ax.scatter(start[1], start[0], label=\"Start Point\", color=\"tab:blue\")\n",
"ax.scatter(end[1], end[0], label=\"Start Point\", color=\"k\")\n",
Expand Down Expand Up @@ -346,7 +346,7 @@
"fig = plt.figure(figsize=(10, 8))\n",
"title = \"($^\\circ$N)\"\n",
"cross.corrected_reflectivity_horizontal.plot(\n",
" cmap=\"pyart_HomeyerRainbow\",\n",
" cmap=\"HomeyerRainbow\",\n",
" x=None,\n",
" y=\"z\",\n",
" vmin=-20,\n",
Expand Down Expand Up @@ -437,7 +437,7 @@
" grid, \"corrected_reflectivity_horizontal\", start, end\n",
")\n",
"cross.corrected_reflectivity_horizontal.plot(\n",
" cmap=\"pyart_HomeyerRainbow\",\n",
" cmap=\"HomeyerRainbow\",\n",
" x=None,\n",
" y=\"z\",\n",
" vmin=-20,\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/retrieve/hydrometeor-class.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@
" vmax=60.0,\n",
" ax=ax[0],\n",
" colorbar_label=\"Raw Ref\",\n",
" cmap=\"pyart_HomeyerRainbow\",\n",
" cmap=\"HomeyerRainbow\",\n",
")\n",
"display.plot_ppi(\n",
" \"corrected_reflectivity_horizontal\",\n",
" 0,\n",
" vmin=0,\n",
" vmax=60.0,\n",
" gatefilter=gtfilter,\n",
" cmap=\"pyart_HomeyerRainbow\",\n",
" cmap=\"HomeyerRainbow\",\n",
" ax=ax[1],\n",
" colorbar_label=\"Filtered Ref\",\n",
")\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/retrieve/plot_composite_reflectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
ax2 = plt.subplot(122)
composite_display = pyart.graph.RadarDisplay(compz)
composite_display.plot(
"composite_reflectivity", ax=ax2, vmin=-20, vmax=80, cmap="pyart_HomeyerRainbow"
"composite_reflectivity", ax=ax2, vmin=-20, vmax=80, cmap="HomeyerRainbow"
)
Loading

0 comments on commit 00dd386

Please sign in to comment.