コード例 #1
0
ファイル: test_harpy.py プロジェクト: pylhc/omc3
def test_harpy(_test_file, _model_file):

    [
        clean, keep_exact_zeros, singval, peak_to_peak, window, max_peak,
        svd_dominance_limit, num_svd_iterations, tolerance, tune_clean_limit,
        turn_bits, output_bits
    ] = HARPY_INPUT[0]

    model = _get_model_dataframe()
    tfs.write(_model_file, model, save_index="NAME")
    _write_tbt_file(model, os.path.dirname(_test_file))
    hole_in_one_entrypoint(harpy=True,
                           clean=clean,
                           keep_exact_zeros=keep_exact_zeros,
                           singval=singval,
                           peak_to_peak=peak_to_peak,
                           window=window,
                           max_peak=max_peak,
                           svd_dominance_limit=svd_dominance_limit,
                           num_svd_iterations=num_svd_iterations,
                           tolerance=tolerance,
                           tune_clean_limit=tune_clean_limit,
                           turn_bits=turn_bits,
                           output_bits=output_bits,
                           autotunes="transverse",
                           outputdir=os.path.dirname(_test_file),
                           files=[_test_file],
                           model=_model_file,
                           to_write=["lin"],
                           unit="m")
    lin = dict(X=tfs.read(f"{_test_file}.linx"),
               Y=tfs.read(f"{_test_file}.liny"))
    model = tfs.read(_model_file)
    _assert_spectra(lin, model)
コード例 #2
0
ファイル: test_harpy.py プロジェクト: pylhc/omc3
def test_harpy_3d(_test_file, _model_file):
    model = _get_model_dataframe()
    tfs.write(_model_file, model, save_index="NAME")
    _write_tbt_file(model, os.path.dirname(_test_file))
    hole_in_one_entrypoint(harpy=True,
                           clean=True,
                           autotunes="all",
                           outputdir=os.path.dirname(_test_file),
                           files=[_test_file],
                           model=_model_file,
                           to_write=["lin"],
                           turn_bits=18,
                           unit="m")
    lin = dict(X=tfs.read(f"{_test_file}.linx"),
               Y=tfs.read(f"{_test_file}.liny"))
    model = tfs.read(_model_file)
    _assert_spectra(lin, model)
    assert _rms(_diff(lin["X"].loc[:, "TUNEZ"].to_numpy(),
                      TUNEZ)) < LIMITS["F2"]
    assert _rms(
        _rel_diff(
            lin["X"].loc[:, f"AMPZ"].to_numpy() *
            lin["X"].loc[:, f"AMPX"].to_numpy() * 2,
            AMPZ * BASEAMP)) < LIMITS["A2"]
    assert _rms(_angle_diff(lin["X"].loc[:, f"MUZ"].to_numpy(),
                            MUZ)) < LIMITS["P2"]
コード例 #3
0
ファイル: test_harpy.py プロジェクト: pylhc/omc3
def test_freekick_harpy(_test_file, _model_file):
    model = _get_model_dataframe()
    tfs.write(_model_file, model, save_index="NAME")
    _write_tbt_file(model, os.path.dirname(_test_file))
    hole_in_one_entrypoint(harpy=True,
                           clean=True,
                           autotunes="transverse",
                           is_free_kick=True,
                           outputdir=os.path.dirname(_test_file),
                           files=[_test_file],
                           model=_model_file,
                           to_write=["lin"],
                           unit='m',
                           turn_bits=18)
    lin = dict(X=tfs.read(f"{_test_file}.linx"),
               Y=tfs.read(f"{_test_file}.liny"))
    model = tfs.read(_model_file)
    for plane in PLANES:
        # main and secondary frequencies
        assert _rms(
            _diff(lin[plane].loc[:, f"TUNE{plane}"].to_numpy(),
                  model.loc[:, f"TUNE{plane}"].to_numpy())) < LIMITS["F1"]
        # main and secondary amplitudes
        # TODO remove factor 2 - only for backwards compatibility with Drive
        assert _rms(
            _rel_diff(lin[plane].loc[:, f"AMP{plane}"].to_numpy() * 2,
                      model.loc[:, f"AMP{plane}"].to_numpy())) < LIMITS["A1"]
        # main and secondary phases
        assert _rms(
            _angle_diff(lin[plane].loc[:, f"MU{plane}"].to_numpy(),
                        model.loc[:, f"MU{plane}"].to_numpy())) < LIMITS["P1"]
コード例 #4
0
ファイル: test_crdt.py プロジェクト: pylhc/omc3
def _create_input(tmp_path_factory):
    omc3_input = {}

    for order in ORDERS:
        path_to_lin = LIN_DIR / order
        optics_opt = MEASURE_OPTICS_SETTINGS.copy()
        optics_opt.update({
            'files': [str(path_to_lin / f'{order}{idx}') for idx in range(1, 4)],
            'outputdir': tmp_path_factory.mktemp(order).resolve(),
            })
        hole_in_one_entrypoint(**optics_opt)
        omc3_input[order] = (optics_opt, path_to_lin)
    yield omc3_input
コード例 #5
0
ファイル: test_coupling.py プロジェクト: pylhc/omc3
def _run_analysis(output_dir: Union[str, Path], beam: int, sdds_input: str):
    """Run hole_in_one on provided data, return the loaded result coupling files for f1001 and f1010."""
    hole_in_one_entrypoint(
        optics=True,
        accel="lhc",
        year="2018",
        beam=beam,
        model_dir=COUPLING_INPUTS / f"model_b{beam}",
        files=[f"{COUPLING_INPUTS}/{sdds_input}.sdds"],
        compensation="none",
        outputdir=output_dir,
        only_coupling=True,
    )
    f1001 = tfs.read(output_dir / f"{F1001.lower()}.tfs", index=NAME)
    f1010 = tfs.read(output_dir / f"{F1010.lower()}.tfs", index=NAME)
    return f1001, f1010
コード例 #6
0
ファイル: test_harpy.py プロジェクト: pylhc/omc3
def test_harpy_without_model(_test_file, _model_file):
    model = _get_model_dataframe()
    tfs.write(_model_file, model, save_index="NAME")
    _write_tbt_file(model, os.path.dirname(_test_file))
    hole_in_one_entrypoint(harpy=True,
                           clean=True,
                           autotunes="transverse",
                           outputdir=os.path.dirname(_test_file),
                           files=[_test_file],
                           to_write=["lin"],
                           turn_bits=18,
                           unit="m")
    lin = dict(X=tfs.read(f"{_test_file}.linx"),
               Y=tfs.read(f"{_test_file}.liny"))
    model = tfs.read(_model_file)
    _assert_spectra(lin, model)
コード例 #7
0
def _create_input(tmp_path_factory, request):
    omc3_input = {}

    for order in ORDERS:
        path_to_lin = LIN_DIR / order
        optics_opt = MEASURE_OPTICS_SETTINGS.copy()
        optics_opt.update({
            "files": [
                str(path_to_lin / f"B{request.param}_{order}{idx}")
                for idx in range(1, 4)
            ],
            "outputdir":
            tmp_path_factory.mktemp(order).resolve(),
            "beam":
            request.param,
            "model_dir":
            Path(__file__).parent.parent / "inputs" / "models" /
            f"inj_beam{request.param}",
        })
        hole_in_one_entrypoint(**optics_opt)
        omc3_input[order] = (optics_opt, path_to_lin)
    yield omc3_input