def test_rcvr_ampnoise(signal, pulsar, receiver): """ Testing making amplitude noise for baseband signal. """ tobs = make_quant(0.02, 's') pulsar.make_pulses(signal, tobs) Tsys = make_quant(35.0, 'K') gain = 1.0 noise = receiver._make_amp_noise(signal, Tsys, gain, pulsar)
def test_bb_disperse(bbsignal, j1713_profile, ism): """ Test disperse function with baseband signal. """ tobs = make_quant(0.05, 's') period = make_quant(5, 'ms') psr = Pulsar(period, 10, profiles=j1713_profile, name='J1746-0118') psr.make_pulses(bbsignal, tobs) ism.disperse(bbsignal, 10) assert (bbsignal.dm.value == 10)
def test_add_delay(signal, pulsar, ism): """ Test add delay from dispersion and FD. """ tobs = make_quant(5, 's') pulsar.make_pulses(signal, tobs) signal._delay = np.repeat(make_quant(1.0, 'ms'), len(signal._dat_freq)) ism.disperse(signal, 10) assert signal.dm.value == 10 ism.FD_shift(signal, [1e-5, -2e-5]) assert (signal._FDshifted == True)
def test_scatterbroaden(signal, pulsar, ism): """ Test pulsar scatter broadening with convolution. """ tobs = make_quant(5, 's') ism.scatter_broaden(signal, 5e-6, 1400.0, convolve=True, pulsar=pulsar) pulsar.make_pulses(signal, tobs)
def test_scattershift(signal, pulsar, ism): """ Test direct scattering shift in time. """ tobs = make_quant(5, 's') pulsar.make_pulses(signal, tobs) ism.scatter_broaden(signal, 5e-6, 1400.0)
def test_scalinglaws(ism): """""" nu_i = make_quant(1400.0, 'MHz') nu_f = make_quant(1200.0, 'MHz') # scale scintillation bandwidth dnu_d = make_quant(20.0, 'MHz') ism.scale_dnu_d(dnu_d, nu_i, nu_f, beta=5) ism.scale_dnu_d(dnu_d, nu_i, nu_f, beta=3) # scale scintillation timescale dt_d = make_quant(3600.0, 's') ism.scale_dt_d(dt_d, nu_i, nu_f, beta=5) ism.scale_dt_d(dt_d, nu_i, nu_f, beta=3) # scale scattering timescale tau_d = make_quant(5e-6, 's') ism.scale_tau_d(tau_d, nu_i, nu_f, beta=5) ism.scale_tau_d(tau_d, nu_i, nu_f, beta=3)
def pulsar(): """ Fixture pulsar class """ F0 = 186.49408124993144 period = make_quant(1.0 / F0, 's') return Pulsar(period, 10, name='J1746-0118')
def backend(): """ Fixture backend class """ smprte = make_quant(81.92, "microsecond") bckend = Backend(samprate=(1.0 / smprte).to("MHz"), name="Cyborg") return bckend
def test_FDshift(signal, pulsar, ism): """ Test FD shift function. """ tobs = make_quant(5, 's') pulsar.make_pulses(signal, tobs) ism.FD_shift(signal, [2e-4, -3e-4, 7e-5])
def test_savepdv(TXTfile, signal, pulsar): """ Test saving data in pdv format. """ tobs = make_quant(1, 's') pulsar.make_pulses(signal, tobs) TXTfile.save_psrchive_pdv(signal, pulsar) os.remove("data/test_pdv_0.txt")
def test_subint_obs(tscope, receiver, backend, subint_signal, pulsar): """ Test adding a system to the telescope and observing with subint signal """ tscope.add_system(name="Twnty_M", receiver=receiver, backend=backend) tobs = make_quant(0.02, 's') pulsar.make_pulses(subint_signal, tobs) tscope.observe(subint_signal, pulsar, system="Twnty_M", noise=False)
def test_bb_obs(tscope, receiver, backend, bb_signal, pulsar): """ Test adding a system to the telescope and observing with subint signal """ tscope.add_system(name="Twnty_M", receiver=receiver, backend=backend) tobs = make_quant(0.01, 's') pulsar.make_pulses(bb_signal, tobs) with pytest.raises(NotImplementedError): tscope.observe(bb_signal, pulsar, system="Twnty_M", noise=False)
def test_backend(signal, pulsar, backend): """ Test for backend class. """ backend_names = backend.__repr__() assert (backend.name == "Cyborg") tobs = make_quant(0.02, 's') pulsar.make_pulses(signal, tobs) fold_sig = backend.fold(signal, pulsar)
def test_shiftlowchan(S_lowchan, pulsar, ism): """ Test shift functions with less than 20 frequency channels. """ tobs = make_quant(5, 's') pulsar.make_pulses(S_lowchan, tobs) ism.disperse(S_lowchan, 10) ism.FD_shift(S_lowchan, [1e-5, -2e-5]) ism.scatter_broaden(S_lowchan, 5e-6, 1400.0)
def test_sampling(receiver, signal, pulsar): """ Test sampling rate comparisons. Lines to Test: 89, 111, 136-139 Not 100% sure some of these lines are being tested appropriately. """ scope1 = Telescope(20.0, area=None, Tsys=25.0, name="Twenty_Meter") # Check dt_tel = dt_sig backend1 = Backend(samprate=1.0 / make_quant(4.8828125e-06, 's'), name="Cyborg") scope1.add_system(name="Twnty_M", receiver=receiver, backend=backend1) tobs = make_quant(0.02, 's') pulsar.make_pulses(signal, tobs) scope1.observe(signal, pulsar, system="Twnty_M", noise=True) # Check dt_tel % dt_sig = 0 backend2 = Backend(samprate=1.0 / make_quant(9.765625e-06, 's'), name="Cyborg") scope1.add_system(name="Twnty_M", receiver=receiver, backend=backend2) scope1.observe(signal, pulsar, system="Twnty_M", noise=True)
def test_disperse(signal, pulsar, ism): """ Test disperse function with filterbank signal. """ tobs = make_quant(5, 's') pulsar.make_pulses(signal, tobs) ism.disperse(signal, 10) assert signal.dm.value == 10 with pytest.raises(ValueError): ism.disperse(signal, 10)
def test_rcvr(signal, pulsar, receiver): """ Tests for the receiver class. """ rcvr_names = receiver.__repr__() assert (receiver.name == "Lband") assert (callable(receiver.response)) assert (receiver.fcent.value == 1400.0) assert (receiver.bandwidth.value == 400.0) # Test Tenv checks tobs = make_quant(0.02, 's') pulsar.make_pulses(signal, tobs) receiver.radiometer_noise(signal, pulsar, gain=1, Tsys=None, Tenv=None) with pytest.raises(ValueError): receiver.radiometer_noise(signal, pulsar, gain=1, Tsys=1.0, Tenv=1.0) receiver.radiometer_noise(signal, pulsar, gain=1, Tsys=None, Tenv=make_quant(2.0, 'K')) # Test get noise failure with pytest.raises(NotImplementedError): signal._sigtype = None receiver.radiometer_noise(signal, pulsar, gain=1, Tsys=None, Tenv=None)
def test_moretxtfile(pulsar): """ Test a few additional lines and properties of the txtfile class. Lines to Test: 59 """ fbsig = FilterBankSignal(1400,400,Nsubband=101,\ sample_rate=186.49408124993144*2048*10**-6,\ sublen=0.5) tobs = make_quant(1, 's') pulsar.make_pulses(fbsig, tobs) # Initialize without path tf = TxtFile(path=None) tf.save_psrchive_pdv(fbsig, pulsar) os.remove("PsrSigSim_Simulated_Pulsar.ar_1.txt") os.remove("PsrSigSim_Simulated_Pulsar.ar_2.txt") # Check attribute assert (tf.tbin == 1.0 / fbsig.samprate) assert (tf.obsfreq == fbsig.fcent) assert (tf.chan_bw == fbsig.bw / fbsig.Nchan)
def pulsar(): """ Fixture pulsar class """ period = make_quant(5, 'ms') return Pulsar(period, 10, name='J1746-0118')
def test_disperse(signal, pulsar, ism): """""" tobs = make_quant(5, 's') pulsar.make_pulses(signal, tobs) ism.disperse(signal, 10)
def test_savepdv(TXTfile, signal, pulsar): tobs = make_quant(1,'s') pulsar.make_pulses(signal,tobs) TXTfile.save_psrchive_pdv(signal, pulsar) os.remove("data/test_pdv_0.txt")