前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >实用编程 | Python+Matplotlib制作超高分辨率动态气象/海洋要素可视化动图

实用编程 | Python+Matplotlib制作超高分辨率动态气象/海洋要素可视化动图

作者头像
气象学家
发布2021-11-16 10:58:19
9990
发布2021-11-16 10:58:19
举报
文章被收录于专栏:气象学家

Animated version of Gulf Stream sea surface temperatures done with

@oceanographer from yesterday - inspired by the moving media #art installations @refikanadol! Shading and texture comes from simulated zonal currents #SciArt @neuro_rish@matplotlib #FESOM2

FESOM2 SST shaded by U component of velocity

Example of scalar field visualization shaded by corresponding vector field.Data used are from FESOM2 model simulations with 1km resolution in Gulf Stream area. Data are interpolated to regular 1/100 degree grid.

数据空间上进行了插值,大概就是1km左右的格点分辨率了。

链接: (数据+代码+测试图)

https://github.com/koldunovn/FESOM_SST_shaded_by_U

代码:

代码语言:javascript
复制
import xarray as xr
import numpy as np
import matplotlib.pylab as plt
import matplotlib.cm as cm

###Download data:
#wget https://zenodo.org/record/4759091/files/GF_FESOM2_testdata.tar.gz
###Unpack data:
#gunzip GF_FESOM2_testdata.tar.gz
#tar -xvf GF_FESOM2_testdata.tar
###Open netCDF files

sst = xr.open_dataset('./GF_FESOM2_testdata/sst.nc')
u = xr.open_dataset('./GF_FESOM2_testdata/u_surf.nc')
v = xr.open_dataset('./GF_FESOM2_testdata/v_surf.nc')

###Plot the figure with U shading

fig, ax = plt.subplots(
            1,
            1,
            constrained_layout=True,
            figsize=(10,10),
        )
ax.imshow(np.flipud(sst.sst.values), cmap=cm.RdBu_r,  vmin=12, vmax=24)
ax.imshow(np.flipud(u.u_surf.values), alpha=0.3, cmap=cm.gray, vmin=-.3, vmax=0.3)
ax.axis('off');
### plt.savefig('./out_figure.png', dpi=300)

###Plot the figure with V shading

fig, ax = plt.subplots(
            1,
            1,
            constrained_layout=True,
            figsize=(10,10),
        )
ax.imshow(np.flipud(sst.sst.values), cmap=cm.RdBu_r,  vmin=12, vmax=24)
ax.imshow(np.flipud(v.v_surf.values), alpha=0.3, cmap=cm.gray, vmin=-.3, vmax=0.3)
ax.axis('off');

###Rotate "light source" for U by 45 degrees
direct = np.rad2deg(np.arctan2(v.v_surf.values, u.u_surf.values))
speed_rot = np.hypot(u.u_surf.values, v.v_surf.values)

myangle = 45
U = speed_rot * np.cos(np.deg2rad(myangle - direct))
# V = speed_rot * np.sin(np.deg2rad(myangle - direct))
fig, ax = plt.subplots(
            1,
            1,
            constrained_layout=True,
            figsize=(10,10),
        )
ax.imshow(np.flipud(sst.sst.values), cmap=cm.RdBu_r,  vmin=12, vmax=24)
ax.imshow(np.flipud(U), alpha=0.3, cmap=cm.gray, vmin=-.3, vmax=0.3)
ax.axis('off');

测试图:

把高分辨率的图拼起来,帧数至少得30 FPS看起来视频就很丝滑了!

下面这些思路相近,但确实高端大气的一些视频还是少不了商业软件渲染的加持的,甚至是CG技术的应用。

声明:欢迎转载、转发本号原创内容,可留言区留言或者后台联系小编(gavin7675)进行授权。气象学家公众号转载信息旨在传播交流,其内容由作者负责,不代表本号观点。文中部分图片来源于网络,如涉及作品内容、版权和其他问题,请后台联系小编处理。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2021-11-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 气象学家 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • FESOM2 SST shaded by U component of velocity
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档