esmvaltool/preprocessor/_derive.py
def _create_pressure_array(tro3_cube, ps_cube, top_limit):
    """Create an array filled with the 'air_pressure' coord values.

    The array is created from the tro3_cube with the same dimensions
    as tro3_cube. This array is then sandwiched with a 2D array containing
    the surface pressure, and a 2D array containing the top pressure limit.

    @R. Checa-Garcia: top_limit can be other cube and we could use
    this function to calculate also tropospheric ozone column as the top
    limit could be defined as an analogous of surface pressure.
    """
    # create 4D array filled with pressure level values
    p_levels = tro3_cube.coord('air_pressure').points
    p_4d_array = iris.util.broadcast_to_shape(p_levels, tro3_cube.shape, [1])
    assert p_4d_array.shape == tro3_cube.shape

    # create 4d array filled with surface pressure values
    shape = tro3_cube.shape
    ps_4d_array = iris.util.broadcast_to_shape(ps_cube.data, shape, [0, 2, 3])
    assert ps_4d_array.shape == tro3_cube.shape

    # set pressure levels below the surface pressure to NaN
    pressure_4d = np.where((ps_4d_array - p_4d_array) < 0, np.NaN, p_4d_array)

    # make top_limit last pressure level
    # formally using broadcasing top_limit might be a cube like ps_cube?
    top_limit_array = np.ones(ps_cube.shape) * top_limit
    data = top_limit_array[:, np.newaxis, :, :]
    pressure_4d = np.concatenate((pressure_4d, data), axis=1)
    assert (pressure_4d[:, -1, :, :] == top_limit).all()

    # make surface pressure the first pressure level
    data = ps_cube.data[:, np.newaxis, :, :]
    pressure_4d = np.concatenate((data, pressure_4d), axis=1)
    assert (pressure_4d[:, 0, :, :] == ps_cube.data).all()

    return pressure_4d
Create an array filled with the 'air_pressure' coord values.

    The array is created from the tro3_cube with the same dimensions
    as tro3_cube. This array is then sandwiched with a 2D array containing
    the surface pressure, and a 2D array containing the top pressure limit.

    @R. Checa-Garcia: top_limit can be other cube and we could use
    this function to calculate also tropospheric ozone column as the top
    limit could be defined as an analogous of surface pressure.
    
Create an array filled with the 'air_pressure' coord values.
The array is created from the tro3_cube with the same dimensions
as tro3_cube. This array is then sandwiched with a 2D array containing
the surface pressure, and a 2D array containing the top pressure limit.
Create an array filled with the ' air_pressure ' coord values . The array is created from the tro3_cube with the same dimensions as tro3_cube . This array is then sandwiched with a 2D array containing the surface pressure and a 2D array containing the top pressure limit .
def _create_pressure_array(tro3_cube, ps_cube, top_limit):
    p_levels = tro3_cube.coord('air_pressure').points
    p_4d_array = iris.util.broadcast_to_shape(p_levels, tro3_cube.shape, [1])
    assert p_4d_array.shape == tro3_cube.shape
    shape = tro3_cube.shape
    ps_4d_array = iris.util.broadcast_to_shape(ps_cube.data, shape, [0, 2, 3])
    assert ps_4d_array.shape == tro3_cube.shape
    pressure_4d = np.where((ps_4d_array - p_4d_array) < 0, np.NaN, p_4d_array)
    top_limit_array = np.ones(ps_cube.shape) * top_limit
    data = top_limit_array[:, np.newaxis, :, :]
    pressure_4d = np.concatenate((pressure_4d, data), axis=1)
    assert (pressure_4d[:, -1, :, :] == top_limit).all()
    data = ps_cube.data[:, np.newaxis, :, :]
    pressure_4d = np.concatenate((data, pressure_4d), axis=1)
    assert (pressure_4d[:, 0, :, :] == ps_cube.data).all()
    return pressure_4d
def _create_pressure_array ( tro3_cube , ps_cube , top_limit ) : p_levels = tro3_cube . coord ( 'air_pressure' ) . points p_4d_array = iris . util . broadcast_to_shape ( p_levels , tro3_cube . shape , [ 1 ] ) assert p_4d_array . shape == tro3_cube . shape shape = tro3_cube . shape ps_4d_array = iris . util . broadcast_to_shape ( ps_cube . data , shape , [ 0 , 2 , 3 ] ) assert ps_4d_array . shape == tro3_cube . shape pressure_4d = np . where ( ( ps_4d_array - p_4d_array ) < 0 , np . NaN , p_4d_array ) top_limit_array = np . ones ( ps_cube . shape ) * top_limit data = top_limit_array [ : , np . newaxis , : , : ] pressure_4d = np . concatenate ( ( pressure_4d , data ) , axis = 1 ) assert ( pressure_4d [ : , - 1 , : , : ] == top_limit ) . all ( ) data = ps_cube . data [ : , np . newaxis , : , : ] pressure_4d = np . concatenate ( ( data , pressure_4d ) , axis = 1 ) assert ( pressure_4d [ : , 0 , : , : ] == ps_cube . data ) . all ( ) return pressure_4d
Create an array filled with the 'air_pressure' coord values.
Create an array filled with the ' air_pressure ' coord values .
"""Create an array filled with the 'air_pressure' coord values.

    The array is created from the tro3_cube with the same dimensions
    as tro3_cube. This array is then sandwiched with a 2D array containing
    the surface pressure, and a 2D array containing the top pressure limit.

    @R. Checa-Garcia: top_limit can be other cube and we could use
    this function to calculate also tropospheric ozone column as the top
    limit could be defined as an analogous of surface pressure.
    """ # create 4D array filled with pressure level values # create 4d array filled with surface pressure values # set pressure levels below the surface pressure to NaN # make top_limit last pressure level # formally using broadcasing top_limit might be a cube like ps_cube? # make surface pressure the first pressure level
tro3_cube
ps_cube
top_limit
Garcia
top_limit can be other cube and we could use
this function to calculate also tropospheric ozone column as the top
limit could be defined as an analogous of surface pressure.
top_limit can be other cube and we could use this function to calculate also tropospheric ozone column as the top limit could be defined as an analogous of surface pressure .