Skip to content
Snippets Groups Projects
Commit 59a4580c authored by Michael Blaschek's avatar Michael Blaschek :bicyclist:
Browse files

py,cartopy update

parent 32e39ea7
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Testing Cartopy # Testing Cartopy
Cartopy is a popular plotting library and depends on `geos` and `proj` libraries and therefore need to be linked against these. Currently it is possible to install cartopy in any version you want, using the provided module libraries: Cartopy is a popular plotting library and depends on `geos` and `proj` libraries and therefore need to be linked against these. Currently it is possible to install cartopy in any version you want, using the provided module libraries:
- `geos/3.9.1-gcc-8.4.1` or similar using gcc - `geos/3.9.1-gcc-8.4.1` or similar using gcc
- `proj/8.1.0-gcc-8.4.1` or similar using gcc - `proj/8.1.0-gcc-8.4.1` or similar using gcc
However, there are still some issues with Cartopy. Please note that its version is `0.XX` that means development and not a stable release.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
!module --no-pager list !module --no-pager list
``` ```
%% Output %% Output
Currently Loaded Modulefiles: Currently Loaded Modulefiles:
1) anaconda3/2020.07-gcc-8.4.1 3) proj/8.1.0-gcc-8.4.1 1) anaconda3/2021.05-gcc-8.5.0 3) proj/8.1.0-gcc-8.5.0
2) geos/3.9.1-gcc-8.4.1 2) geos/3.8.1-gcc-8.5.0
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
%pylab inline %pylab inline
``` ```
%% Output %% Output
Populating the interactive namespace from numpy and matplotlib Populating the interactive namespace from numpy and matplotlib
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import cartopy.crs as ccrs import cartopy.crs as ccrs
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
fig = plt.figure(figsize=(10, 5)) fig = plt.figure(figsize=(10, 5))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.Robinson()) ax = fig.add_subplot(1, 1, 1, projection=ccrs.Robinson())
# make the map global rather than have it zoom in to # make the map global rather than have it zoom in to
# the extents of any plotted data # the extents of any plotted data
ax.set_global() ax.set_global()
ax.stock_img() ax.stock_img()
ax.coastlines() ax.coastlines()
ax.plot(-0.08, 51.53, 'o', transform=ccrs.PlateCarree()) ax.plot(-0.08, 51.53, 'o', transform=ccrs.PlateCarree())
ax.plot([-0.08, 132], [51.53, 43.17], transform=ccrs.PlateCarree()) ax.plot([-0.08, 132], [51.53, 43.17], transform=ccrs.PlateCarree())
ax.plot([-0.08, 132], [51.53, 43.17], transform=ccrs.Geodetic()) ax.plot([-0.08, 132], [51.53, 43.17], transform=ccrs.Geodetic())
``` ```
%% Output %% Output
/home/spack/.local/lib/python3.8/site-packages/cartopy/img_transform.py:308: RuntimeWarning: invalid value encountered in greater /home/spack/.local/lib/python3.8/site-packages/cartopy/img_transform.py:308: RuntimeWarning: invalid value encountered in greater
non_self_inverse_points = (((np.abs(target_x_points - back_to_target_x) / non_self_inverse_points = (((np.abs(target_x_points - back_to_target_x) /
/home/spack/.local/lib/python3.8/site-packages/cartopy/img_transform.py:310: RuntimeWarning: invalid value encountered in greater /home/spack/.local/lib/python3.8/site-packages/cartopy/img_transform.py:310: RuntimeWarning: invalid value encountered in greater
((np.abs(target_y_points - back_to_target_y) / ((np.abs(target_y_points - back_to_target_y) /
[<matplotlib.lines.Line2D at 0x7fa7c05e0100>] [<matplotlib.lines.Line2D at 0x7fa7c05e0100>]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Write the necessary modules into the kernel launcher configuration file: Write the necessary modules into the kernel launcher configuration file:
`~/load_modules_into_jupyter.conf` `~/load_modules_into_jupyter.conf`
If that files is written just now. restart the kernel otherwise the pip install will fail. If that files is written just now. restart the kernel otherwise the pip install will fail.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
%%writefile ~/load_modules_into_jupyter.conf %%writefile ~/load_modules_into_jupyter.conf
geos geos
proj proj
``` ```
%% Output %% Output
Writing /home/spack/load_modules_into_jupyter.conf Writing /home/spack/load_modules_into_jupyter.conf
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Execute the local `--user` install of cartopy into your home directory: Execute the local `--user` install of cartopy into your home directory:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
!pip install --user cartopy # Cartopy 0.20.0 with shapely
!pip install --user cartopy==0.20.0 shapely==1.7.1
# Cartopy 0.20.2 with shapely 1.8.0 (does not work with 1.8.1 or 1.8.2)
# !pip install --user shapely==1.8.0 cartopy
``` ```
%% Output %% Output
Collecting cartopy Collecting cartopy
Using cached Cartopy-0.20.0.tar.gz (10.8 MB) Using cached Cartopy-0.20.0.tar.gz (10.8 MB)
Installing build dependencies ... [?25ldone Installing build dependencies ... [?25ldone
[?25h Getting requirements to build wheel ... [?25ldone [?25h Getting requirements to build wheel ... [?25ldone
[?25h Preparing wheel metadata ... [?25ldone [?25h Preparing wheel metadata ... [?25ldone
[?25hCollecting shapely>=1.6.4 [?25hCollecting shapely>=1.6.4
Downloading Shapely-1.7.1-cp38-cp38-manylinux1_x86_64.whl (1.0 MB) Downloading Shapely-1.7.1-cp38-cp38-manylinux1_x86_64.whl (1.0 MB)
 |████████████████████████████████| 1.0 MB 23.6 MB/s eta 0:00:01  |████████████████████████████████| 1.0 MB 23.6 MB/s eta 0:00:01
[?25hCollecting pyproj>=3.0.0 [?25hCollecting pyproj>=3.0.0
Downloading pyproj-3.2.1-cp38-cp38-manylinux2010_x86_64.whl (6.3 MB) Downloading pyproj-3.2.1-cp38-cp38-manylinux2010_x86_64.whl (6.3 MB)
 |████████████████████████████████| 6.3 MB 102.1 MB/s eta 0:00:01  |████████████████████████████████| 6.3 MB 102.1 MB/s eta 0:00:01
[?25hRequirement already satisfied: matplotlib>=3.1 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from cartopy) (3.2.2) [?25hRequirement already satisfied: matplotlib>=3.1 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from cartopy) (3.2.2)
Requirement already satisfied: numpy>=1.18 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from cartopy) (1.18.5) Requirement already satisfied: numpy>=1.18 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from cartopy) (1.18.5)
Collecting pyshp>=2.1 Collecting pyshp>=2.1
Downloading pyshp-2.1.3.tar.gz (219 kB) Downloading pyshp-2.1.3.tar.gz (219 kB)
 |████████████████████████████████| 219 kB 103.9 MB/s eta 0:00:01  |████████████████████████████████| 219 kB 103.9 MB/s eta 0:00:01
[?25hRequirement already satisfied: certifi in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from pyproj>=3.0.0->cartopy) (2020.6.20) [?25hRequirement already satisfied: certifi in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from pyproj>=3.0.0->cartopy) (2020.6.20)
Requirement already satisfied: cycler>=0.10 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from matplotlib>=3.1->cartopy) (0.10.0) Requirement already satisfied: cycler>=0.10 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from matplotlib>=3.1->cartopy) (0.10.0)
Requirement already satisfied: python-dateutil>=2.1 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from matplotlib>=3.1->cartopy) (2.8.1) Requirement already satisfied: python-dateutil>=2.1 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from matplotlib>=3.1->cartopy) (2.8.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from matplotlib>=3.1->cartopy) (2.4.7) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from matplotlib>=3.1->cartopy) (2.4.7)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from matplotlib>=3.1->cartopy) (1.2.0) Requirement already satisfied: kiwisolver>=1.0.1 in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from matplotlib>=3.1->cartopy) (1.2.0)
Requirement already satisfied: six in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from cycler>=0.10->matplotlib>=3.1->cartopy) (1.15.0) Requirement already satisfied: six in /home/swd/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.4.1/anaconda3-2020.07-4onhdcbnvyvwfdxxbelrplxjihjsknex/lib/python3.8/site-packages (from cycler>=0.10->matplotlib>=3.1->cartopy) (1.15.0)
Building wheels for collected packages: cartopy, pyshp Building wheels for collected packages: cartopy, pyshp
Building wheel for cartopy (PEP 517) ... [?25ldone Building wheel for cartopy (PEP 517) ... [?25ldone
[?25h Created wheel for cartopy: filename=Cartopy-0.20.0-cp38-cp38-linux_x86_64.whl size=10980651 sha256=c63e7fc196492e2db81029ed2af8d2f3fb1ba3fa2129e8e4c59d6000c2a5a591 [?25h Created wheel for cartopy: filename=Cartopy-0.20.0-cp38-cp38-linux_x86_64.whl size=10980651 sha256=c63e7fc196492e2db81029ed2af8d2f3fb1ba3fa2129e8e4c59d6000c2a5a591
Stored in directory: /home/spack/.cache/pip/wheels/f2/b9/4d/cf1a107ee01bae40000f27ed744a269bc251223b241fd71117 Stored in directory: /home/spack/.cache/pip/wheels/f2/b9/4d/cf1a107ee01bae40000f27ed744a269bc251223b241fd71117
Building wheel for pyshp (setup.py) ... [?25ldone Building wheel for pyshp (setup.py) ... [?25ldone
[?25h Created wheel for pyshp: filename=pyshp-2.1.3-py3-none-any.whl size=37262 sha256=85f688d164ea994b5d66b0fb71c3fc0c78a6a9d74fdef026991ef2fca114c18e [?25h Created wheel for pyshp: filename=pyshp-2.1.3-py3-none-any.whl size=37262 sha256=85f688d164ea994b5d66b0fb71c3fc0c78a6a9d74fdef026991ef2fca114c18e
Stored in directory: /home/spack/.cache/pip/wheels/1f/1b/b5/54affbefc8a7e2bdf1da000fc576b8a1c91338f1f327a04f4c Stored in directory: /home/spack/.cache/pip/wheels/1f/1b/b5/54affbefc8a7e2bdf1da000fc576b8a1c91338f1f327a04f4c
Successfully built cartopy pyshp Successfully built cartopy pyshp
Installing collected packages: shapely, pyproj, pyshp, cartopy Installing collected packages: shapely, pyproj, pyshp, cartopy
Successfully installed cartopy-0.20.0 pyproj-3.2.1 pyshp-2.1.3 shapely-1.7.1 Successfully installed cartopy-0.20.0 pyproj-3.2.1 pyshp-2.1.3 shapely-1.7.1
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
**When the installation is completed, restart the current kernel and try to plot again.** **When the installation is completed, restart the current kernel and try to plot again.**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment