气象python:温度剖面图的绘制

import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset

# 读取 nc 文件
nc_file = "2010_air_12.nc"
nc_data = Dataset(nc_file, "r")

# 获取经度、纬度、时间和温度数据
lon = nc_data.variables["longitude"][:]
lat = nc_data.variables["latitude"][:]
time = nc_data.variables["time"][:]
temp = nc_data.variables["t"][:]
level = nc_data.variables["level"][:]

# 找到对应时间索引(假设时间是按小时存储的)
# 6月25日12:00对应的时间索引为 176
desired_time_index = 176

# 找到对应经度范围索引
desired_lon_indices = np.where((lon >= 70) & (lon <= 140))[0]

# 选择对应时间和经度范围的温度数据
desired_temp = temp[desired_time_index, :, :, desired_lon_indices]

# 绘制温度剖面填色图
plt.imshow(desired_temp[0, :, :], extent=[lat[0], lat[-1], level[0], level[-1]], aspect='auto',cmap='jet')
plt.colorbar(label='Temperature')
plt.xlabel('Latitude')
plt.ylabel('Altitude')
plt.title('xyplot5_python-1')
plt.savefig("xyplot5_python-1.png")
plt.show()

读取nc文件,绘制6月25日12:00,东经70-140度间平均温度剖面填色图,横坐标为纬度,纵坐标为高度。

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值