def calc_env(index, shellindex, edgeindex, MC):
    if len(shellindex) > 0:
        K_J_I = index_to_zyx(shellindex, MC)

        n = 6
        for i in range(n):
            # Find all the points just outside the clouds
            stacklist = [K_J_I, ]
            for item in ((0, -1, 0), (0, 1, 0),
                         (0, 0, -1), (0, 0, 1)):
                stacklist.append( K_J_I + numpy.array(item)[:, numpy.newaxis] )

            maskindex = numpy.hstack(stacklist)
            maskindex[1, :] = maskindex[1, :] % MC['ny']
            maskindex[2, :] = maskindex[2, :] % MC['nx']            
            maskindex = numpy.unique( zyx_to_index(maskindex[0, :],
                                                   maskindex[1, :],
                                                   maskindex[2, :],
                                                   MC) )

            # From the expanded mask, select the points outside the cloud
            envindex = numpy.setdiff1d(maskindex, index, assume_unique = True)

            K_J_I = index_to_zyx(envindex, MC)
            
        # Select the points within 4 grid cells of cloud
        r = calc_radii(envindex, edgeindex, MC)
        mask = r < 4.5
        envindex = envindex[mask]
    else:
        envindex = []

    return envindex
Exemple #2
0
def calc_env(index, shellindex, edgeindex, MC):
    if len(shellindex) > 0:
        K_J_I = index_to_zyx(shellindex, MC)

        n = 6
        for i in range(n):
            # Find all the points just outside the clouds
            stacklist = [
                K_J_I,
            ]
            for item in ((0, -1, 0), (0, 1, 0), (0, 0, -1), (0, 0, 1)):
                stacklist.append(K_J_I + numpy.array(item)[:, numpy.newaxis])

            maskindex = numpy.hstack(stacklist)
            maskindex[1, :] = maskindex[1, :] % MC['ny']
            maskindex[2, :] = maskindex[2, :] % MC['nx']
            maskindex = numpy.unique(
                zyx_to_index(maskindex[0, :], maskindex[1, :], maskindex[2, :],
                             MC))

            # From the expanded mask, select the points outside the cloud
            envindex = numpy.setdiff1d(maskindex, index, assume_unique=True)

            K_J_I = index_to_zyx(envindex, MC)

        # Select the points within 4 grid cells of cloud
        r = calc_radii(envindex, edgeindex, MC)
        mask = r < 4.5
        envindex = envindex[mask]
    else:
        envindex = []

    return envindex
Exemple #3
0
def advect_indexes(indexes, u, v, w, MC):
    K_J_I = index_to_zyx(indexes, MC)
    K_J_I[0, :] = K_J_I[0, :] - w
    K_J_I[1, :] = K_J_I[1, :] - v
    K_J_I[2, :] = K_J_I[2, :] - u

    K_J_I[0, K_J_I[0, :] >= MC['nz']] = MC['nz'] - 1
    K_J_I[0, K_J_I[0, :] < 0] = 0
    K_J_I[1, :] = K_J_I[1, :] % MC['ny']
    K_J_I[2, :] = K_J_I[2, :] % MC['nx']

    advected_indexes = zyx_to_index(K_J_I[0, :], K_J_I[1, :], K_J_I[2, :], MC)

    return advected_indexes
def advect_indexes(indexes, u, v, w, MC):
    K_J_I = index_to_zyx(indexes, MC)
    K_J_I[0, :] = K_J_I[0, :] - w
    K_J_I[1, :] = K_J_I[1, :] - v
    K_J_I[2, :] = K_J_I[2, :] - u
                               
    K_J_I[0, K_J_I[0, :] >= MC['nz']] = MC['nz']-1
    K_J_I[0, K_J_I[0, :] < 0] = 0
    K_J_I[1, :] = K_J_I[1, :] % MC['ny']
    K_J_I[2, :] = K_J_I[2, :] % MC['nx']

    advected_indexes = zyx_to_index(K_J_I[0,:], K_J_I[1,:], K_J_I[2,:], MC)
    
    return advected_indexes