Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support proplot #19

Open
zxdawn opened this issue Mar 15, 2020 · 2 comments
Open

Support proplot #19

zxdawn opened this issue Mar 15, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@zxdawn
Copy link
Collaborator

zxdawn commented Mar 15, 2020

Problem

  1. The ax passed by proplot is GeoAxes instead of GeoAxesSubplot.
  2. proplot doesn't accept matplotlib.colors.BoundaryNorm. Instead, it uses BinNorm.

Code

proplot version

import cartopy.crs as ccrs
import proplot as plot
from pycwr.draw.RadarPlot import Graph, GraphMap
from pycwr.io.auto_io import radar_io

proj = ccrs.PlateCarree()
f, axs = plot.subplots(proj=proj)

dir = '/yin_raid/xin/data/radar/guangzhou/'
file = "Z_RADR_I_Z9200_20160506100000_O_DOR_SA_CAP.bin.bz2"
data = radar_io(dir+file)
NRadar = data.ToPRD()

graph = GraphMap(NRadar, ccrs.PlateCarree())
ax=axs[0]
graph.plot_crf_map(ax)

matplotlib version

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from pycwr.draw.RadarPlot import Graph, GraphMap
from pycwr.io.auto_io import radar_io

dir = '/yin_raid/xin/data/radar/guangzhou/'
file = "Z_RADR_I_Z9200_20160506100000_O_DOR_SA_CAP.bin.bz2"
data = radar_io(dir+file)
NRadar = data.ToPRD()

lon_min = 111.5; lon_max = 115
lat_min = 22.5; lat_max = 25
ax = plt.axes(projection=ccrs.PlateCarree())
graph = GraphMap(NRadar, ccrs.PlateCarree())
graph.plot_crf_map(ax)
ax.set_xlim([lon_min, lon_max])
ax.set_ylim([lat_min, lat_max])

Error of proplot version

Error 1

Traceback (most recent call last):
  File "crf.py", line 21, in <module>
    graph.plot_crf_map(ax)
  File "/yin_raid/xin/miniconda3/envs/pycwr/lib/python3.7/site-packages/pycwr-0.2.14-py3.7-linux-x86_64.egg/pycwr/draw/RadarPlot.py", line 368, in plot_crf_map
    assert isinstance(ax, cartopy.mpl.geoaxes.GeoAxesSubplot), "axes is not cartopy axes!"
AssertionError: axes is not cartopy axes!

Error 2

  File "crf.py", line 20, in <module>
    graph.plot_crf_map(ax)
  ......................
  File "/yin_raid/xin/miniconda3/envs/pycwr/lib/python3.7/site-packages/proplot/styletools.py", line 2614, in __init__
    f'Normalizer cannot be an instance of '
ValueError: Normalizer cannot be an instance of matplotlib.colors.BoundaryNorm.

Solution of proplot version

Solution 1

Use tuple in isinstance:

assert isinstance(ax, (cartopy.mpl.geoaxes.GeoAxes, cartopy.mpl.geoaxes.GeoAxesSubplot)), "axes is not cartopy axes!"

Solution 2

Use levels instead of norm for proplot:

pm = ax.pcolormesh(lon, lat, radar_data, transform=self.transform, cmap=cmap, levels=levels, zorder=4, **kwargs)

Output Figures

matplotlib version

matplotlib

proplot version

proplot

Final solution

We need to find a better solution of supporting both matplotlib and proplot.

@zxdawn zxdawn changed the title Support GeoAxes passed by proplot Support proplot Mar 15, 2020
@zxdawn
Copy link
Collaborator Author

zxdawn commented Mar 15, 2020

@bugsuse @bugsuse What do you think of supporting proplot?

@zxdawn zxdawn self-assigned this Mar 15, 2020
@zxdawn zxdawn added the enhancement New feature or request label Mar 15, 2020
@zxdawn
Copy link
Collaborator Author

zxdawn commented Mar 15, 2020

Maybe we can just using GeoAxes and GeoAxesSubplot to distinguish proplot and matplotlib? @YvZheng Are axes passed by matplotlib all GeoAxesSubplot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant