示例#1
0
 def _calc_error():
     z_precision = 4.343 * (1 / np.sqrt(_number_of_pulses()) +
                            utils.db2lin(z_power_min - z_power) / 3)
     gas_error = attenuations['radar_gas_atten'] * 0.1
     liq_error = attenuations['liquid_atten_err'].filled(0)
     z_error = utils.l2norm(gas_error, liq_error, z_precision)
     z_error[attenuations['liquid_uncorrected']] = ma.masked
     return z_error
def test_db2lin(fake_nc_file):
    nc = netCDF4.Dataset(fake_nc_file)
    test_var = nc.variables['time']
    name, units = 'test_name', 'dB'
    obj = CloudnetArray(test_var, name, units)
    obj.db2lin()
    assert obj.units == ''
    assert_array_equal(obj.data, utils.db2lin(test_var[:]))
示例#3
0
 def _calc_error() -> np.ndarray:
     if 'width' not in self.data:
         return 0.3
     z_precision = 4.343 * (1 / np.sqrt(_number_of_independent_pulses())
                            + utils.db2lin(z_power_min - z_power) / 3)
     gas_error = attenuations['radar_gas_atten'] * 0.1
     liq_error = attenuations['liquid_atten_err'].filled(0)
     z_error = utils.l2norm(gas_error, liq_error, z_precision)
     z_error[attenuations['liquid_uncorrected']] = ma.masked
     return z_error
示例#4
0
 def _calc_error() -> Union[np.ndarray, float]:
     if "width" not in self.data:
         return 0.3
     z_precision = 4.343 * (
         1 / np.sqrt(_number_of_independent_pulses())
         + utils.db2lin(z_power_min - z_power) / 3
     )
     gas_error = attenuations["radar_gas_atten"] * 0.1
     liq_error = attenuations["liquid_atten_err"].filled(0)
     z_error = utils.l2norm(gas_error, liq_error, z_precision)
     z_error[attenuations["liquid_uncorrected"]] = ma.masked
     return z_error
示例#5
0
def test_db2lin(input, result):
    assert utils.db2lin(*input) == result
示例#6
0
 def db2lin(self) -> None:
     """Converts log units to linear."""
     if "db" in self.units.lower():
         self.data = utils.db2lin(self.data)
         self.units = ""
示例#7
0
 def test_db2lin(self):
     name, units = "test_name", "dB"
     obj = CloudnetArray(self.time, name, units)
     obj.db2lin()
     assert obj.units == ""
     assert_array_equal(obj.data, utils.db2lin(self.time[:]))
示例#8
0
 def _convert_z_units(self):
     """Converts reflectivity factor to SI units."""
     z = self.getvar('Z') - 180
     return utils.db2lin(z)
示例#9
0
def test_convert_z_units(drizzle_source_file):
    obj = drizzle.DrizzleSource(drizzle_source_file)
    z = obj.getvar("Z") - 180
    expected = utils.db2lin(z)
    testing.assert_array_almost_equal(obj._convert_z_units(), expected)
示例#10
0
def test_convert_z_units(drizzle_source_file):
    obj = drizzle.DrizzleSource(drizzle_source_file)
    z = obj.getvar('Z') - 180
    compare = utils.db2lin(z)
    testing.assert_array_almost_equal(obj._convert_z_units(), compare)
示例#11
0
def test_db2lin_arrays(data, expected):
    converted = utils.db2lin(data)
    assert_array_equal(converted, expected)
    if ma.isMaskedArray(data):
        assert_array_equal(converted.mask, expected.mask)  # pylint: disable=E1101
示例#12
0
def test_db2lin(data, result):
    assert utils.db2lin(*data) == result
示例#13
0
 def test_db2lin(self):
     name, units = 'test_name', 'dB'
     obj = CloudnetArray(self.time, name, units)
     obj.db2lin()
     assert obj.units == ''
     assert_array_equal(obj.data, utils.db2lin(self.time[:]))
示例#14
0
def test_db2lin_arrays(input, expected):
    converted = utils.db2lin(input)
    assert_array_equal(converted, expected)
    if ma.isMaskedArray(input):
        assert_array_equal(converted.mask, expected.mask)