Пример #1
0
def test_generate_polycos(tmpdir, par_file, obs, obsfreq, nspan, ncoeff):
    output_polyco = tmpdir / "B1855_polyco_round_trip_from_par.dat"
    mjd_start, mjd_end = 55000.0, 55001.0

    model = get_model(str(par_file))

    p = Polycos()
    p.generate_polycos(model, mjd_start, mjd_end, obs, nspan, ncoeff, obsfreq)
    p.write_polyco_file(output_polyco)
    q = Polycos()
    q.read_polyco_file(output_polyco)

    mjds = np.linspace(mjd_start, mjd_end, 51)

    t = toa.get_TOAs_list(
        [toa.TOA(mjd, obs=obs, freq=obsfreq) for mjd in mjds],
        ephem=model.EPHEM.value)
    ph1 = p.eval_abs_phase(mjds)
    ph2 = q.eval_abs_phase(mjds)
    ph3 = model.phase(t, abs_phase=True)

    assert np.allclose(ph1.int.value[0], ph3.int.value[0])
    assert np.allclose(ph1.frac.value[0], ph3.frac.value[0])
    assert np.allclose(ph2.int.value[0], ph3.int.value[0])
    assert np.allclose(ph2.frac.value[0], ph3.frac.value[0])
Пример #2
0
def test_generate_polycos_maxha_error(par_file):
    model = get_model(str(par_file))
    p = Polycos()
    with pytest.raises(ValueError):
        p.generate_polycos(model, 55000, 55002, "ao", 144, 12, 400.0, maxha=8)