-
Notifications
You must be signed in to change notification settings - Fork 390
Description
I'm really sorry if this is not a MWE but it is not easy to try and recreate a similar dataset, and I've spent already few hours trying to narrow down this issue :) The code used to make the plot is at the end of this post.
I'm plotting data that is natively defined in a Stereographic projection with a central_longitude=-80. In order to make a plot over Europe I'm rotating it to central_longitude=10.
This is the resulting plot when using the original projection with central_longitude=-80
This is the resulting plot when using central_longitude = 10 but leaving everything else the same
Notice the completely different (wrong) colors.
I'm not sure if there's something wrong going on with the transformation of polygons, or whether this has to do with the masked array, or the stereographic projection.
Here is the minimal code needed to reproduce this problem. Again I'm sorry it's not self-contained but I can upload the data if needed.
fig, ax = plt.subplots(
figsize=(12, 12),
subplot_kw={
"projection": ccrs.Stereographic(
central_latitude=90, central_longitude=-80, true_scale_latitude=60
)
},
)
extent_lonlat = [-17, 41, 35, 72]
scale='50m'
ax.set_extent(extent_lonlat, crs=ccrs.PlateCarree())
ax.add_feature(cfeature.OCEAN.with_scale(scale), facecolor="#82aac7")
ax.add_feature(
cfeature.LAND.with_scale(scale),
facecolor=(0.8, 0.7137254901960784, 0.615686274509804),
)
x = subset_plot["x"].values
y = subset_plot["y"].values
X, Y = np.meshgrid(x, y)
data = subset_plot.where(subset_plot > 5).values
cf = ax.contourf(
X,
Y,
data,
cmap=cmap,
norm=norm,
levels=levels_snow,
transform=dataset_crs,
)