我正在尝试绘制 GPCC 降水的气候图。
但我发现本初子午线处有一块空白(数据切断)。
我该如何解决这个问题?我可以使用 CDO、NCO、Python。
我也分享代码和数据。
(数据) https://drive.google.com/drive/folders/1rEHKz5GQlvC3m_Cfzx48cTrPZPU0qAar?usp=sharing
(GPCC 元数据) https://opendata.dwd.de/climate_environment/GPCC/html/fulldata-monthly_v2022_doi_download.html
type here
from netCDF4 import Dataset
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import xarray as xr
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import calendar
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import cartopy.feature as cfeature
import cftime
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
%matplotlib inline
mpl.rcParams['figure.figsize'] = [8., 6.]
filename = 'D:/ERA5/precip.nc'
ds = xr.open_dataset(filename)
ds
da = ds['precip']
da
def is_jjas(month):
return (month >= 6) & (month <= 9)
dd = da.sel(time=is_jjas(da['time.month']))
def is_1982(year):
return (year> 1981)
dn = dd.sel(time=is_1982(dd['time.year']))
dn
JJAS= dn.groupby('time.year').mean('time')
JJAS2 = JJAS.mean(dim='year', keep_attrs=True)
JJAS2
fig, ax = plt.subplots(1, 1, figsize = (16, 8), subplot_kw={'projection': ccrs.PlateCarree()})
cs = plt.contourf(JJAS2.lon, JJAS2.lat, JJAS2, levels=[0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500],
vmin=0, vmax=500, cmap='Blues', extend='both')
# Set the figure title, add lat/lon grid and coastlines
ax.set_title('', fontsize=16)
ax.gridlines(draw_labels=True, linewidth=1, color='gray', alpha=0.5, linestyle='--')
ax.coastlines(color='black')
ax.set_extent([-20, 30, 0, 30], crs=ccrs.PlateCarree())
cbar = plt.colorbar(cs,fraction=0.05, pad=0.04, extend='both', orientation='horizontal')
我尝试在 Google 上搜索并找到 CDO 方法。如果我插入数据,其分辨率可能会改变。我想使用具有相同分辨率但没有任何空白的 GPCC 数据。