def __init__(self, input_cube, vel_x, vel_y, orographic_enhancement_cube=None, attributes_dict=None): """ Initialises the object. This includes checking if orographic enhancement is provided and removing the orographic enhancement from the input file ready for extrapolation. An error is raised if the input cube is precipitation rate but no orographic enhancement cube is provided. Args: input_cube (iris.cube.Cube): A 2D cube containing data to be advected. vel_x (iris.cube.Cube): Cube containing a 2D array of velocities along the x coordinate axis vel_y (iris.cube.Cube): Cube containing a 2D array of velocities along the y coordinate axis orographic_enhancement_cube (iris.cube.Cube): Cube containing the orographic enhancement fields. May have data for multiple times in the cube. The orographic enhancement is removed from the input_cube before advecting, and added back on after advection. attributes_dict (dict): Dictionary containing information for amending the attributes of the output cube. """ if not (vel_x and vel_y): raise TypeError("Neither x velocity or y velocity can be None") self.orographic_enhancement_cube = orographic_enhancement_cube if self.orographic_enhancement_cube: input_cube, = ApplyOrographicEnhancement("subtract")( input_cube, self.orographic_enhancement_cube) elif ("precipitation_rate" in input_cube.name() or "rainfall_rate" in input_cube.name()): msg = ("For precipitation or rainfall fields, orographic " "enhancement cube must be supplied.") raise ValueError(msg) self.input_cube = input_cube self.advection_plugin = AdvectField(vel_x, vel_y, attributes_dict=attributes_dict)
def __init__(self, input_cube, vel_x, vel_y, orographic_enhancement_cube=None, metadata_dict=None): """ Initialises the object. This includes checking if orographic enhancement is provided and removing the orographic enhancement from the input file ready for extrapolation. An error is raised if the input cube is precipitation rate but no orographic enhancement cube is provided. Args: input_cube (iris.cube.Cube): A 2D cube containing data to be advected. vel_x (iris.cube.Cube): Cube containing a 2D array of velocities along the x coordinate axis vel_y (iris.cube.Cube): Cube containing a 2D array of velocities along the y coordinate axis Keyword Args: orographic_enhancement_cube (iris.cube.Cube): Cube containing the orographic enhancement fields. May have data for multiple times in the cube. The orographic enhancement is removed from the input_cube before advecting, and added back on after advection. metadata_dict (dict): Dictionary containing information for amending the metadata of the output cube. Please see the :func:`improver.utilities.cube_metadata.amend_metadata` for information regarding the allowed contents of the metadata dictionary. """ self.orographic_enhancement_cube = orographic_enhancement_cube if self.orographic_enhancement_cube: input_cube, = ApplyOrographicEnhancement("subtract").process( input_cube, self.orographic_enhancement_cube) elif "precipitation_rate" in input_cube.name(): msg = ("For precipitation fields, orographic enhancement " "cube must be supplied.") raise ValueError(msg) self.input_cube = input_cube self.advection_plugin = AdvectField(vel_x, vel_y, metadata_dict=metadata_dict)