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[:]))
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
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
def test_db2lin(input, result): assert utils.db2lin(*input) == result
def db2lin(self) -> None: """Converts log units to linear.""" if "db" in self.units.lower(): self.data = utils.db2lin(self.data) self.units = ""
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[:]))
def _convert_z_units(self): """Converts reflectivity factor to SI units.""" z = self.getvar('Z') - 180 return utils.db2lin(z)
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)
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)
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
def test_db2lin(data, result): assert utils.db2lin(*data) == result
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[:]))
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)