Reputation: 9
Thank you in advance for assistance with this issue. I have been working tirelessly to get this working, but as a non-expert I've found myself stuck with the following issue.
Goal: I am working on plotting a differential emissions map between two emission scenarios from GEOS-Chem GCHP output netCDF outputs. I was able to get my code to compile properly before updating Anaconda, Spyder and several other python packages--but post update, my code is not compiling properly.
Here is all of the information you will need to know:
Code Script:
# 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
Differential Output from Script:
C2H6 Concentration (pptv) 2018-01: Emission Differential
Associated Error Output:
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)
At this point, I am unsure what I can do to correct for this. ANY help would be greatly appreciated. Once again, thanks in advance and kind regards!
Upvotes: 0
Views: 700
Reputation: 3407
This appears to be a warning message, not an error message. It is sayng that a function/method is calling a deprecated function. This is potentially a problem in future when the deprecated function is deleted, but for now it is best to ignore it. The only thing you could do is raise an issue, in case the cartopy developers are not aware of it: https://github.com/SciTools/cartopy/issues
update:
... the devs are aware of it.... https://github.com/SciTools/cartopy/pull/1914
Consider upgrading your cartopy-version to v20.0.2!
Upvotes: 1