Пример #1
0
def test_pintify_parfile_repeat_line_mix_alises():
    repeat_par = base_par + "EQUAD -fe 1 1 3\nT2EQUAD -fe 2 1 3\nEQUAD -fe 4 2 2"
    m = ModelBuilder()
    with pytest.raises(TimingModelError):
        m._pintify_parfile(StringIO(repeat_par))
    pint_dict, original_name, unknow = m._pintify_parfile(
        StringIO(repeat_par), allow_name_mixing=True)
    # The list order is swaped since parse_parfile will pack EQUADs first and
    # then the pintify will add T2ECORR to the list.
    assert pint_dict["EQUAD1"] == ["-fe 1 1 3", "-fe 4 2 2", "-fe 2 1 3"]
    assert "T2EQUAD" not in pint_dict.keys()
Пример #2
0
def test_parse_parfile_index_param():
    indexed_par = base_par + "DMX_0001 1 1 2\nDMX_0025 2 1 3"
    m = ModelBuilder()
    pint_dict, original_name, unknow = m._pintify_parfile(
        StringIO(indexed_par))
    assert pint_dict["DMX_0001"] == ["1 1 2"]
    assert pint_dict["DMX_0025"] == ["2 1 3"]
Пример #3
0
def test_pintify_parfile_repeat_line_with_repeat_param():
    repeat_par = base_par + "JUMP -fe 1 1 3\nJUMP -fe 2 1 3"
    repeat_par += "\nECORR -fe 1 1 2\nECORR -fe 2 1 2"
    m = ModelBuilder()
    pint_dict, original_name, unknow = m._pintify_parfile(StringIO(repeat_par))
    assert len(pint_dict["JUMP1"]) == 2
    assert len(pint_dict["ECORR1"]) == 2
Пример #4
0
def test_pintify_parfile_alises():
    aliases_par = base_par.replace("ELONG", "LAMBDA")
    m = ModelBuilder()
    pint_dict, original_name, unknow = m._pintify_parfile(
        StringIO(aliases_par))
    assert pint_dict["ELONG"] == ["0 1 3"]
    assert len(unknow) == 0
    assert "LAMBDA" not in pint_dict.keys()
def test_model_from_par():
    """Test Get model from test par file."""
    test_par1 = """
    PSR              B1855+09
    LAMBDA   286.8634893301156  1     0.0000000165859
    BETA      32.3214877555037  1     0.0000000273526
    PMLAMBDA           -3.2701  1              0.0141
    PMBETA             -5.0982  1              0.0291
    PX                  0.2929  1              0.2186
    F0    186.4940812707752116  1  0.0000000000328468
    F1     -6.205147513395D-16  1  1.379566413719D-19
    PEPOCH        54978.000000
    START            53358.726
    FINISH           56598.873
    DM               13.299393
    DMX              14.000000
    DMX_0001    1.51618630D-02  1      3.51684846D-03
    DMXEP_0001     53358.72746
    DMXR1_0001     53358.72746
    DMXR2_0001     53358.77841
    DMXF1_0001         424.000
    DMXF2_0001        1442.000
    DMX_0002    1.52370685D-02  1      3.51683449D-03
    DMXEP_0002     53420.54893
    DMXR1_0002     53420.54893
    DMXR2_0002     53420.58620
    DMXF1_0002         424.000
    DMXF2_0002        1442.000
    FD1  1.61666384D-04  1      3.38650356D-05
    FD2 -1.88210030D-04  1      4.13173074D-05
    SOLARN0               0.00
    EPHEM               DE421
    ECL                 IERS2003
    CLK                 TT(BIPM)
    UNITS               TDB
    TIMEEPH             FB90
    T2CMETHOD           TEMPO
    CORRECT_TROPOSPHERE N
    PLANET_SHAPIRO      N
    #DILATEFREQ          N
    NTOA                  4005
    TRES                  5.52
    TZRMJD  54981.28084616488447
    TZRFRQ             424.000
    TZRSITE                  3
    NITS                     1
    INFO -f
    BINARY            DD
    A1             9.230780480  1         0.000000203
    E             0.0000216340  1        0.0000000236
    T0        54975.5128660817  1        0.0019286695
    PB       12.32717119132762  1    0.00000000019722
    OM        276.536118059963  1      0.056323656112
    SINI              0.999461  1            0.000178
    M2                0.233837  1            0.011278
    RNAMP         0.17173D-01
    RNIDX            -4.91353
    TNRedAmp -14.227505410948254
    TNRedGam 4.91353
    TNRedC 45
    T2EFAC -f L-wide_PUPPI   1.507
    T2EFAC -f 430_ASP   1.147
    T2EQUAD -f L-wide_PUPPI   0.25518
    T2EQUAD -f 430_ASP   0.01410
    ECORR -f 430_PUPPI   0.00601
    ECORR -f L-wide_PUPPI   0.31843
    JUMP -fe L-wide      -0.000009449  1       0.000009439
    """
    mb = ModelBuilder()
    param_inpar, original_name, unknown = mb._pintify_parfile(
        io.StringIO(test_par1))
    # valid_param_inline = []
    # for l in test_par1.split("\n"):
    #     l = l.strip()
    #     if not (l.startswith("#") or l == ""):
    #         valid_param_inline.append(l.split()[0])
    # assert set(repeat) == {"JUMP", "ECORR", "T2EQUAD", "T2EFAC"}
    comps, conflict, _ = mb.choose_model(param_inpar)
    assert comps == {
        "Spindown",
        "FD",
        "AbsPhase",
        "ScaleToaError",
        "TroposphereDelay",
        "PhaseJump",
        "DispersionDMX",
        "AstrometryEcliptic",
        "BinaryDD",
        "DispersionDM",
        "EcorrNoise",
        "SolarWindDispersion",
        "PLRedNoise",
        "SolarSystemShapiro",
    }
    tm = mb(io.StringIO(test_par1))
    assert len(tm.get_prefix_mapping("EQUAD")) == 2
    assert len(tm.get_prefix_mapping("EFAC")) == 2
    assert len(tm.get_prefix_mapping("JUMP")) == 1
Пример #6
0
def test_pintify_parfile_repeat_line_with_repeat_aliases():
    repeat_par = base_par + "T2EQUAD -fe 1 1 3\nT2EQUAD -fe 2 1 3"
    m = ModelBuilder()
    pint_dict, original_name, unknow = m._pintify_parfile(StringIO(repeat_par))
    assert len(pint_dict["EQUAD1"]) == 2
    assert "T2EQUAD" not in pint_dict.keys()
Пример #7
0
def test_pintify_parfile_repeat_line_with_nonrepeat_param():
    repeat_par = base_par + "DM 1 1 3\nF0 2 1 3"
    m = ModelBuilder()
    with pytest.raises(TimingModelError):
        m._pintify_parfile(StringIO(repeat_par))
Пример #8
0
def test_pintify_parfile_from_parfile_dict():
    m = ModelBuilder()
    par_dict = parse_parfile(StringIO(base_par))
    pint_dict, original_name, unknow = m._pintify_parfile(par_dict)
    assert len(pint_dict) == len((base_par.strip()).split("\n"))
    assert len(unknow) == 0
Пример #9
0
def test_pintify_parfile_duplicate_binary():
    dup_par = base_par + "BINARY DD\nBINARY BT"
    m = ModelBuilder()
    with pytest.raises(TimingModelError):
        m._pintify_parfile(StringIO(dup_par))
Пример #10
0
def test_pintify_parfile_unrecognize():
    wrong_par = base_par + "UNKNOWN 2 1 1"
    m = ModelBuilder()
    pint_dict, original_name, unknow = m._pintify_parfile(StringIO(wrong_par))
    assert unknow == {"UNKNOWN": ["2 1 1"]}
Пример #11
0
def test_pintify_parfile_nonrepeat_with_alise_repeating():
    aliases_par = base_par + "LAMBDA 2 1 3"
    m = ModelBuilder()
    with pytest.raises(TimingModelError):
        m._pintify_parfile(StringIO(aliases_par))