我按照此处的示例(https://unidata.github.io/python-gallery/examples/Precipitation_Map.html)但是在尝试访问单位时出现维度错误。我假设这与pint
它解析单位的方式和降水量是一个速率有关。任何帮助,将不胜感激
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import metpy
import datetime
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from xarray.backends import NetCDF4DataStore
import xarray as xr
import numpy as np
from metpy.units import masked_array, units
from siphon.catalog import TDSCatalog
best_gfs = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/'
'Global_0p25deg/catalog.xml?dataset=grib/NCEP/GFS/Global_0p25deg/Best')
best_gfs.datasets
best_ds = list(best_gfs.datasets.values())[0]
ncss = best_ds.subset()
query = ncss.query()
query.lonlat_box(-66.243114,-25.762908,-28.708933, -2.191886).time_range(datetime.datetime.utcnow(), datetime.datetime.utcnow() + datetime.timedelta(days=10))
query.accept('netcdf4')
query.variables('Precipitation_rate_surface')
data = ncss.get_data(query)
data = xr.open_dataset(NetCDF4DataStore(data))
lon_2d, lat_2d = np.meshgrid(data['lon'], data['lat'])
precip = data['Precipitation_rate_surface']
precip.metpy.units