Ejemplo n.º 1
0
def mask_cube(cube_in, mask):
    ''' Mask cube where mask is larger than zero
    Input:
    cube_in:           iris.cube.Cube 
                       unmasked data cube
    mask:              numpy.ndarray or dask.array 
                       mask to use for masking, >0 where cube is supposed to be masked
    Output:
    cube_out:          iris.cube.Cube 
                       Masked cube
    '''
    from dask.array import ma
    from copy import deepcopy
    cube_out = deepcopy(cube_in)
    cube_out.data = ma.masked_where(mask != 0, cube_in.core_data())
    return cube_out
Ejemplo n.º 2
0
def mask_cube_untracked(variable_cube, mask):
    ''' Mask cube for untracked volume 
    Input:
    variable_cube:     iris.cube.Cube 
                       unmasked data cube
    mask:              iris.cube.Cube 
                       cube containing mask (int id for tacked volumes 0 everywhere else)
    Output:
    variable_cube_out: iris.cube.Cube 
                       Masked cube for untracked volume
    '''
    from dask.array import ma
    from copy import deepcopy
    variable_cube_out = deepcopy(variable_cube)
    variable_cube_out.data = ma.masked_where(mask.core_data() > 0,
                                             variable_cube_out.core_data())
    return variable_cube_out
Ejemplo n.º 3
0
def mask_cube_features(variable_cube, mask, feature_ids):
    ''' Mask cube for tracked volume of an individual cell   
    Input:
    variable_cube:     iris.cube.Cube 
                       unmasked data cube
    mask:              iris.cube.Cube 
                       cube containing mask (int id for tacked volumes 0 everywhere else)
    cell:          int
                       interger id of cell to create masked cube for
    Output:
    variable_cube_out: iris.cube.Cube 
                       Masked cube with data for respective cell
    '''
    from dask.array import ma, isin
    from copy import deepcopy
    variable_cube_out = deepcopy(variable_cube)
    variable_cube_out.data = ma.masked_where(
        ~isin(mask.core_data(), feature_ids), variable_cube_out.core_data())
    return variable_cube_out