def test_init_from_attenuation_VF_units(self): """ Test the attenuation unit conversions in the Coaxial classmethod `from_attenuation_VF_units`. """ # create a dummy Coaxial media for various attenuation and test the # resulting alpha values (real part of gamma) frequency = rf.Frequency(npy.random.rand(), unit='GHz', npoints=1) _att = npy.random.rand() # dB/m coax = Coaxial.from_attenuation_VF(frequency=frequency, VF=1, att=_att, unit='dB/m') assert_almost_equal(coax.gamma.real, rf.db_2_np(_att)) # dB/100m coax = Coaxial.from_attenuation_VF(frequency=frequency, VF=1, att=_att, unit='dB/100m') assert_almost_equal(coax.gamma.real, rf.db_2_np(_att) / 100) # dB/feet coax = Coaxial.from_attenuation_VF(frequency=frequency, VF=1, att=_att, unit='dB/feet') assert_almost_equal(coax.gamma.real, rf.db_2_np(_att) * rf.meter_2_feet()) # dB/100m coax = Coaxial.from_attenuation_VF(frequency=frequency, VF=1, att=_att, unit='dB/100feet') assert_almost_equal(coax.gamma.real, rf.db_2_np(_att) / 100 * rf.meter_2_feet()) # Neper/m coax = Coaxial.from_attenuation_VF(frequency=frequency, VF=1, att=_att, unit='Np/m') assert_almost_equal(coax.gamma.real, _att) # Neper/feet coax = Coaxial.from_attenuation_VF(frequency=frequency, VF=1, att=_att, unit='Np/feet') assert_almost_equal(coax.gamma.real, _att * rf.meter_2_feet())
def test_db_per_100feet_2_db_per_100meter(self): """ Test attenuation unit conversion dB/100feet to dB/100m """ assert_almost_equal(rf.db_per_100feet_2_db_per_100meter(), rf.meter_2_feet(), decimal=2) assert_almost_equal(rf.db_per_100feet_2_db_per_100meter(2.5), 8.2, decimal=2) assert_almost_equal(rf.db_per_100feet_2_db_per_100meter(0.28), 0.92, decimal=2)
def test_meter_2_feet(self): """ Test meter to feet length conversion """ assert_almost_equal(rf.meter_2_feet(0.01), 0.0328084) assert_almost_equal(rf.meter_2_feet(1), 3.28084)