我对python真的很陌生,我需要在python中绘制海面温度(sst)的数据netcdf,但它一直出错。
我在另一个笔记本中使用相同的代码,它运行得很好。
###SST CÓDIGO PLOT
import numpy as np
import matplotlib.pyplot as plt
from numpy import pi
from mpl_toolkits.basemap import Basemap
from netCDF4 import Dataset
import pandas as pd
from scipy import stats
import seaborn as sns
import xarray as xr
import cartopy.crs as ccrs
import os
from netCDF4 import Dataset as netcdf_dataset
from cartopy import config
import statistics
import glob
import seaborn as sns
ds = xr.open_dataset('/home/mayna/Downloads/d86/20190327010000-OSISAF-L3C_GHRSST-SSTsubskin-GOES16-ssteqc_goes16_20190327_010000-v02.0-fv01.0.nc')
plt.figure(figsize=(8,4))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.add_feature(cartopy.feature.BORDERS, linestyle='-', linewidth=0.25)
ax.coastlines(linewidth=0.25)
ds['sea_surface_temperature'][0,:,:].plot.contourf(levels=20, ax=ax, transform=ccrs.PlateCarree(),cmap='coolwarm')
它说错误在“ax.add_feature(cartopy.feature.BORDERS,linestyle ='-',linewidth = 0.25)”行中,即“NameError:名称'cartopy'未定义”。
你认为这是什么问题?
PS:我知道我使用了很多不需要的库