Пример #1
0
def test_find_liquid():
    class Obs:
        def __init__(self):
            self.height = np.arange(6) * 100
            self.time = np.arange(3)
            self.lwp = ma.array(range(3))
            self.beta = ma.array([[1e-8, 1e-8, 2e-6, 1e-3, 5e-6, 1e-8],
                                  [1e-8, 1e-8, 1e-5, 1e-3, 1e-5, 1e-8],
                                  [1e-8, 1e-8, 1e-5, 1e-3, 1e-5, 1e-8]],
                                 mask=[[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0],
                                       [0, 0, 0, 0, 0, 0]])

    bases = np.array([[0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0],
                      [0, 0, 1, 0, 0, 0]])

    tops = np.array([[0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 1, 0],
                     [0, 0, 0, 0, 1, 0]])

    is_liquid = np.array([[0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0],
                          [0, 0, 1, 1, 1, 0]])

    obs = Obs()
    result = droplet.find_liquid(obs)
    assert_array_equal(bases, result['bases'])
    assert_array_equal(tops, result['tops'])
    assert_array_equal(is_liquid, result['presence'])
Пример #2
0
def classify_measurements(data: dict) -> ClassificationResult:
    """Classifies radar/lidar observations.

    This function classifies atmospheric scatterers from the input data.
    The input data needs to be averaged or interpolated to the common
    time / height grid before calling this function.

    Args:
        data: Containing :class:`Radar`, :class:`Lidar`, :class:`Model` and :class:`Mwr` instances.

    Returns:
        A :class:`ClassificationResult` instance.

    References:
        The Cloudnet classification scheme is based on methodology proposed by
        Hogan R. and O'Connor E., 2004, https://bit.ly/2Yjz9DZ and its
        proprietary Matlab implementation.

    Notes:
        Some of the individual classification methods are changed in this Python
        implementation compared to the original Cloudnet methodology.
        Especially methods classifying insects, melting layer and liquid droplets.

    """
    obs = ClassData(data)
    bits: List[np.ndarray] = [np.array([])] * 6
    liquid = droplet.find_liquid(obs)
    bits[3] = melting.find_melting_layer(obs)
    bits[2] = freezing.find_freezing_region(obs, bits[3])
    bits[0] = droplet.correct_liquid_top(obs, liquid, bits[2], limit=500)
    bits[5] = insects.find_insects(obs, bits[3], bits[0])
    bits[1] = falling.find_falling_hydrometeors(obs, bits[0], bits[5])
    bits, filtered_ice = _filter_falling(bits)
    for _ in range(5):
        bits[3] = _fix_undetected_melting_layer(bits)
        bits = _filter_insects(bits)
    bits[4] = _find_aerosols(obs, bits[1], bits[0])
    bits[4][filtered_ice] = False
    return ClassificationResult(
        _bits_to_integer(bits), obs.is_rain, obs.is_clutter, liquid["bases"], obs.rain_rate
    )