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

contourf producing maps with blank spots #1131

Closed
moonshoes87 opened this issue Sep 26, 2018 · 3 comments · Fixed by #1146
Closed

contourf producing maps with blank spots #1131

moonshoes87 opened this issue Sep 26, 2018 · 3 comments · Fixed by #1146

Comments

@moonshoes87
Copy link

Description

I work on a geology package and we would like to switch from Basemap to cartopy. I am trying to plot a contour map with the magnetic field strength. This works correctly in Basemap's contourf, but with the same data in cartopy there are mysterious blank spots in the plot.

Image produced by basemap:
image

Image produced by cartopy:
image

Code to reproduce

Full code (including data) in Jupyter html:

cartopy_plotting.html.zip

Full code in .ipynb form:

cartopy_plotting.ipynb.zip

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import cartopy
import cartopy.crs as ccrs
from mpl_toolkits.basemap import Basemap
date=2018 
lon_0=0 # we can specify the grid spacing and the intended 0 longitude for the plot

Bs = np.array([[54.8439591 , 54.84395902, 54.84395918, 54.84395915, 54.84395932,
        54.84395933, 54.84395919, 54.84395923, 54.84395907, 54.84395912,
        54.84395893, 54.84395891, 54.84395882, 54.84395868, 54.84395883,
        54.84395867, 54.84395873, 54.84395863, 54.84395879, 54.84395874,
        54.84395893, 54.84395894, 54.84395915, 54.84395921, 54.84395913,
        54.84395922, 54.84395912, 54.84395922, 54.84395908, 54.84395916,
        54.84395906, 54.84395915, 54.84395913, 54.84395898, 54.84395905,
        54.84395895, 54.8439591 ],
       [60.81772812, 60.2066832 , 59.44375176, 58.54963078, 57.54461989,
        56.44971031, 55.28786124, 54.08492646, 52.86980756, 51.67371366,
        50.52873251, 49.46620166, 48.51541752, 47.70305541, 47.05330095,
        46.5883327 , 46.32856162, 46.29209331, 46.49317295, 46.93979353,
        47.63099527, 48.55453764, 49.6855385 , 50.98643876, 52.40838915,
        53.89393561, 55.38076374, 56.80613561, 58.1115362 , 59.24693785,
        60.17405232, 60.86809626, 61.3178596 , 61.52424809, 61.49774109,
        61.25535945, 60.81772812],
       [63.24383384, 61.95512574, 60.49396817, 58.88128326, 57.12309175,
        55.22100186, 53.18571003, 51.04832107, 48.86472292, 46.71073761,
        44.66922015, 42.813808  , 41.19616737, 39.8428371 , 38.76358754,
        37.96736581, 37.47764414, 37.33915101, 37.61226372, 38.35713497,
        39.61391176, 41.38654795, 43.63523847, 46.27790041, 49.19742772,
        52.25107128, 55.28076648, 58.12554309, 60.63697784, 62.69598499,
        64.22651632, 65.20149317, 65.63893021, 65.59024861, 65.12548925,
        64.31991238, 63.24383384],
       [62.13872323, 60.26936421, 58.30630585, 56.26201471, 54.09875408,
        51.75517309, 49.18659611, 46.40152449, 43.48209322, 40.5804809 ,
        37.88629864, 35.57007183, 33.72492068, 32.3394704 , 31.32434666,
        30.58143397, 30.07496074, 29.86606904, 30.09997445, 30.95608928,
        32.57956994, 35.02156881, 38.21727437, 42.00750624, 46.17944943,
        50.49749774, 54.71579905, 58.58609602, 61.87788661, 64.41214196,
        66.09322265, 66.9213945 , 66.97853528, 66.39388412, 65.30778213,
        63.8507126 , 62.13872323],
       [58.63739075, 56.3738957 , 54.11502179, 51.8832529 , 49.60648339,
        47.16554696, 44.45436756, 41.42841175, 38.14897107, 34.81605147,
        31.74980198, 29.28740991, 27.62249323, 26.69115468, 26.21890628,
        25.90799198, 25.60651345, 25.36039316, 25.38774472, 26.02715205,
        27.63100174, 30.39317279, 34.23358326, 38.84894252, 43.85817978,
        48.90790139, 53.69060397, 57.92446797, 61.36162345, 63.83018616,
        65.26768545, 65.72314197, 65.33317179, 64.27622927, 62.71950275,
        60.79776304, 58.63739075],
       [54.04793668, 51.59430873, 49.19815172, 46.89312207, 44.60858028,
        42.24586022, 39.7064979 , 36.89259693, 33.77032277, 30.48964275,
        27.44056391, 25.13072887, 23.88880955, 23.60386118, 23.81366863,
        24.07517707, 24.18884587, 24.15207921, 24.09160213, 24.33547615,
        25.44845094, 27.96095242, 31.94582687, 36.95895057, 42.368702  ,
        47.64479546, 52.40688169, 56.3616432 , 59.31253932, 61.21697149,
        62.15353267, 62.22901803, 61.55490039, 60.27219522, 58.52297502,
        56.41156419, 54.04793668],
       [48.90555814, 46.4921163 , 44.1473195 , 41.87964522, 39.64443824,
        37.44666252, 35.27123424, 32.99042036, 30.45300235, 27.70124207,
        25.09666556, 23.19886717, 22.40176587, 22.58822898, 23.25643655,
        24.00802879, 24.72411949, 25.33506838, 25.70553386, 25.87948794,
        26.37257767, 28.0430766 , 31.40297199, 36.1135575 , 41.34866997,
        46.38095084, 50.71976421, 54.00101144, 56.05803318, 57.06736932,
        57.3767459 , 57.16220754, 56.39781756, 55.08850172, 53.33825848,
        51.24398726, 48.90555814],
       [43.29423458, 41.18133211, 39.15065878, 37.16388859, 35.20231518,
        33.36669473, 31.71312329, 30.1079179 , 28.34624856, 26.3950297 ,
        24.50547693, 23.11305025, 22.57824584, 22.90351296, 23.7612709 ,
        24.88635667, 26.20545117, 27.55732262, 28.59676284, 29.08354655,
        29.25569462, 29.95479737, 32.09061237, 35.72986773, 40.10602907,
        44.39920061, 48.0314895 , 50.52133999, 51.64398109, 51.7459695 ,
        51.45611559, 51.0229043 , 50.24862702, 48.98391725, 47.3218551 ,
        45.39123996, 43.29423458],
       [37.90918428, 36.33887873, 34.86896969, 33.45103671, 32.09292509,
        30.90056736, 29.92444194, 29.05289031, 28.10401858, 26.99309263,
        25.80549142, 24.76590803, 24.17374722, 24.26128982, 25.02185469,
        26.29062961, 27.87932604, 29.52111069, 30.87656307, 31.65462432,
        31.83367287, 31.96867995, 32.99925005, 35.32114382, 38.43608984,
        41.63055699, 44.35982315, 46.10666491, 46.57418194, 46.10876816,
        45.41460791, 44.76903518, 43.92140177, 42.68311749, 41.17141542,
        39.54930907, 37.90918428],
       [34.13360995, 33.24859235, 32.45466473, 31.75156484, 31.19517034,
        30.82653328, 30.63126235, 30.52011151, 30.32703639, 29.88390835,
        29.12689613, 28.14808621, 27.22092639, 26.75113095, 27.01936852,
        27.97462341, 29.31889124, 30.71900588, 31.94225298, 32.79994554,
        33.17648723, 33.34227507, 33.95037651, 35.36934244, 37.34862389,
        39.43753966, 41.25270265, 42.38776885, 42.56390802, 41.96580767,
        41.07509897, 40.13047536, 39.03334648, 37.73191418, 36.38632588,
        35.16816113, 34.13360995],
       [32.89103817, 32.62342162, 32.45766304, 32.44606268, 32.69223399,
        33.17074118, 33.78030588, 34.39840844, 34.81580102, 34.76924937,
        34.1141545 , 32.94253889, 31.58686572, 30.52137208, 30.11385393,
        30.41133918, 31.19126928, 32.18032624, 33.18766674, 34.06222642,
        34.72067735, 35.30078903, 36.08532234, 37.18298805, 38.47597294,
        39.79752112, 40.95895198, 41.71079369, 41.83753472, 41.30196698,
        40.23673801, 38.82430951, 37.23615746, 35.66406733, 34.33082917,
        33.40444748, 32.89103817],
       [34.05458017, 34.12737546, 34.43838144, 35.03369946, 35.99244645,
        37.22813457, 38.56102772, 39.79855265, 40.66800571, 40.83686822,
        40.12085534, 38.66650432, 36.92860438, 35.44513151, 34.55628128,
        34.31196441, 34.60550024, 35.29240411, 36.19137541, 37.11463991,
        38.00113408, 38.93855201, 39.98256382, 41.06449581, 42.12500631,
        43.16209903, 44.11113659, 44.80322978, 45.01510249, 44.52256718,
        43.21945705, 41.26213428, 39.03594844, 36.95924351, 35.35091607,
        34.39047887, 34.05458017],
       [37.26143859, 37.39720502, 38.00588003, 39.07410441, 40.57345193,
        42.34374942, 44.15643721, 45.77407976, 46.89759504, 47.18122275,
        46.43044866, 44.8119803 , 42.8378329 , 41.08800231, 39.90262165,
        39.33251307, 39.31529806, 39.76995204, 40.5444573 , 41.44727035,
        42.39458202, 43.42419546, 44.54715645, 45.70467409, 46.87032678,
        48.05368833, 49.18799522, 50.08253401, 50.44966272, 49.97495214,
        48.49099116, 46.16421803, 43.46492148, 40.92691794, 38.94734066,
        37.72712896, 37.26143859],
       [42.30230785, 42.40532915, 43.14107313, 44.43328995, 46.14594161,
        48.06199981, 49.93962165, 51.544028  , 52.61225068, 52.86447982,
        52.1460678 , 50.59305657, 48.63233682, 46.77134043, 45.35230187,
        44.48729342, 44.1645142 , 44.32563974, 44.85010253, 45.57979015,
        46.42012088, 47.37966134, 48.50138689, 49.80144705, 51.26406405,
        52.82083917, 54.30709433, 55.45697007, 55.94902577, 55.49984693,
        54.00982548, 51.67783038, 48.95588471, 46.35627306, 44.27092276,
        42.90572116, 42.30230785],
       [48.40204611, 48.48950587, 49.17270908, 50.34506532, 51.83583682,
        53.43136574, 54.91881343, 56.10651157, 56.8116271 , 56.86861308,
        56.19839522, 54.89158025, 53.21329885, 51.50094047, 50.0317529 ,
        48.96075843, 48.34060846, 48.15501088, 48.332985  , 48.7801415 ,
        49.43823883, 50.31917781, 51.4755789 , 52.93664905, 54.65439303,
        56.47813778, 58.16285989, 59.41228197, 59.94718777, 59.5880022 ,
        58.33383345, 56.39486925, 54.13693869, 51.95762814, 50.17119697,
        48.96205936, 48.40204611],
       [53.9092286 , 53.94162978, 54.37829985, 55.12552041, 56.0495612 ,
        56.99801661, 57.82511949, 58.40669885, 58.64324756, 58.46594376,
        57.85678891, 56.87134606, 55.63904222, 54.33095537, 53.11291477,
        52.11128129, 51.40191782, 51.01426546, 50.94337773, 51.17083124,
        51.68913538, 52.51155946, 53.65384426, 55.09594245, 56.74804448,
        58.4422811 , 59.95638342, 61.06093289, 61.57509906, 61.41568097,
        60.62513271, 59.36582983, 57.87746654, 56.41315764, 55.18289484,
        54.32562456, 53.9092286 ],
       [57.19426523, 57.10967163, 57.2070383 , 57.43719963, 57.73344261,
        58.02223252, 58.23393221, 58.31099595, 58.2130527 , 57.92038236,
        57.43708384, 56.79287201, 56.04084083, 55.24992082, 54.49393669,
        53.84109208, 53.34693826, 53.05183045, 52.98226247, 53.15425723,
        53.5756915 , 54.24414855, 55.13925223, 56.21280857, 57.38320416,
        58.53967897, 59.55780441, 60.32253161, 60.75217375, 60.81629467,
        60.54219581, 60.00793594, 59.32398708, 58.60944617, 57.97014968,
        57.48395203, 57.19426523],
       [57.81468255, 57.69017288, 57.5934811 , 57.51633874, 57.4456496 ,
        57.36607415, 57.26267821, 57.12329769, 56.94038426, 56.71221352,
        56.44341395, 56.14480513, 55.83256113, 55.52678547, 55.24967556,
        55.02352831, 54.86883035, 54.80259245, 54.8369618 , 54.97804669,
        55.22487524, 55.56852194, 55.99162501, 56.46869297, 56.96761224,
        57.45254411, 57.88800113, 58.24344878, 58.49750212, 58.64077563,
        58.67672215, 58.62028014, 58.49466996, 58.32708724, 58.14420867,
        57.96832908, 57.81468255],
       [56.63546513, 56.63546513, 56.63546513, 56.63546513, 56.63546513,
        56.63546513, 56.63546513, 56.63546513, 56.63546513, 56.63546513,
        56.63546513, 56.63546513, 56.63546513, 56.63546513, 56.63546513,
        56.63546513, 56.63546513, 56.63546513, 56.63546513, 56.63546513,
        56.63546513, 56.63546513, 56.63546513, 56.63546513, 56.63546513,
        56.63546513, 56.63546513, 56.63546513, 56.63546513, 56.63546513,
        56.63546513, 56.63546513, 56.63546513, 56.63546513, 56.63546513,
        56.63546513, 56.63546513]])
lons = np.array([-180., -170., -160., -150., -140., -130., -120., -110., -100.,
        -90.,  -80.,  -70.,  -60.,  -50.,  -40.,  -30.,  -20.,  -10.,
          0.,   10.,   20.,   30.,   40.,   50.,   60.,   70.,   80.,
         90.,  100.,  110.,  120.,  130.,  140.,  150.,  160.,  170.,
        180.])
lats = np.array([-90, -80, -70, -60, -50, -40, -30, -20, -10,   0,  10,  20,  30,
        40,  50,  60,  70,  80,  90])
lincr=2
levmax=round(Bs.max())+lincr
levmin=round(Bs.min()-lincr)
levels=np.arange(levmin,levmax,lincr)

# plot with cartopy
ax = plt.axes(projection=ccrs.Mollweide(central_longitude=lon_0))
x, y = np.meshgrid(lons,lats)
m=ax.contourf(x, y, Bs, levels,transform=ccrs.PlateCarree(),cmap=cm.jet)
ax.set_global()
ax.coastlines()
cbar=plt.colorbar(m,orientation='horizontal') # put on a color bar of intensities
plt.title('Cartopy plot Field strength ($\mu$T): '+str(date))
plt.show()

# plot with basemap
m = Basemap(projection='hammer',lon_0=lon_0)
xx, yy = np.meshgrid(lons,lats)
x,y=m(xx,yy)
m.drawcoastlines()
cs=m.contourf(x,y,Bs,levels,cmap=cm.jet) 
cbar=m.colorbar(cs,location='bottom')
plt.title('Basemap plot Field strength ($\mu$T): '+str(date))
plt.show()

Traceback


Full environment definition

Operating system

OSX High Sierra 10.13.6

Cartopy version

0.16.1

conda list

 ~ conda list
# packages in environment at /Users/nebula/anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0            py36h2fc01ae_0  
alabaster                 0.7.10           py36h174008c_0  
anaconda                  custom           py36ha4fed55_0  
anaconda-client           1.6.9                    py36_0  
anaconda-navigator        1.7.0                    py36_0  
anaconda-project          0.8.2            py36h9ee5d53_0  
appdirs                   1.4.3                    py36_0  
appnope                   0.1.0            py36hf537a9a_0  
appscript                 1.0.1            py36h9e71e49_1  
asn1crypto                0.24.0                   py36_0  
asteval                   0.9.12             pyh24bf2e0_1    conda-forge
astroid                   1.6.1                    py36_0  
astropy                   2.0.3            py36h1de35cc_0  
attrs                     17.4.0                   py36_0  
autopep8                  1.3.5                     <pip>
babel                     2.5.3                    py36_0  
backports                 1.0              py36ha3c1827_1  
backports.shutil_get_terminal_size 1.0.0            py36hd7a2ee4_2  
basemap                   1.1.0                    py36_4    conda-forge
beautifulsoup4            4.6.0            py36h72d3c9f_1  
bitarray                  0.8.1            py36h1de35cc_1  
blas                      1.0                         mkl  
bleach                    2.1.2                    py36_0  
bokeh                     0.12.13          py36h2f9c1c0_0  
boto                      2.48.0           py36hdbc59ac_1  
bottleneck                1.2.1            py36hbd380ad_0  
bzip2                     1.0.6                hd86a083_4  
ca-certificates           2018.03.07                    0  
cartopy                   0.16.0           py36h9263bd1_0  
certifi                   2018.8.24                py36_1  
cffi                      1.11.4           py36h342bebf_0  
chardet                   3.0.4            py36h96c241c_1  
click                     6.7              py36hec950be_0  
cloudpickle               0.5.2                    py36_1  
clyent                    1.2.2            py36hae3ad88_0  
cmarkgfm                  0.4.2                     <pip>
colorama                  0.3.9            py36hd29a30c_0  
conda                     4.5.11                   py36_0  
conda-build               3.4.1                    py36_0  
conda-env                 2.6.0                h36134e3_0  
conda-verify              2.0.0            py36he837df3_0  
contextlib2               0.5.5            py36hd66e5e7_0  
cryptography              2.1.4            py36h842514c_0  
curl                      7.58.0               ha441bb4_0  
cycler                    0.10.0           py36hfc81398_0  
cython                    0.27.3           py36h6ecb376_0  
cytoolz                   0.9.0            py36h1de35cc_0  
dask-core                 0.16.1                   py36_0  
datashape                 0.5.4            py36hfb22df8_0  
dbus                      1.12.2               h5243cc1_1  
decorator                 4.2.1                    py36_0  
distributed               1.20.2                   py36_0  
docutils                  0.14             py36hbfde631_0  
entrypoints               0.2.3            py36hd81d71f_2  
et_xmlfile                1.0.1            py36h1315bdc_0  
expat                     2.2.5                hb8e80ba_0  
fastcache                 1.0.2            py36h1de35cc_2  
filelock                  2.0.13           py36hf9de95b_0  
flask                     0.12.2           py36h5658096_0  
flask-cors                3.0.3            py36h7387b97_0  
freetype                  2.9.1                hb4e5f40_0  
future                    0.16.0                   py36_1  
geos                      3.6.2                         1    conda-forge
get_terminal_size         1.0.0                h7520d66_0  
gettext                   0.19.8.1             h15daf44_3  
gevent                    1.2.2            py36ha70b9d6_0  
glib                      2.53.6               h33f6a65_2  
glob2                     0.6              py36h94c9186_0  
gmp                       6.1.2                hb37e062_1  
gmpy2                     2.0.8            py36hf9c35bd_2  
greenlet                  0.4.12           py36hf09ba7b_0  
h5py                      2.7.1            py36h39cdac5_0  
hdf5                      1.10.1               ha036c08_1  
heapdict                  1.0.0                    py36_2  
html5lib                  1.0.1            py36h2f9c1c0_0  
icu                       58.2                 h4b95b61_1  
idna                      2.6              py36h8628d0a_1  
imageio                   2.2.0            py36h5e01289_0  
imagesize                 0.7.1            py36h3495948_0  
intel-openmp              2018.0.0             h8158457_8  
ipykernel                 4.8.0                    py36_0  
ipython                   6.2.1            py36h3dda519_1  
ipython_genutils          0.2.0            py36h241746c_0  
ipywidgets                7.1.1                    py36_0  
iscompatible              0.1.1                     <pip>
isort                     4.2.15           py36hceb2a01_0  
itsdangerous              0.24             py36h49fbb8d_1  
jbig                      2.1                  h4d881f8_0  
jdcal                     1.3              py36h1986823_0  
jedi                      0.11.1                   py36_0  
jinja2                    2.10             py36hd36f9c5_0  
jpeg                      9b                   he5867d9_2  
jsonschema                2.6.0            py36hb385e00_0  
jupyter                   1.0.0                    py36_4  
jupyter_client            5.2.2                    py36_0  
jupyter_console           5.2.0            py36hccf5b1c_1  
jupyter_core              4.4.0            py36h79cf704_0  
jupyterlab                0.31.5                   py36_0  
jupyterlab_launcher       0.10.2                   py36_0  
kiwisolver                1.0.1            py36h792292d_0  
lazy-object-proxy         1.3.1            py36h2fbbe47_0  
libcurl                   7.58.0               hf30b1f0_0  
libcxx                    4.0.1                h579ed51_0  
libcxxabi                 4.0.1                hebd6815_0  
libedit                   3.1                  hb4e282d_0  
libffi                    3.2.1                h475c297_4  
libgfortran               3.0.1                h93005f0_2  
libiconv                  1.15                 hdd342a3_7  
libopenblas               0.2.20               hdc02c5d_7  
libpng                    1.6.34               he12f830_0  
libsodium                 1.0.15               hd9e47c5_0  
libssh2                   1.8.0                h322a93b_4  
libtiff                   4.0.9                h0dac147_0  
libxml2                   2.9.7                hab757c2_0  
libxslt                   1.1.32               hb819dd2_0  
llvmlite                  0.21.0           py36hff739e7_0  
lmfit                     0.9.11             pyh24bf2e0_1    conda-forge
locket                    0.2.0            py36hca03003_1  
lxml                      4.1.1            py36hef8c89e_1  
lzo                       2.10                 h362108e_2  
markupsafe                1.0              py36h3a1e703_1  
matplotlib                2.2.3            py36h54f8f79_0  
mccabe                    0.6.1            py36hdaeb55d_0  
mistune                   0.8.3                    py36_0  
mkl                       2018.0.1             hfbd8650_4  
mkl-service               1.1.2            py36h7ea6df4_4  
mpc                       1.0.3                h7a72875_5  
mpfr                      3.1.5                h711e7fd_2  
mpmath                    1.0.0            py36hf1b8295_2  
msgpack-python            0.5.1            py36h04f5b5a_0  
multipledispatch          0.4.9            py36hc5f92b5_0  
navigator-updater         0.1.0            py36h7aee5fb_0  
nbconvert                 5.3.1            py36h810822e_0  
nbformat                  4.4.0            py36h827af21_0  
ncurses                   6.0                  hd04f020_2  
networkx                  2.1                      py36_0  
nltk                      3.2.5            py36h1190bce_0  
nose                      1.3.7            py36h73fae2b_2  
notebook                  5.4.0                    py36_0  
numba                     0.36.2          np114py36hc2f221f_0  
numexpr                   2.6.4            py36habcfcfe_0  
numpy                     1.14.2           py36ha9ae307_0  
numpy-base                1.14.3           py36h7ef55bc_1  
numpydoc                  0.7.0            py36he54d08e_0  
olefile                   0.45.1                   py36_0  
openpyxl                  2.4.10                   py36_0  
openssl                   1.0.2p               h1de35cc_0  
owslib                    0.16.0                   py36_0  
packaging                 16.8             py36he5e8135_0  
pandas                    0.23.1           py36h1702cab_0  
pandoc                    1.19.2.1             ha5e8f32_1  
pandocfilters             1.4.2            py36h3b0b094_1  
parso                     0.1.1            py36hc90e01c_0  
partd                     0.3.8            py36hf5c4cb8_0  
path.py                   10.5             py36h7bcb313_0  
pathlib2                  2.3.0            py36h877a6d8_0  
patsy                     0.5.0                    py36_0  
pcre                      8.41                 hfb6ab37_1  
pep8                      1.7.1                    py36_0  
pexpect                   4.3.1                    py36_0  
pickleshare               0.7.4            py36hf512f8e_0  
pillow                    5.2.0            py36hb68e598_0  
pip                       10.0.1                   py36_0  
pip                       10.0.1                    <pip>
pip                       18.0                      <pip>
pkginfo                   1.4.2                    py36_1  
pluggy                    0.6.0            py36hb1d0581_0  
ply                       3.10             py36h10e714e_0  
proj4                     5.0.1                h1de35cc_0  
prompt_toolkit            1.0.15           py36haeda067_0  
psutil                    5.4.3            py36h1de35cc_0  
ptyprocess                0.5.2            py36he6521c3_0  
py                        1.5.2            py36ha69170d_0  
pycodestyle               2.3.1            py36h83e8646_0  
pycosat                   0.6.3            py36hee92d8f_0  
pycparser                 2.18             py36h724b2fc_1  
pycrypto                  2.6.1            py36h1de35cc_7  
pycurl                    7.43.0.1         py36hdbc3d79_0  
pyepsg                    0.3.2            py36hba2fa79_0  
pyflakes                  1.6.0            py36hea45e83_0  
pygments                  2.2.0            py36h240cd3f_0  
pylint                    1.8.2                    py36_0  
pyodbc                    4.0.22           py36h0a44026_0  
pyopenssl                 17.5.0           py36h51e4350_0  
pyparsing                 2.2.0            py36hb281f35_0  
pyproj                    1.9.5.1                  py36_0    conda-forge
Pypubsub                  4.0.0                     <pip>
pyqt                      5.6.0            py36he5c6137_6  
pyshp                     1.2.12                     py_0    conda-forge
pysocks                   1.6.7            py36hfa33cec_1  
pytables                  3.4.2            py36hfbd7ab0_2  
pytest                    3.3.2                    py36_0  
python                    3.6.4                hc167b69_1  
python-dateutil           2.6.1            py36h86d2abb_1  
python.app                2                py36h54569d5_7  
pytz                      2017.3           py36hf0bf824_0  
pywavelets                0.5.2            py36h2710a04_0  
pyyaml                    3.12             py36h2ba1e63_1  
pyzmq                     16.0.3           py36he48b5ad_0  
qt                        5.6.2               h9975529_14  
qtawesome                 0.4.4            py36h468c6fb_0  
qtconsole                 4.3.1            py36hd96c0ff_0  
qtpy                      1.3.1            py36h16bb863_0  
readline                  7.0                  hc1231fa_4  
readme-renderer           20.0                      <pip>
requests                  2.18.4           py36h4516966_1  
requests-toolbelt         0.8.0                    py36_0  
rope                      0.10.7           py36h68959ac_0  
ruamel_yaml               0.15.35          py36h1de35cc_1  
scikit-learn              0.19.1           py36hffbff8c_0  
scipy                     1.0.0            py36h1de22e9_0  
scripttest                1.3                       <pip>
send2trash                1.4.2                    py36_0  
setuptools                39.0.1                    <pip>
setuptools                38.4.0                   py36_0  
shapely                   1.6.2            py36hed20685_0  
simplegeneric             0.8.1                    py36_2  
singledispatch            3.4.0.3          py36hf20db9d_0  
sip                       4.18.1           py36h2824476_2  
six                       1.11.0           py36h0e22d5e_1  
six                       1.11.0                    <pip>
snowballstemmer           1.2.1            py36h6c7b616_0  
sortedcollections         0.5.3            py36he9c3ed6_0  
sortedcontainers          1.5.9                    py36_0  
sphinx                    1.6.6                    py36_0  
sphinxcontrib             1.0              py36h9364dc8_1  
sphinxcontrib-websupport  1.0.1            py36h92f4a7a_1  
spyder                    3.2.6                    py36_0  
sqlalchemy                1.2.1            py36h1de35cc_0  
sqlite                    3.22.0               h3efe00b_0  
sympy                     1.1.1            py36h7f3cf04_0  
tblib                     1.3.2            py36hda67792_0  
terminado                 0.8.1                    py36_1  
testpath                  0.3.1            py36h625a49b_0  
tk                        8.6.7                h35a86e2_3  
toolz                     0.9.0                    py36_0  
tornado                   4.5.3                    py36_0  
tqdm                      4.23.4                   py36_0  
traitlets                 4.3.2            py36h65bd3ce_0  
twine                     1.11.0                   py36_0  
typing                    3.6.2            py36haa2d9ef_0  
uncertainties             3.0.2                    py36_1    conda-forge
unicodecsv                0.14.1           py36he531d66_0  
unixodbc                  2.3.4                h4cb4dde_1  
urllib3                   1.22             py36h68b9469_0  
wcwidth                   0.1.7            py36h8c6ec74_0  
webencodings              0.5.1            py36h3b9701d_1  
werkzeug                  0.14.1                   py36_0  
wheel                     0.30.0           py36h5eb2c71_1  
widgetsnbextension        3.1.0                    py36_0  
wrapt                     1.10.11          py36hc29e774_0  
wxPython                  4.0.3                     <pip>
xlrd                      1.1.0            py36h336f4a2_1  
xlsxwriter                1.0.2            py36h3736301_0  
xlwings                   0.11.5                   py36_0  
xlwt                      1.2.0            py36h5ad1178_0  
xz                        5.2.3                h0278029_2  
yaml                      0.1.7                hc338f04_2  
zeromq                    4.2.2                ha360ad0_2  
zict                      0.1.3            py36h71da714_0  
zlib                      1.2.11               hf3cbc9b_2 

pip list

@QuLogic
Copy link
Member

QuLogic commented Oct 7, 2018

The contours can be reduced to these two broken paths:

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.path as mpath
import numpy as np

verts17 = np.array([
 [-170.        , -90.        ],
 [-160.        , -90.        ],
 [-150.        , -90.        ],
 [-140.        , -90.        ],
 [-130.        , -90.        ],
 [-120.        , -90.        ],
 [-110.        , -90.        ],
 [-100.        , -90.        ],
 [ -90.        , -90.        ],
 [ -80.        , -90.        ],
 [ -70.        , -90.        ],
 [ -60.        , -90.        ],
 [ -50.        , -90.        ],
 [ -40.        , -90.        ],
 [ -30.        , -90.        ],
 [ -20.        , -90.        ],
 [ -10.        , -90.        ],
 [   0.        , -90.        ],
 [  10.        , -90.        ],
 [  20.        , -90.        ],
 [  30.        , -90.        ],
 [  40.        , -90.        ],
 [  50.        , -90.        ],
 [  60.        , -90.        ],
 [  70.        , -90.        ],
 [  80.        , -90.        ],
 [  90.        , -90.        ],
 [ 100.        , -90.        ],
 [ 110.        , -90.        ],
 [ 120.        , -90.        ],
 [ 130.        , -90.        ],
 [ 140.        , -90.        ],
 [ 150.        , -90.        ],
 [ 160.        , -90.        ],
 [ 170.        , -90.        ],
 [ 180.        , -90.        ],
 [ 180.        , -88.06480482],
 [ 170.        , -88.19689778],
 [ 160.        , -88.26258068],
 [ 150.        , -88.26947457],
 [ 140.        , -88.21430546],
 [ 130.        , -88.08098516],
 [ 120.        , -87.8311056 ],
 [ 110.        , -87.37441191],
 [ 100.        , -86.46208528],
 [  90.        , -84.10837483],
 [  84.3443839 , -80.        ],
 [  82.5282601 , -70.        ],
 [  83.31809409, -60.        ],
 [  85.45458246, -50.        ],
 [  89.08554991, -40.        ],
 [  90.        , -38.46802366],
 [  99.71787765, -30.        ],
 [ 100.        , -29.86852629],
 [ 110.        , -27.99419447],
 [ 120.        , -27.67466329],
 [ 130.        , -28.10693902],
 [ 140.        , -29.35305703],
 [ 143.03836208, -30.        ],
 [ 150.        , -31.7583954 ],
 [ 160.        , -35.13382265],
 [ 170.        , -39.20356446],
 [ 171.74123963, -40.        ],
 [ 180.        , -44.25336715],
 [ 180.        , -40.        ],
 [ 180.        , -39.90678111],
 [ 170.        , -35.33327859],
 [ 160.        , -31.27633115],
 [ 156.2191454 , -30.        ],
 [ 150.        , -28.21691104],
 [ 140.        , -26.10059642],
 [ 130.        , -24.84924035],
 [ 120.        , -24.29664457],
 [ 110.        , -24.2357849 ],
 [ 100.        , -25.33754215],
 [  90.        , -29.99709329],
 [  89.99691751, -30.        ],
 [  84.02835495, -40.        ],
 [  80.73076516, -50.        ],
 [  80.        , -53.01792348],
 [  78.30311067, -60.        ],
 [  75.77262267, -70.        ],
 [  70.71336012, -80.        ],
 [  70.        , -81.11643952],
 [  60.        , -86.53485986],
 [  50.        , -87.81217178],
 [  40.        , -88.36391949],
 [  30.        , -88.65812942],
 [  20.        , -88.82994152],
 [  10.        , -88.93226075],
 [   0.        , -88.98936602],
 [ -10.        , -89.01312918],
 [ -20.        , -89.00890267],
 [ -30.        , -88.97771693],
 [ -40.        , -88.91670403],
 [ -50.        , -88.81813456],
 [ -60.        , -88.66642441],
 [ -70.        , -88.43064893],
 [ -80.        , -88.04423025],
 [ -90.        , -87.33787453],
 [-100.        , -85.72495289],
 [-109.30108519, -80.        ],
 [-110.        , -79.72032435],
 [-120.        , -73.87360322],
 [-124.00085117, -70.        ],
 [-130.        , -66.47702774],
 [-139.57861887, -60.        ],
 [-140.        , -59.7801689 ],
 [-150.        , -54.8341225 ],
 [-159.48461603, -50.        ],
 [-160.        , -49.76606705],
 [-170.        , -45.03326184],
 [-179.80462939, -40.        ],
 [-180.        , -39.90678111],
 [-180.        , -40.        ],
 [-180.        , -44.25336715],
 [-170.        , -49.21772383],
 [-168.3447695 , -50.        ],
 [-160.        , -54.49737642],
 [-150.        , -59.40162374],
 [-148.78879731, -60.        ],
 [-140.        , -66.28648692],
 [-134.09548541, -70.        ],
 [-130.        , -76.33997544],
 [-126.12935689, -80.        ],
 [-130.        , -82.80062298],
 [-140.        , -85.71941512],
 [-150.        , -86.8803473 ],
 [-160.        , -87.48675446],
 [-170.        , -87.84430274],
 [-180.        , -88.06480482],
 [-180.        , -90.        ],
 [-170.        , -90.        ]])
codes17 = np.array([1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 79])
bad_path17 = mpath.Path(verts17, codes17)
verts18 = np.array([
 [-110.         , 49.76654914],
 [-100.         , 48.06726757],
 [ -90.         , 47.83070886],
 [ -80.         , 49.51041661],
 [ -78.48184154 , 50.        ],
 [ -70.         , 55.59874175],
 [ -62.92912972 , 60.        ],
 [ -60.         , 68.98354974],
 [ -59.48362882 , 70.        ],
 [ -60.         , 71.96086464],
 [ -65.36243675 , 80.        ],
 [ -60.         , 82.08541582],
 [ -50.         , 84.26827105],
 [ -40.         , 85.41441829],
 [ -30.         , 86.05775411],
 [ -20.         , 86.40296264],
 [ -10.         , 86.53295542],
 [   0.         , 86.46670029],
 [  10.         , 86.16593423],
 [  20.         , 85.49503981],
 [  30.         , 84.04405843],
 [  40.         , 80.13007872],
 [  40.1755513  , 80.        ],
 [  48.01772332 , 70.        ],
 [  50.         , 68.09459195],
 [  55.47216536 , 60.        ],
 [  60.         , 56.42708207],
 [  67.37826371 , 50.        ],
 [  70.         , 48.69264769],
 [  80.         , 44.39058248],
 [  90.         , 41.37291304],
 [ 100.         , 40.12749416],
 [ 110.         , 41.22341995],
 [ 120.         , 44.60261529],
 [ 130.         , 49.16288744],
 [ 131.74881042 , 50.        ],
 [ 140.         , 54.98074439],
 [ 150.         , 59.0727081 ],
 [ 153.35828768 , 60.        ],
 [ 160.         , 62.93157679],
 [ 170.         , 65.30146242],
 [ 180.         , 66.36452994],
 [ 180.         , 70.        ],
 [ 180.         , 80.        ],
 [ 180.         , 90.        ],
 [ 170.         , 90.        ],
 [ 160.         , 90.        ],
 [ 150.         , 90.        ],
 [ 140.         , 90.        ],
 [ 130.         , 90.        ],
 [ 120.         , 90.        ],
 [ 110.         , 90.        ],
 [ 100.         , 90.        ],
 [  90.         , 90.        ],
 [  80.         , 90.        ],
 [  70.         , 90.        ],
 [  60.         , 90.        ],
 [  50.         , 90.        ],
 [  40.         , 90.        ],
 [  30.         , 90.        ],
 [  20.         , 90.        ],
 [  10.         , 90.        ],
 [   0.         , 90.        ],
 [ -10.         , 90.        ],
 [ -20.         , 90.        ],
 [ -30.         , 90.        ],
 [ -40.         , 90.        ],
 [ -50.         , 90.        ],
 [ -60.         , 90.        ],
 [ -70.         , 90.        ],
 [ -80.         , 90.        ],
 [ -90.         , 90.        ],
 [-100.         , 90.        ],
 [-110.         , 90.        ],
 [-120.         , 90.        ],
 [-130.         , 90.        ],
 [-140.         , 90.        ],
 [-150.         , 90.        ],
 [-160.         , 90.        ],
 [-170.         , 90.        ],
 [-180.         , 90.        ],
 [-180.         , 80.        ],
 [-180.         , 70.        ],
 [-180.         , 66.36452994],
 [-170.         , 66.49729491],
 [-160.         , 65.73294484],
 [-150.         , 63.78287603],
 [-140.53635295 , 60.        ],
 [-140.         , 59.88238149],
 [-130.         , 57.2018102 ],
 [-120.         , 53.72014009],
 [-110.8967899  , 50.        ],
 [-110.         , 49.76654914],
])
codes18 = np.array([1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 79])
bad_path18 = mpath.Path(verts18, codes18)

lon_0 = 0

# plot with cartopy
ax = plt.axes(projection=ccrs.Mollweide(central_longitude=lon_0))
ax.set_global()

patch = mpatches.PathPatch(bad_path17, facecolor='C0', edgecolor='none',
                           label='17 0', transform=ccrs.PlateCarree())
ax.add_patch(patch)
ax.scatter(verts17[:, 0], verts17[:, 1], color=f'C1', marker='x',
           transform=ccrs.PlateCarree(), label='17 0')

patch = mpatches.PathPatch(bad_path18, facecolor='C2', edgecolor='none',
                           label='18 2', transform=ccrs.PlateCarree())
ax.add_patch(patch)
ax.scatter(verts18[:, 0], verts18[:, 1], color=f'C3', marker='x',
           transform=ccrs.PlateCarree(), label='18 2')

ax.legend()

plt.show()

The scatter points do appear in the right place, so it seems there is a problem when stitching the transformed points back into shape somehow, at least for the top one.

@QuLogic
Copy link
Member

QuLogic commented Oct 7, 2018

Even shorter reproducer on the top one:

verts18 = np.array([
    [-110., 50.],
    [   0., 80.],
    [   0., 90.],
    [-180., 90.],
    [-180., 70.],
    [-110., 50.],
])
codes18 = np.array([1, 2, 2, 2, 2, 79])

@QuLogic
Copy link
Member

QuLogic commented Oct 8, 2018

There seems to be something up in cartopy.trace.project_linear; if [-180., 70.], is changed to [-179., 70.],, then the output of that function is reasonable:

okay
(the hole is fixed either when stitched to the boundary or when converted to a ring.)

But in the original, it looks like:
broken

You can add 9s after the decimal until -179.999999999999 (-180 + 1e-12) when it flips to the broken result.

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

Successfully merging a pull request may close this issue.

2 participants