iris中的控制Vmin和Vmax是动画;

发布于 2025-01-31 18:37:31 字数 536 浏览 3 评论 0 原文

有人知道如何(如果?)我可以使用 iris.experiment。 ?

wind = iris.load_cube('/my/pp/file')
cube_iter = wind.slices(('longitude', 'latitude'))
ani = animate(cube_iter, qplt.contourf,vmin=0,vmax=20)
plt.show()

我正在使用IRIS 2.4.0版。

在此代码中,动画有效,但VMAX被忽略(请参阅附件屏幕截图)。

有人知道如何解决这个问题吗?

谢谢!

Does anyone know how (if?) I can control the vmin and vmax of an Iris quickplot pcolormesh animation using iris.experimental.animate.animate?

wind = iris.load_cube('/my/pp/file')
cube_iter = wind.slices(('longitude', 'latitude'))
ani = animate(cube_iter, qplt.contourf,vmin=0,vmax=20)
plt.show()

I'm using Iris version 2.4.0.

In this code, the animation works, but vmax is ignored (see attached screenshot).

Does anyone know how to fix this?

Thanks!

Image illustrating that vmax is not being obeyed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光病人 2025-02-07 18:37:31

这有点像软糖,但是我们可以使用 functools.spartial 函数要修复 calle Extend 关键字。

import functools

import iris
from iris.experimental.animate import animate
import iris.quickplot as qplt
import matplotlib.pyplot as plt

my_contourf = functools.partial(qplt.contourf, levels=range(260, 291, 5),
                                extend="both")
# Function defined by partial has no __module__ or __name__ attribute, so add
# them to get past iris animate's checks.
my_contourf.__module__ = "iris.quickplot"
my_contourf.__name__ = "contourf"

fname = iris.sample_data_path("E1_north_america.nc")
cube = iris.load_cube(fname)[:20]

cube_iter = cube.slices(('longitude', 'latitude'))
ani = animate(cube_iter, my_contourf, vmin=260, vmax=290)
ani.save("abc.gif")

This is a bit of a fudge, but we can produce a more sensible animation by using the functools.partial function to fix the levels and extend keyword.

import functools

import iris
from iris.experimental.animate import animate
import iris.quickplot as qplt
import matplotlib.pyplot as plt

my_contourf = functools.partial(qplt.contourf, levels=range(260, 291, 5),
                                extend="both")
# Function defined by partial has no __module__ or __name__ attribute, so add
# them to get past iris animate's checks.
my_contourf.__module__ = "iris.quickplot"
my_contourf.__name__ = "contourf"

fname = iris.sample_data_path("E1_north_america.nc")
cube = iris.load_cube(fname)[:20]

cube_iter = cube.slices(('longitude', 'latitude'))
ani = animate(cube_iter, my_contourf, vmin=260, vmax=290)
ani.save("abc.gif")

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文