-
Notifications
You must be signed in to change notification settings - Fork 447
Closed
Labels
Area: XarrayPertains to xarray integrationPertains to xarray integration
Milestone
Description
I get an error "vertical attribute is not available." when interpolating bitwise vortices to isentropic surfaces using the mpcalc.isentropic_interpolation_as_dataset function.Here's the code and the specifics of the error reported:
f=xr.open_dataset(r'H:\data\dust\daily_atmosphere_data\daily_mean_era5_pv0.5_198604.nc')
f_1=xr.open_dataset(r'H:\data\dust\daily_atmosphere_data\daily_mean_era5_t0.5_198604.nc')
pv=f.pv.loc['1986-04-01',100000:20000,20:60,30:150] # (level,lat,lon)
t=f_1.t.loc['1986-04-01',100000:20000,20:60,30:150]# (level,lat,lon)
print(t,pv)
isentlevs = [345.] * units.kelvin
print(isen_lev)
isent_data = mpcalc.isentropic_interpolation_as_dataset(isentlevs, t, pv)C:\Users\Administrator\AppData\Local\Temp\ipykernel_8224\906077059.py:12: UserWarning: More than one vertical coordinate present for variable "t".
isent_data = mpcalc.isentropic_interpolation_as_dataset(isentlevs, t, pv)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [20], in <cell line: 12>()
10 print(isen_lev)
11 # 调用 isentropic_interpolation_as_dataset 函数
---> 12 isent_data = mpcalc.isentropic_interpolation_as_dataset(isentlevs, t, pv)
File G:\Anaconda\lib\site-packages\metpy\calc\thermo.py:2761, in isentropic_interpolation_as_dataset(levels, temperature, max_iters, eps, bottom_up_search, *args)
2756 all_args = xr.broadcast(temperature, *args)
2758 # Obtain result as list of Quantities
2759 ret = isentropic_interpolation(
2760 levels,
-> 2761 all_args[0].metpy.vertical,
2762 all_args[0].metpy.unit_array,
2763 *(arg.metpy.unit_array for arg in all_args[1:]),
2764 vertical_dim=all_args[0].metpy.find_axis_number('vertical'),
2765 temperature_out=True,
2766 max_iters=max_iters,
2767 eps=eps,
2768 bottom_up_search=bottom_up_search
2769 )
2771 # Reconstruct coordinates and dims (add isentropic levels, remove isobaric levels)
2772 vertical_dim = all_args[0].metpy.find_axis_name('vertical')
File G:\Anaconda\lib\site-packages\metpy\xarray.py:486, in MetPyDataArrayAccessor.vertical(self)
483 @property
484 def vertical(self):
485 """Return the vertical coordinate."""
--> 486 return self._axis('vertical')
File G:\Anaconda\lib\site-packages\metpy\xarray.py:418, in MetPyDataArrayAccessor._axis(self, axis)
416 coord_var = self._metpy_axis_search(axis)
417 if coord_var is None:
--> 418 raise AttributeError(axis + ' attribute is not available.')
419 else:
420 return coord_var
AttributeError: vertical attribute is not available.Metadata
Metadata
Assignees
Labels
Area: XarrayPertains to xarray integrationPertains to xarray integration