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

strange behaviour in PlateCarree when change central_longitude #2411

Open
szwang1990 opened this issue Jul 3, 2024 · 1 comment
Open

strange behaviour in PlateCarree when change central_longitude #2411

szwang1990 opened this issue Jul 3, 2024 · 1 comment

Comments

@szwang1990
Copy link

Description

When I use the PlateCarree projection in Cartopy to plot, the plot seems strange at some specific central longitudes.

Code to reproduce

fname = 'alpha_BCC-CSM2-MR.nc'
ds = xr.open_dataset(fname)

proj = ccrs.PlateCarree(central_longitude=0)
fig, ax = plt.subplots(
    1, 1, subplot_kw=dict(projection=proj), figsize=(10, 8)
)
pcm = ax.pcolormesh(ds.lon, ds.lat, ds.alpha.squeeze() * 1e4, vmin=-0.1, vmax=3.5, cmap=cm.get_cmap('seismic', lut=16), transform=ccrs.PlateCarree())
cbar = fig.colorbar(pcm, ax=ax, extend='both', shrink=0.5)
ax.coastlines()
ax.set_global()
ax.set_title(label='alpha')

Traceback

When central_longitude is set to 0 or -100, some blank areas remain in the plot. If central_longitude is set to other values, the plot is OK.

central_longitude_0
central_longitude_-100
central_longitude_-50
central_longitude_50

Full environment definition

Operating system

Ubuntu 18.04

Cartopy version

0.20.0

conda list

# packages in environment at /home/swang/Software/anaconda3/envs/nc_conda_env:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                  2_kmp_llvm    conda-forge
backcall                  0.2.0              pyhd3eb1b0_0    defaults
basemap                   1.2.2            py37hbe109c4_4    conda-forge
blas                      1.0                         mkl    defaults
bokeh                     2.4.3              pyhd8ed1ab_3    conda-forge
bottleneck                1.3.5            py37h7deecbd_0    defaults
brotli                    1.0.9                h5eee18b_7    defaults
brotli-bin                1.0.9                h5eee18b_7    defaults
brotli-python             1.0.9            py37hd23a5d3_7    conda-forge
bzip2                     1.0.8                h7b6447c_0    defaults
c-ares                    1.19.1               h5eee18b_0    defaults
ca-certificates           2024.2.2             hbcca054_0    conda-forge
cartopy                   0.20.0           py37hbe109c4_0    conda-forge
certifi                   2024.2.2           pyhd8ed1ab_0    conda-forge
cf_xarray                 0.7.2              pyhd8ed1ab_0    conda-forge
cftime                    1.5.1.1          py37hce1f21e_0    defaults
charset-normalizer        3.3.2              pyhd8ed1ab_0    conda-forge
click                     8.0.4            py37h06a4308_0    defaults
cloudpickle               2.2.1              pyhd8ed1ab_0    conda-forge
cmaps                     1.0.5              pyhd8ed1ab_0    conda-forge
cmocean                   2.0                        py_3    conda-forge
colorspacious             1.1.2              pyh24bf2e0_0    conda-forge
curl                      8.4.0                hdbd6064_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cycler                    0.11.0             pyhd3eb1b0_0    defaults
cyrus-sasl                2.1.28               h52b45da_1    defaults
cytoolz                   0.12.0           py37h540881e_0    conda-forge
dask                      2.12.0                     py_0    conda-forge
dask-core                 2.12.0                     py_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
dbus                      1.13.18              hb2f20db_0    defaults
debugpy                   1.5.1            py37h295c915_0    anaconda
decorator                 5.1.1              pyhd3eb1b0_0    defaults
distributed               2.12.0                   py37_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
entrypoints               0.4              py37h06a4308_0    defaults
esmf                      8.2.0           nompi_h61edca3_0    conda-forge
esmpy                     8.2.0           nompi_py37hff05f9c_1    conda-forge
expat                     2.5.0                h6a678d5_0    defaults
fftw                      3.3.9                h27cfd23_1    defaults
flit-core                 3.6.0              pyhd3eb1b0_0    defaults
flox                      0.4.1              pyhd8ed1ab_0    conda-forge
fontconfig                2.14.1               h4c34cd2_2    defaults
fonttools                 4.25.0             pyhd3eb1b0_0    defaults
freetype                  2.12.1               h4a9f257_0    defaults
fsspec                    2023.1.0           pyhd8ed1ab_0    conda-forge
geos                      3.9.1                h295c915_0    defaults
giflib                    5.2.1                h5eee18b_3    defaults
glib                      2.69.1               he621ea3_2    defaults
gst-plugins-base          1.14.1               h6a678d5_1    defaults
gstreamer                 1.14.1               h5eee18b_1    defaults
gsw                       3.4.0            py37hda87dfa_3    conda-forge
hdf4                      4.2.15               h10796ff_3    conda-forge
hdf5                      1.12.1          nompi_h4df4325_104    conda-forge
heapdict                  1.0.1                      py_0    conda-forge
icu                       58.2                 he6710b0_3    defaults
idna                      3.4                pyhd8ed1ab_0    conda-forge
importlib-metadata        4.11.3           py37h06a4308_0    defaults
importlib_metadata        4.11.3               hd3eb1b0_0    defaults
intel-openmp              2021.4.0          h06a4308_3561    defaults
ipykernel                 6.15.2           py37h06a4308_0    anaconda
ipython                   7.31.1           py37h06a4308_1    anaconda
jedi                      0.18.1           py37h06a4308_1    defaults
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
joblib                    1.1.1            py37h06a4308_0    defaults
jpeg                      9e                   h5eee18b_1    defaults
jupyter_client            7.4.9            py37h06a4308_0    defaults
jupyter_core              4.11.1           py37h06a4308_0    anaconda
kiwisolver                1.4.4            py37h6a678d5_0    defaults
krb5                      1.20.1               h143b758_1    defaults
lcms2                     2.12                 h3be6417_0    defaults
ld_impl_linux-64          2.38                 h1181459_1    defaults
lerc                      3.0                  h295c915_0    defaults
libbrotlicommon           1.0.9                h5eee18b_7    defaults
libbrotlidec              1.0.9                h5eee18b_7    defaults
libbrotlienc              1.0.9                h5eee18b_7    defaults
libclang                  14.0.6          default_hc6dbbc7_1    defaults
libclang13                14.0.6          default_he11475f_1    defaults
libcups                   2.4.2                h2d74bed_1    defaults
libcurl                   8.4.0                h251f7ec_0    defaults
libdeflate                1.17                 h5eee18b_1    defaults
libedit                   3.1.20221030         h5eee18b_0    defaults
libev                     4.33                 h7f8727e_1    defaults
libevent                  2.1.12               hdbd6064_1    defaults
libffi                    3.4.4                h6a678d5_0    defaults
libgcc-ng                 13.2.0               h807b86a_2    conda-forge
libgfortran-ng            11.2.0               h00389a5_1    defaults
libgfortran5              11.2.0               h1234567_1    defaults
libllvm11                 11.1.0               hf817b99_3    conda-forge
libllvm14                 14.0.6               hdb19cb5_3    defaults
libnetcdf                 4.8.1           nompi_h329d8a1_102    conda-forge
libnghttp2                1.57.0               h2d74bed_0    defaults
libnsl                    2.0.0                h5eee18b_0    defaults
libpng                    1.6.39               h5eee18b_0    defaults
libpq                     12.15                hdbd6064_1    defaults
libsodium                 1.0.18               h7b6447c_0    defaults
libssh2                   1.10.0               hdbd6064_2    defaults
libstdcxx-ng              11.2.0               h1234567_1    defaults
libtiff                   4.5.1                h6a678d5_0    defaults
libuuid                   1.41.5               h5eee18b_0    defaults
libwebp                   1.2.4                h11a3e52_1    defaults
libwebp-base              1.2.4                h5eee18b_1    defaults
libxcb                    1.15                 h7f8727e_0    defaults
libxkbcommon              1.0.1                h5eee18b_1    defaults
libxml2                   2.10.4               hcbfbd50_0    defaults
libxslt                   1.1.37               h2085143_0    defaults
libzip                    1.8.0                h6ac8c49_1    defaults
libzlib                   1.2.13               hd590300_5    conda-forge
llvm-openmp               14.0.6               h9e868ea_0    defaults
llvmlite                  0.38.1           py37h0761922_0    conda-forge
locket                    1.0.0              pyhd8ed1ab_0    conda-forge
lz4-c                     1.9.4                h6a678d5_0    defaults
markupsafe                2.1.1            py37h540881e_1    conda-forge
matplotlib                3.5.2            py37h06a4308_0    defaults
matplotlib-base           3.5.2            py37hf590b9c_0    defaults
matplotlib-inline         0.1.6            py37h06a4308_0    defaults
mkl                       2021.4.0           h06a4308_640    defaults
mkl-service               2.4.0            py37h7f8727e_0    defaults
mkl_fft                   1.3.1            py37hd3c417c_0    defaults
mkl_random                1.2.2            py37h51133e4_0    defaults
msgpack-python            1.0.3            py37h7cecad7_1    conda-forge
munkres                   1.1.4                      py_0    defaults
mysql                     5.7.24               h721c034_2    defaults
nc-time-axis              1.4.1              pyhd8ed1ab_0    conda-forge
ncurses                   6.4                  h6a678d5_0    defaults
nest-asyncio              1.5.6            py37h06a4308_0    defaults
netcdf-fortran            4.5.4           nompi_h2b6e579_100    conda-forge
netcdf4                   1.6.2            py37h89d13dc_0    defaults
nspr                      4.35                 h6a678d5_0    defaults
nss                       3.89.1               h6a678d5_0    defaults
numba                     0.55.1           py37h43839f2_1    conda-forge
numexpr                   2.8.4            py37he184ba9_0    defaults
numpy                     1.21.5           py37h6c91a56_3    defaults
numpy-base                1.21.5           py37ha15fc14_3    defaults
numpy_groupies            0.9.22             pyhd8ed1ab_0    conda-forge
openssl                   3.2.1                hd590300_1    conda-forge
packaging                 22.0             py37h06a4308_0    defaults
pandas                    1.3.5            py37h8c16a72_0    defaults
parso                     0.8.3              pyhd3eb1b0_0    defaults
partd                     1.4.1              pyhd8ed1ab_0    conda-forge
pcre                      8.45                 h295c915_0    defaults
pexpect                   4.8.0              pyhd3eb1b0_3    defaults
pickleshare               0.7.5           pyhd3eb1b0_1003    defaults
pillow                    9.4.0            py37h6a678d5_0    defaults
pint                      0.18               pyhd8ed1ab_0    conda-forge
pint-xarray               0.2.1              pyhd8ed1ab_0    conda-forge
pip                       22.3.1           py37h06a4308_0    defaults
platformdirs              2.5.2            py37h06a4308_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ply                       3.11                     py37_0    defaults
pooch                     1.8.0              pyhd8ed1ab_0    conda-forge
pop-tools                 2020.9.14                  py_0    conda-forge
proj                      8.0.1                h1217e81_0    defaults
prompt-toolkit            3.0.36           py37h06a4308_0    defaults
psutil                    5.9.0            py37h5eee18b_0    defaults
ptyprocess                0.7.0              pyhd3eb1b0_2    defaults
pygments                  2.11.2             pyhd3eb1b0_0    defaults
pyparsing                 3.0.9            py37h06a4308_0    defaults
pyproj                    3.2.1            py37hcc46e62_6    conda-forge
pyqt                      5.15.7           py37h6a678d5_1    defaults
pyqt5-sip                 12.11.0          py37h6a678d5_1    defaults
pyshp                     2.1.3              pyhd3eb1b0_0    defaults
pysocks                   1.7.1            py37h89c1867_5    conda-forge
python                    3.7.12          hf930737_100_cpython    conda-forge
python-dateutil           2.8.2              pyhd3eb1b0_0    defaults
python_abi                3.7                     4_cp37m    conda-forge
pytz                      2022.7           py37h06a4308_0    defaults
pyyaml                    6.0              py37h540881e_4    conda-forge
pyzmq                     23.2.0           py37h6a678d5_0    defaults
qt-main                   5.15.2               h7358343_9    defaults
qt-webengine              5.15.9               h9ab4d14_7    defaults
qtwebkit                  5.212                h3fafdc1_5    defaults
readline                  8.2                  h5eee18b_0    defaults
requests                  2.31.0             pyhd8ed1ab_0    conda-forge
scipy                     1.7.3            py37h6c91a56_2    defaults
seawater                  3.3.4                      py_1    conda-forge
setuptools                65.6.3           py37h06a4308_0    defaults
shapely                   1.8.0            py37h48c49eb_0    conda-forge
sip                       6.6.2            py37h6a678d5_0    defaults
six                       1.16.0             pyhd3eb1b0_1    defaults
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
sparse                    0.13.0             pyhd8ed1ab_0    conda-forge
sqlite                    3.41.2               h5eee18b_0    defaults
tblib                     2.0.0              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h1ccaba5_0    defaults
toml                      0.10.2             pyhd3eb1b0_0    defaults
toolz                     0.12.0             pyhd8ed1ab_0    conda-forge
tornado                   6.2              py37h5eee18b_0    defaults
traitlets                 5.7.1            py37h06a4308_0    defaults
typing-extensions         4.4.0            py37h06a4308_0    defaults
typing_extensions         4.4.0            py37h06a4308_0    defaults
urllib3                   2.1.0              pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.5              pyhd3eb1b0_0    defaults
wheel                     0.38.4           py37h06a4308_0    defaults
xarray                    0.20.1             pyhd3eb1b0_1    defaults
xesmf                     0.6.3              pyhd8ed1ab_1    conda-forge
xmip                      0.7.2              pyhd8ed1ab_0    conda-forge
xz                        5.4.2                h5eee18b_0    defaults
yaml                      0.2.5                h7f98852_2    conda-forge
zeromq                    4.3.4                h2531618_0    defaults
zict                      2.2.0              pyhd8ed1ab_0    conda-forge
zipp                      3.11.0           py37h06a4308_0    defaults
zlib                      1.2.13               hd590300_5    conda-forge
zstd                      1.5.5                hc292b87_0    defaults

pip list

@rcomer
Copy link
Member

rcomer commented Jul 3, 2024

Thanks for the report @szwang1990! Cartopy 0.20 is quite old now. Are you able to test with the latest version 0.23?

If the problem does persist in the latest version, we will need to reproduce it in order to investigate. So can you share your NetCDF file?

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

No branches or pull requests

2 participants