Exercise 3:
iris.Constraint
cube_func keyword, and load the file in iris.sample_data_path('A1B_north_america.nc')
such that only cubes with cell methods are loaded (note: in this case, that is all that exists in the file).
In [1]:
def has_cell_methods(cube):
if cube.cell_methods is not None:
return True
return False
In [2]:
import iris
fname = iris.sample_data_path('A1B_north_america.nc')
cubes = iris.load(fname, iris.Constraint(cube_func=has_cell_methods))
print(cubes)