예제 #1
0
def test_create_irf_point_like_energy_dependent_cuts(
    temp_dir_observed_files, simulated_dl2_file
):
    """
    Generating point-like IRF file from a test DL2 files, using
    energy-dependent cuts
    """
    from lstchain.tools.lstchain_create_irf_files import IRFFITSWriter
    from gammapy.irf import RadMax2D

    irf_file = temp_dir_observed_files / "pnt_irf.fits.gz"

    assert (
        run_tool(
            IRFFITSWriter(),
            argv=[
                f"--input-gamma-dl2={simulated_dl2_file}",
                f"--input-proton-dl2={simulated_dl2_file}",
                f"--input-electron-dl2={simulated_dl2_file}",
                f"--output-irf-file={irf_file}",
                "--overwrite",
                "--energy-dependent-gh",
                "--point-like",
                "--energy-dependent-theta",
                "--DL3Cuts.max_theta_cut=1",
                "--DL3Cuts.fill_theta_cut=1"
            ],
            cwd=temp_dir_observed_files,
        )
        == 0
    )

    assert RadMax2D.read(irf_file, hdu="RAD_MAX")
예제 #2
0
def test_rad_max_roundtrip(tmp_path):
    n_energy = 10
    energy_axis = MapAxis.from_energy_bounds(50 * u.GeV,
                                             100 * u.TeV,
                                             n_energy,
                                             name="energy")

    n_offset = 5
    offset_axis = MapAxis.from_bounds(0,
                                      2,
                                      n_offset,
                                      unit=u.deg,
                                      name="offset")

    shape = (n_energy, n_offset)
    rad_max = np.linspace(0.1, 0.5, n_energy * n_offset).reshape(shape)

    rad_max_2d = RadMax2D(
        axes=[
            energy_axis,
            offset_axis,
        ],
        data=rad_max,
        unit=u.deg,
    )

    rad_max_2d.write(tmp_path / "rad_max.fits")
    rad_max_read = RadMax2D.read(tmp_path / "rad_max.fits")

    assert np.all(rad_max_read.data == rad_max)
    assert np.all(rad_max_read.data == rad_max_read.data)