首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >依赖错误: Cartopy & Numpy

依赖错误: Cartopy & Numpy
EN

Stack Overflow用户
提问于 2022-03-07 20:50:48
回答 1查看 385关注 0票数 0

预先感谢您在这个问题上的帮助。我一直在不懈地工作,以使这项工作,但作为一个非专家,我发现自己陷入了以下问题。

目标:I正在绘制来自GEOS输出netCDF输出的两个排放场景之间的差异排放图。在更新Anaconda、Spyder和其他几个python包之前,我能够正确地编译我的代码--但是在更新之后,我的代码没有正确编译。

以下是您需要了解的所有信息:

代码脚本:

代码语言:javascript
运行
复制
# Key Module Import(s)
import os
import csv # Module which enables the script to work directly with .csv files, in this case being the NOAA and INSTAAR Observation Data
import numpy as np
import netCDF4 as nc
import pandas as pd
import xarray as xr
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.legend import _get_legend_handles_labels
import datetime
import cartopy.crs as crs
import cartopy.feature as cft

# Directories + Location(s)
GCHP_C24_Baseline_OutDir = ('E:/PSU/CCAR REU/Emissions Inventories - GEOS-CHEM/GEOS-Chem Output Directory/Baseline Simulations/C24_Baseline/baseline_c24_2018 (Monthly)/') # GCHP C2H6 C24_Baseline Output Directory
GCHP_M24_Modified_OutDir = ('E:/PSU/CCAR REU/Emissions Inventories - GEOS-CHEM/GEOS-Chem Output Directory/Modified Simulations/C24_Modified/NEW RUN_M24/') # GCHP C2H6 M24_Modified Output Directory

# Baseline - Monthly Outputs
C24_01 = xr.open_dataset(GCHP_C24_Baseline_OutDir + 'GEOSChem.SpeciesConcMonthlyAvg.20180101_0000z.nc4') # Location of Monthly Average of C2H6 C24_Baseline GCHP Output file for 01/2018

# Variable Extraction & Unit Conversion:
C_C24_01 = C24_01['SpeciesConc_C2H6']*1e12

# Modified - Monthly Outputs
M24_01 = xr.open_dataset(GCHP_M24_Modified_OutDir + 'GEOSChem.SpeciesConcMonthlyAvg.20180101_0000z.nc4') # Location of Monthly Average of C2H6 M24_Modified GCHP Output file for 01/2018

# Variable Extraction & Unit Conversion:
C_M24_01 = M24_01['SpeciesConc_C2H6']*1e12

# Differential Calculation(s):
diff_01 = (C_M24_01 - C_C24_01)

# Cartographic Parameters:
plt.rcParams['figure.dpi'] = 500
fig = plt.figure(figsize=(9,7))
ax = plt.axes(projection = crs.PlateCarree()) # Global Projection
ax.set_global()

# Carographic Feature(s):
ax.add_feature(cft.COASTLINE)
ax.add_feature(cft.BORDERS, linestyle = 'solid', linewidth = 0.80)
ax.gridlines(draw_labels=True, color='grey', alpha=0.8, linestyle='--')

# Plot(s)

# 2018-01
diff_01[0,0].plot(cmap = 'coolwarm', ax=ax, cbar_kwargs = {"orientation": "horizontal"})
plt.title('C2H6 Concentration (pptv) 2018-01: Emission Scenario Differential', fontsize = 15, fontstyle = 'italic', loc = 'center', y = 1.075) # Title
ax.text(-0.09, 0.5, 'Latitude', va='bottom', ha='center', rotation='vertical', rotation_mode='anchor', fontsize = 10, fontweight = 'bold', transform=ax.transAxes) # Y-Axis
ax.text(0.5, -0.14, 'Longitude', va='bottom', ha='center', rotation='horizontal', rotation_mode='anchor', fontsize = 10, fontweight = 'bold', transform=ax.transAxes) # X-Axis

脚本的差异输出:

2018-01年C2H6浓度:排放差异

相关错误输出:

代码语言:javascript
运行
复制
runfile('E:/PSU/CCAR REU/Python Codex/GCHP - Differential map_C24.py', wdir='E:/PSU/CCAR REU/Python Codex')
C:\Users\Jordan\anaconda3\lib\site-packages\cartopy\crs.py:228: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the  number of parts of a multi-part geometry.
  if len(multi_line_string) > 1:
C:\Users\Jordan\anaconda3\lib\site-packages\cartopy\crs.py:239: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the  number of parts of a multi-part geometry.
  line_strings = list(multi_line_string)
C:\Users\Jordan\anaconda3\lib\site-packages\cartopy\crs.py:239: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  line_strings = list(multi_line_string)
C:\Users\Jordan\anaconda3\lib\site-packages\cartopy\crs.py:280: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  for line in multi_line_string:
C:\Users\Jordan\anaconda3\lib\site-packages\cartopy\crs.py:347: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the  number of parts of a multi-part geometry.
  if len(p_mline) > 0:
C:\Users\Jordan\anaconda3\lib\site-packages\cartopy\crs.py:385: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  line_strings.extend(multi_line_string)
C:\Users\Jordan\anaconda3\lib\site-packages\cartopy\crs.py:385: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the  number of parts of a multi-part geometry.
  line_strings.extend(multi_line_string)
C:\Users\Jordan\anaconda3\lib\site-packages\cartopy\mpl\gridliner.py:549: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the  number of parts of a multi-part geometry.
  elif len(intersection) > 4:
C:\Users\Jordan\anaconda3\lib\site-packages\cartopy\mpl\gridliner.py:556: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  xy = np.append(intersection[0], intersection[-1],
<__array_function__ internals>:5: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
C:\Users\Jordan\anaconda3\lib\site-packages\numpy\lib\function_base.py:4817: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  return concatenate((arr, values), axis=axis)

在这一点上,我不知道我能做些什么来纠正这个问题。任何帮助都将不胜感激。再次,谢谢您的问候!

EN

回答 1

Stack Overflow用户

发布于 2022-03-08 08:48:50

这似乎是一条警告消息,而不是错误消息。它是说一个函数/方法正在调用一个不推荐的函数。在将来删除弃用函数时,这可能是一个问题,但就目前而言,最好忽略它。你唯一能做的就是提出一个问题,以防那些没有意识到的开发者:https://github.com/SciTools/cartopy/issues

更新:

..。神知道这件事..。https://github.com/SciTools/cartopy/pull/1914

考虑将您的cartopy版本升级到v20.0.2!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71387103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档