是否可以基于cell_methods创建虹膜约束?

时间:2017-07-18 13:59:58

标签: python-iris

这刚刚出现,我有一个答案,但我想在这里分享......

"是否可以根据cell_methods创建虹膜约束?"

我有一个数据文件加载生成许多立方体 我想只提取那些包含整体传播的东西,我可以从他们的cell_methods中识别出来,这些东西设置为:
(CellMethod(method=u'standard_deviation', coord_names=(u'realization',), intervals=(), comments=()),)

有没有办法过滤负载,以便我只读取所需的"整体传播"数据?

1 个答案:

答案 0 :(得分:3)

你需要使用" cube_func"解决这个问题。
http://scitools.org.uk/iris/docs/latest/iris/iris.html?highlight=constraint#iris.Constraint

所以,非常类似......

def cube_is_mean(cube):
   return any(cm.method == 'mean' for cm in cube.cell_methods)

means_constraint = iris.Constraint(cube_func=cube_is_mean)