收藏本站 劰载中...网站公告 | 吾爱海洋论坛交流QQ群:835383472

[Python] Python+Matplotlib制作超高分辨率动态气象/海洋要素可视化动图

[复制链接]

6cc92c98be4616b53f7d5c94bbe9887f.gif

2d7e4e96fca02e32c657bfffecc9b48f.png Animated version of Gulf Stream sea surface temperatures done with

@oceanographer from yesterday - inspired by the moving media #artinstallations @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 modelsimulations with 1km resolutionin Gulf Stream area. Data areinterpolated to regular 1/100 degree grid.

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

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

游客,如果您要查看本帖隐藏内容请回复

代码:


/ I- C7 }; V! x5 |: j/ H# O2 ^! D

[Python] 纯文本查看 复制代码
importxarray asxr
importnumpy asnp
importmatplotlib.pylab asplt
importmatplotlib.cm ascm
###Download data:
#wget [url]https://zenodo.org/record/4759091/files/GF_FESOM2_testdata.tar.gz[/url]
###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');


, C" e% Y+ W3 U

测试图:

2bf1065711ad414fdf3c7dd493e37bda.png

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

8 A* X  Q2 @  z

9 {/ b% E3 F5 v& K! ]# l  `4 o6 l! q" `$ d, P% v# j# E+ _
6 v% O. @# R! K7 a% R

  I2 ~2 @8 T$ H) ]* p
                               
登录/注册后可看大图

$ N8 [& }8 c% ~! g! V# d; n" B
                               
登录/注册后可看大图


7 J4 s$ d; r  N9 `2 p" ^                               
登录/注册后可看大图


9 g) I0 J; [1 C# p- r" q# q) b% O
6337ef653810cc6d728718b0ea9cf975.gif
c98d42538c362bdb40eaccba88f68bb4.gif
回复

举报 使用道具

相关帖子

全部回帖
暂无回帖,快来参与回复吧
懒得打字?点击右侧快捷回复 【吾爱海洋论坛发文有奖】
您需要登录后才可以回帖 登录 | 立即注册
leejiafu
活跃在2026-2-10
快速回复 返回顶部 返回列表