Ejemplo n.º 1
0
def _filter_insects(bits: list) -> list:
    is_melting_layer = bits[3]
    is_insects = bits[5]
    is_falling = bits[1]

    # Remove above melting layer
    above_melting = utils.ffill(is_melting_layer)
    ind = np.where(is_insects & above_melting)
    is_falling[ind] = True
    is_insects[ind] = False

    # remove around melting layer:
    original_insects = np.copy(is_insects)
    n_gates = 5
    for x, y in zip(*np.where(is_melting_layer)):
        try:
            # change insects to drizzle below melting layer pixel
            ind1 = np.arange(y - n_gates, y)
            ind11 = np.where(original_insects[x, ind1])[0]
            n_drizzle = sum(is_falling[x, :y])
            if n_drizzle > 5:
                is_falling[x, ind1[ind11]] = True
                is_insects[x, ind1[ind11]] = False
            else:
                continue
            # change insects on the right and left of melting layer pixel to drizzle
            ind1 = np.arange(x - n_gates, x + n_gates + 1)
            ind11 = np.where(original_insects[ind1, y])[0]
            is_falling[ind1[ind11], y - 1 : y + 2] = True
            is_insects[ind1[ind11], y - 1 : y + 2] = False
        except IndexError:
            continue
    bits[1] = is_falling
    bits[5] = is_insects
    return bits
Ejemplo n.º 2
0
def _find_cold_aerosols(obs: ClassData, is_liquid: np.ndarray) -> np.ndarray:
    """Lidar signals which are in colder than the threshold temperature and
    have gap below in the profile are probably ice.
    """
    temperature_limit = T0 - 15
    is_beta = ~obs.beta.mask
    region = utils.ffill(is_beta, 1) == 0
    return is_beta & (obs.tw.data < temperature_limit) & ~is_liquid & region
Ejemplo n.º 3
0
def fill_clouds_with_lwc_dz(atmosphere: tuple, is_liquid: np.ndarray) -> np.ndarray:
    """Fills liquid clouds with lwc change rate at the cloud bases.

    Args:
        atmosphere: 2-element tuple containing temperature (K) and pressure (Pa).
        is_liquid: Boolean array indicating presence of liquid clouds.

    Returns:
        Liquid water content change rate (g/m3/m), so that for each cloud the base value
        is filled for the whole cloud.

    """
    lwc_dz = get_lwc_change_rate_at_bases(atmosphere, is_liquid)
    lwc_dz_filled = ma.zeros(lwc_dz.shape)
    lwc_dz_filled[is_liquid] = utils.ffill(lwc_dz[is_liquid])
    return lwc_dz_filled
Ejemplo n.º 4
0
def test_ffill_2():
    x = np.array([[5, 1, 1, 6], [3, 0, 1, 0]])
    result = np.array([[5, 5, 5, 6], [3, 0, 0, 0]])
    assert_array_almost_equal(utils.ffill(x, value=1), result)
Ejemplo n.º 5
0
def test_ffill(input, result):
    assert_array_almost_equal(utils.ffill(input), result)
Ejemplo n.º 6
0
 def _screen_above_liquid():
     above_liquid = utils.ffill(liquid_layers)
     prob[(above_liquid == 1) & (insect_prob_no_ldr > 0)] = 0
Ejemplo n.º 7
0
 def _screen_above_melting():
     above_melting = utils.ffill(melting_layer)
     prob[above_melting == 1] = 0