Closed xenct closed 3 months ago
After trying to make contourf work for this data (modifying levels, norm, transform, data, etc) I found a similar issue https://github.com/SciTools/cartopy/issues/1076. I believe it is a similar issue due to this comment https://github.com/SciTools/cartopy/issues/1076#issuecomment-552407421
... The bug appears very often (more than 50% of the cases) when a contourf is crossing the 0 value, ... ... This makes it impossible to reliably produce filled contours when looking at the poles...
Our data here also crosses zero and the projection has a singularity at the south pole.
I believe that there may not be a satisfactory fix available. The best course of action may be to change the default function to contourf=False
or remove the contourf functionality altogether.
From further testing, I am confident it is a problem with combining this anomaly data, contourf and the projections.
Stripping the plotting down to the minimum for projecting on crs = ccrs.LambertConformal(...)
, plotting works ok with da.plot()
and da.plot.contour()
, but performs strangely on da.plot.contourf()
import xarray as xr
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ds = xr.open_dataset('/g/data/ia39/ncra/heat/data/HWF/bias-corrected/ensemble/GWL-change/HWF_AGCD-05i_MME50_ssp370_v1-r1-ACS-QME-AGCD-1960-2022_GWL20-GWL12-change.nc')
crs = ccrs.LambertConformal(
central_latitude=-24.75,
central_longitude=134.0,
cutoff=30,
standard_parallels=(-10, -40),
)
plt.figure()
ds['HWF'].plot(transform=ccrs.PlateCarree(), subplot_kws=dict(projection=crs),)
plt.figure()
ds['HWF'].plot.contour(transform=ccrs.PlateCarree(), subplot_kws=dict(projection=crs),)
plt.figure()
ds['HWF'].plot.contourf(transform=ccrs.PlateCarree(), subplot_kws=dict(projection=crs),)
The strange behaviour also depends on the input data. eg the same code works fine for
ds = xr.open_dataset('/g/data/ia39/ncra/heat/data/HWF/bias-corrected/ensemble/GWL-average/HWF_AGCD-05i_MME50_ssp370_v1-r1-ACS-QME-AGCD-1960-2022_GWL20.nc')
In plot_acs_hazard default behaviour, the map produced is not as expected. The error does not occur with all data. The white area is transparent/NaN The remaining coloured area is not aligned correctly
For example:
expected output: