Exemplo n.º 1
0
def test_append_iwc(iwc_source_file, iwc_cat_file):
    from cloudnetpy.products.iwc import _append_iwc
    ice_class = _IceClassification(iwc_cat_file)
    ice_class.ice_above_rain = np.array([0, 0, 1])
    ice_data = IwcSource(iwc_source_file)
    ice_data.data['iwc_inc_rain'] = [1, 1, 1]
    _append_iwc(ice_data, ice_class)
    assert 'iwc' in ice_data.data.keys()
Exemplo n.º 2
0
def test_append_iwc_indices(iwc_source_file, iwc_cat_file):
    from cloudnetpy.products.iwc import _append_iwc
    ice_class = _IceClassification(iwc_cat_file)
    ice_class.ice_above_rain = np.array([0, 0, 1])
    ice_data = IwcSource(iwc_source_file)
    ice_data.data['iwc_inc_rain'] = [1, 1, 1]
    _append_iwc(ice_data, ice_class)
    x = ice_data.data['iwc'][:]
    x = x.mask
    assert np.alltrue(x[:2])
Exemplo n.º 3
0
def test_append_iwc_status(iwc_source_file, value):
    from cloudnetpy.products.iwc import _append_iwc_status
    ice_class = IceClass()
    ice_data = IwcSource(iwc_source_file)
    ice_data.data['iwc'] = np.ma.array([[1, 1, 1, 1, 1, 1],
                                        [1, 1, 1, 1, 1, 1]],
                                       mask=[[True, True, False, False, False, False],
                                             [True, True, True, False, False, False]])
    _append_iwc_status(ice_data, ice_class)
    assert value in ice_data.data['iwc_retrieval_status'][:]
Exemplo n.º 4
0
def test_append_iwc_status(categorize_file):
    iwc_source = IwcSource(categorize_file)
    ice_class = IceClassification(categorize_file)
    iwc_source.data['iwc'] = ma.array([[1, 1], [1, 1], [1, 1]],
                                      dtype=float,
                                      mask=[[1, 0], [0, 0], [0, 0]])
    ice_class.is_ice = np.array([[1, 0], [0, 0], [0, 0]], dtype=bool)
    ice_class.corrected_ice = np.array([[0, 0], [1, 0], [0, 1]], dtype=bool)
    ice_class.uncorrected_ice = np.array([[0, 0], [0, 1], [1, 0]], dtype=bool)
    ice_class.cold_above_rain = np.array([[0, 0], [0, 0], [1, 0]], dtype=bool)
    ice_class.ice_above_rain = np.array([[0, 0], [0, 0], [0, 1]], dtype=bool)
    ice_class.would_be_ice = np.array([[0, 0], [0, 0], [0, 0]], dtype=bool)
    iwc_source.append_status(ice_class)
    for value in range(1, 7):
        assert value in iwc_source.data['iwc_retrieval_status'][:]
Exemplo n.º 5
0
def test_append_iwc_including_rain(iwc_source_file, iwc_cat_file):
    from cloudnetpy.products.iwc import _append_iwc_including_rain
    ice_class = _IceClassification(iwc_cat_file)
    ice_class.is_ice = np.array([0, 0, 1])
    ice_data = IwcSource(iwc_source_file)
    _append_iwc_including_rain(ice_data, ice_class)
    assert 'iwc_inc_rain' in ice_data.data.keys()
Exemplo n.º 6
0
def test_iwc_error(iwc_source_file, iwc_cat_file):
    from cloudnetpy.products.iwc import _append_iwc_error
    ice_data = IwcSource(iwc_source_file)
    ice_class = _IceClassification(iwc_cat_file)
    ice_class.uncorrected_ice = np.array([1, 0, 1])
    ice_class.is_ice = np.array([0, 0, 1])
    ice_class.ice_above_rain = np.array([1, 1, 0])
    _append_iwc_error(ice_data, ice_class)
    assert 'iwc_error' in ice_data.data.keys()
Exemplo n.º 7
0
def test_append_iwc_including_rain_indices(iwc_source_file, iwc_cat_file):
    from cloudnetpy.products.iwc import _append_iwc_including_rain
    ice_class = _IceClassification(iwc_cat_file)
    ice_class.is_ice = np.array([0, 0, 1])
    ice_data = IwcSource(iwc_source_file)
    _append_iwc_including_rain(ice_data, ice_class)
    x = ice_data.data['iwc_inc_rain'][:]
    x = x.mask
    assert np.alltrue(x[1:])
Exemplo n.º 8
0
class TestAppending:
    @pytest.fixture(autouse=True)
    def run_before_tests(self, categorize_file):
        self.ice_class = IceClassification(categorize_file)
        self.iwc_source = IwcSource(categorize_file)

    def test_append_iwc_including_rain(self):
        self.ice_class.is_ice = np.array([[0, 1], [1, 1], [0, 0]], dtype=bool)
        self.iwc_source.append_iwc_including_rain(self.ice_class)
        expected_mask = [[1, 0], [0, 0], [1, 1]]
        assert_array_equal(self.iwc_source.data['iwc_inc_rain'][:].mask,
                           expected_mask)

    def test_append_iwc(self):
        self.ice_class.ice_above_rain = np.array([0, 0, 0, 1, 1], dtype=bool)
        self.iwc_source.data['iwc_inc_rain'] = ma.array([1, 2, 3, 4, 5],
                                                        mask=[1, 0, 1, 0, 1])
        self.iwc_source.append_iwc(self.ice_class)
        expected_mask = [1, 0, 1, 1, 1]
        assert_array_equal(self.iwc_source.data['iwc'][:].mask, expected_mask)

    def test_iwc_error(self):
        self.ice_class.is_ice = np.array([[0, 0], [0, 1], [1, 1]], dtype=bool)
        self.ice_class.ice_above_rain = np.array([[1, 0], [1, 0], [1, 0]],
                                                 dtype=bool)
        self.iwc_source.append_error(self.ice_class)
        expected_mask = [[1, 1], [1, 0], [1, 0]]
        assert_array_equal(self.iwc_source.data['iwc_error'][:].mask,
                           expected_mask)

    def test_append_sensitivity(self):
        self.iwc_source.append_sensitivity()
        assert self.iwc_source.data['iwc_sensitivity'][:].shape == (2, )

    def test_append_bias(self):
        self.iwc_source.append_bias()
        assert isinstance(self.iwc_source.data['iwc_bias'].data[()], float)
Exemplo n.º 9
0
def test_iwc_spec_liq_atten(iwc_source_file):
    obj = IwcSource(iwc_source_file)
    compare = 1
    assert compare == obj.spec_liq_atten
Exemplo n.º 10
0
def test_iwc_wl_band(iwc_source_file):
    obj = IwcSource(iwc_source_file)
    compare = 0
    assert compare == obj.wl_band
Exemplo n.º 11
0
def test_append_bias(iwc_source_file):
    from cloudnetpy.products.iwc import _append_iwc_bias
    ice_data = IwcSource(iwc_source_file)
    _append_iwc_bias(ice_data)
    assert 'iwc_bias' in ice_data.data.keys()
Exemplo n.º 12
0
def test_append_sensitivity(iwc_source_file):
    from cloudnetpy.products.iwc import _append_iwc_sensitivity
    ice_data = IwcSource(iwc_source_file)
    ice_data.mean_temperature = np.array([1.5])
    _append_iwc_sensitivity(ice_data)
    assert 'iwc_sensitivity' in ice_data.data.keys()
Exemplo n.º 13
0
def test_iwc_temperature(iwc_source_file):
    obj = IwcSource(iwc_source_file)
    compare = np.array([[8.85, 6.85, 4.85],
                       [12.85, 10.85, 8.85],
                       [10.85, 8.85, 6.85]])
    testing.assert_almost_equal(compare, obj.temperature)
Exemplo n.º 14
0
def test_iwc_temperature(categorize_file):
    obj = IwcSource(categorize_file)
    expected = [[6.85, 16.85], [6.85, 16.85], [6.85, 16.85]]
    testing.assert_almost_equal(obj.temperature, expected)
Exemplo n.º 15
0
def test_iwc_coeffs(result, categorize_file):
    obj = IwcSource(categorize_file)
    assert result in obj.coeffs._fields
    assert obj.coeffs == (0.878, 0.000242, -0.0186, 0.0699, -1.63)
Exemplo n.º 16
0
def test_iwc_wl_band(categorize_file):
    obj = IwcSource(categorize_file)
    assert obj.wl_band == 0
Exemplo n.º 17
0
def test_iwc_z_factor(iwc_source_file):
    obj = IwcSource(iwc_source_file)
    Coefficients = namedtuple('Coefficients', 'K2liquid0')
    obj.coeffs = Coefficients(10)
    compare = -0.25
    assert compare == round(obj.z_factor, 3)
Exemplo n.º 18
0
def test_iwc_coeffs(result, iwc_source_file):
    obj = IwcSource(iwc_source_file)
    assert result in obj.coeffs._fields
Exemplo n.º 19
0
 def run_before_tests(self, categorize_file):
     self.ice_class = IceClassification(categorize_file)
     self.iwc_source = IwcSource(categorize_file)
Exemplo n.º 20
0
def test_iwc_mean_temperature(iwc_source_file):
    obj = IwcSource(iwc_source_file)
    compare = np.array([10.85, 8.85, 6.85])
    testing.assert_almost_equal(compare, obj.mean_temperature)
Exemplo n.º 21
0
def test_iwc_mean_temperature(iwc_source_file):
    # TODO: test with different model grid
    obj = IwcSource(iwc_source_file)
    compare = np.array([10.85, 8.85, 6.85])
    testing.assert_almost_equal(compare, obj.mean_temperature)