2

This just came up, I have an answer but I wanted to share it here...

"Is it possible to create an iris constraint based on cell_methods?"

I have a datafile which loads producing many cubes.
I would like to extract only those containing ensemble spread, which I can identify from their cell_methods, which are set to:
(CellMethod(method=u'standard_deviation', coord_names=(u'realization',), intervals=(), comments=()),)

Is there a way to filter the load so that I only read in the desired "ensemble spread" data ?

pp-mo
  • 468
  • 2
  • 8

1 Answers1

3

You will need to use the "cube_func" approach for this.
http://scitools.org.uk/iris/docs/latest/iris/iris.html?highlight=constraint#iris.Constraint

So, something very roughly like ...

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)
pp-mo
  • 468
  • 2
  • 8