cartopy 投影计算量大吗?

0 投票
0 回答
36 浏览
提问于 2025-04-12 01:18

我从几个月前开始使用Cartopy,就一直在为它苦恼。很多时候,我的Jupyter笔记本都崩溃了,连从命令行运行脚本也不行。我现在用的是Linux操作系统,电脑内存是8GB。

Cartopy是不是很占用计算资源?要顺利运行它,理想的系统配置应该是什么样的呢?

比如,下面这个代码片段(来自xarray)在我的系统上就无法运行。

from __future__ import division

import xarray as xr
import cartopy.crs as ccrs
import matplotlib.pyplot as plt

# Load the data
ds = xr.tutorial.load_dataset('air_temperature')
air = ds.air.isel(time=[0, 724]) - 273.15

# This is the map projection we want to plot *onto*
map_proj = ccrs.LambertConformal(central_longitude=-95, central_latitude=45)

p = air.plot(transform=ccrs.PlateCarree(),  # the data's projection
             col='time', col_wrap=1,  # multiplot settings
             aspect=ds.dims['lon'] / ds.dims['lat'],  # for a sensible figsize
             subplot_kws={'projection': map_proj})  # the plot's projection

# We have to set the map's options on all four axes
for ax in p.axes.flat:
    ax.coastlines()
    ax.set_extent([-160, -30, 5, 75])
    # Without this aspect attributes the maps will look chaotic and the
    # "extent" attribute above will be ignored
    ax.set_aspect('equal', 'box-forced')

plt.show()

我正考虑升级我的笔记本电脑。如果有人能推荐一款更好的笔记本或者理想的配置,那就太好了。

非常感谢大家的帮助!

0 个回答

暂无回答

撰写回答