实用编程 | Python+Matplotlib制作超高分辨率动态气象/海洋要素可视化动图
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
代码:
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)进行授权。气象学家公众号转载信息旨在传播交流,其内容由作者负责,不代表本号观点。文中部分图片来源于网络,如涉及作品内容、版权和其他问题,请后台联系小编处理。
相关文章
- 使用Windows 11操作系统,遇到鼠标自动漂移怎么办?鼠标漂移解决方法
- 我希望在 GNOME 中看到的五个微小而有用的功能
- 使用Multipass编译OpenHarmony工程
- Linux硬盘分区 fdisk 和 parted命令详解
- Linus Torvalds 正式发布 Linux Kernel 5.16
- Linux Mint 与 Mozilla 建立合作伙伴关系,使用 Mozilla 版本的 Firefox
- 首发体验软通动力开箱即用的OpenHarmony开发环境
- Firefox仍是Linux Mint默认浏览器 但会移除大量定制功能
- 在 Linux 中以脚本模式运行 Top
- 硬件更改不用怕,这样重新激活Windows 10,仍然使用正版操作系统
- Windows 11的设备管理器开始默认不读取A:\软驱
- Windows 11优化设备管理器:更新驱动的默认路径终于不再是软驱A盘了
- 在 Linux 中像专业人士一样使用 GNOME 截图工具
- Fedora 36 将移除对 ifcfg 的支持
- 在浏览器中,把 Vite 跑起来了!
- Iot前端Node-Red+ IOT Studio + Github无法访问解决办法
- 惊喜:Windows 11 仍然支持运行 5.25 寸软盘
- Centos8中恢复根目录为默认权限
- Firefox 95 和 Chrome 97 在 Linux 的性能对比
- Maui Shell 来了,开启 Linux 桌面新时代!