Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CubeCombiner #1383

Merged
merged 10 commits into from
Dec 16, 2020
19 changes: 11 additions & 8 deletions improver/cli/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,22 @@ def process(
result (iris.cube.Cube):
Returns a cube with the combined data.
"""
from improver.cube_combiner import CubeCombiner
from improver.cube_combiner import CubeCombiner, CubeMultiplier
from iris.cube import CubeList

if not cubes:
raise TypeError("A cube is needed to be combined.")
if new_name is None:
new_name = cubes[0].name()
broadcast_to_coords = ["threshold"] if broadcast_to_threshold else None
result = CubeCombiner(operation, warnings_on=check_metadata)(
CubeList(cubes),
new_name,
broadcast_to_coords=broadcast_to_coords,
use_midpoint=use_midpoint,
)

if operation == "*" or operation == "multiply":
result = CubeMultiplier()(
CubeList(cubes), new_name, broadcast_to_threshold=broadcast_to_threshold,
)

else:
result = CubeCombiner(operation)(
CubeList(cubes), new_name, use_midpoint=use_midpoint,
)

return result
Loading