Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I cannot plot vertical velocity with depth using 2160 #338

Open
ccomm2 opened this issue Nov 14, 2024 · 0 comments
Open

I cannot plot vertical velocity with depth using 2160 #338

ccomm2 opened this issue Nov 14, 2024 · 0 comments

Comments

@ccomm2
Copy link

ccomm2 commented Nov 14, 2024

I cannot plot vertical velocity with depth using 2160
THIS IS MY CODE:

from xmitgcm import llcreader
import xarray as xr

from pylab import mpl
mpl.rcParams['font.sans-serif']=['SimHei']

创建模型实例

model = llcreader.ECCOPortalLLC2160Model()

获取数据集,指定需要的变量(垂直速度 'W')和垂直层级

ds = model.get_dataset(varnames=['W'], k_levels=list(range(10)))

查看数据集的信息

print(ds)

选择第一个时间步长,第一个面的第一个网格点的数据

w_data = ds['W'].isel(time=0, face=0, j=0, i=0)

查看选定的数据

print(w_data)
import matplotlib.pyplot as plt

获取深度数据

depths = ds['Z'].isel(k=list(range(10))) # 确保深度与垂直速度对应

绘制垂直速度随深度变化的图

plt.figure(figsize=(10, 6))
plt.plot(w_data, depths)
plt.xlabel('垂直速度 (m/s)')
plt.ylabel('深度 (m)')
plt.title('垂直速度随深度变化')
plt.gca(
plt.show()).invert_yaxis() # 因为深度增加是向下的,所以反转y轴
plt.grid(True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant