Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 72 additions & 6 deletions magicctapipe/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,64 @@ def temp_DL3_monly(tmp_path_factory):
"""


@pytest.fixture(scope="session")
def query_test_1(temp_DL2_test):
"""
Toy DL2
"""
path = temp_DL2_test / "query_test_1.h5"
data = Table()
data["event_id"] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
data["combo_type"] = [1, 3, 3, 2, 2, 0, 1, 2, 3, 0, 1, 2]
data["magic_stereo"] = [
True,
True,
False,
True,
False,
True,
False,
False,
True,
False,
True,
True,
]
write_table_hdf5(
data, str(path), "/events/parameters", overwrite=True, serialize_meta=False
)
return path


@pytest.fixture(scope="session")
def query_test_2(temp_DL2_test):
"""
Toy DL2
"""
path = temp_DL2_test / "query_test_2.h5"
data = Table()
data["event_id"] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
data["combo_type"] = [1, 6, 3, 4, 2, 3, 1, 2, 3, 5, 1, 2]
data["magic_stereo"] = [
True,
True,
False,
True,
False,
True,
False,
False,
True,
False,
True,
True,
]
write_table_hdf5(
data, str(path), "/events/parameters", overwrite=True, serialize_meta=False
)
return path


@pytest.fixture(scope="session")
def dl2_test(temp_DL2_test):
"""
Expand Down Expand Up @@ -652,7 +710,7 @@ def RF_monly(gamma_stereo_monly, p_stereo_monly, temp_rf_monly, config_monly):


@pytest.fixture(scope="session")
def gamma_dl2(temp_DL1_gamma_test, RF, temp_DL2_gamma):
def gamma_dl2(temp_DL1_gamma_test, RF, temp_DL2_gamma, config):
"""
Produce a DL2 file
"""
Expand All @@ -664,6 +722,7 @@ def gamma_dl2(temp_DL1_gamma_test, RF, temp_DL2_gamma):
f"-d{str(file)}",
f"-r{str(RF)}",
f"-o{str(temp_DL2_gamma)}",
f"-c{str(config)}",
]
)

Expand All @@ -686,7 +745,9 @@ def gamma_dl2(temp_DL1_gamma_test, RF, temp_DL2_gamma):


@pytest.fixture(scope="session")
def gamma_dl2_monly(temp_DL1_gamma_test_monly, RF_monly, temp_DL2_gamma_monly):
def gamma_dl2_monly(
temp_DL1_gamma_test_monly, RF_monly, temp_DL2_gamma_monly, config_monly
):
"""
Produce a DL2 file
"""
Expand All @@ -698,6 +759,7 @@ def gamma_dl2_monly(temp_DL1_gamma_test_monly, RF_monly, temp_DL2_gamma_monly):
f"-d{str(file)}",
f"-r{str(RF_monly)}",
f"-o{str(temp_DL2_gamma_monly)}",
f"-c{str(config_monly)}",
]
)

Expand Down Expand Up @@ -755,7 +817,7 @@ def IRF_monly(gamma_dl2_monly, config_monly, temp_irf_monly):


@pytest.fixture(scope="session")
def p_dl2(temp_DL1_p_test, RF, temp_DL2_p):
def p_dl2(temp_DL1_p_test, RF, temp_DL2_p, config):
"""
Produce a DL2 file
"""
Expand All @@ -767,13 +829,14 @@ def p_dl2(temp_DL1_p_test, RF, temp_DL2_p):
f"-d{str(file)}",
f"-r{str(RF)}",
f"-o{str(temp_DL2_p)}",
f"-c{str(config)}",
]
)
return temp_DL2_p


@pytest.fixture(scope="session")
def p_dl2_monly(temp_DL1_p_test_monly, RF_monly, temp_DL2_p_monly):
def p_dl2_monly(temp_DL1_p_test_monly, RF_monly, temp_DL2_p_monly, config_monly):
"""
Produce a DL2 file
"""
Expand All @@ -785,6 +848,7 @@ def p_dl2_monly(temp_DL1_p_test_monly, RF_monly, temp_DL2_p_monly):
f"-d{str(file)}",
f"-r{str(RF_monly)}",
f"-o{str(temp_DL2_p_monly)}",
f"-c{str(config_monly)}",
]
)
return temp_DL2_p_monly
Expand Down Expand Up @@ -964,7 +1028,7 @@ def stereo_monly(merge_magic_monly, temp_stereo_monly, config_monly):


@pytest.fixture(scope="session")
def real_dl2(coincidence_stereo, RF, temp_DL2_real):
def real_dl2(coincidence_stereo, RF, temp_DL2_real, config):
"""
Produce a DL2 file
"""
Expand All @@ -976,13 +1040,14 @@ def real_dl2(coincidence_stereo, RF, temp_DL2_real):
f"-d{str(file)}",
f"-r{str(RF)}",
f"-o{str(temp_DL2_real)}",
f"-c{str(config)}",
]
)
return temp_DL2_real


@pytest.fixture(scope="session")
def real_dl2_monly(stereo_monly, RF_monly, temp_DL2_real_monly):
def real_dl2_monly(stereo_monly, RF_monly, temp_DL2_real_monly, config_monly):
"""
Produce a DL2 file
"""
Expand All @@ -994,6 +1059,7 @@ def real_dl2_monly(stereo_monly, RF_monly, temp_DL2_real_monly):
f"-d{str(file)}",
f"-r{str(RF_monly)}",
f"-o{str(temp_DL2_real_monly)}",
f"-c{str(config_monly)}",
]
)
return temp_DL2_real_monly
Expand Down
6 changes: 2 additions & 4 deletions magicctapipe/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
format_object,
get_dl2_mean,
get_stereo_events,
get_stereo_events_old,
load_dl2_data_file,
load_irf_files,
load_lst_dl1_data_file,
load_magic_dl1_data_files,
load_mc_dl2_data_file,
load_train_data_files,
load_train_data_files_tel,
query_data,
resource_file,
save_pandas_data_in_table,
telescope_combinations,
Expand All @@ -42,14 +41,13 @@
"format_object",
"get_dl2_mean",
"get_stereo_events",
"get_stereo_events_old",
"load_dl2_data_file",
"load_irf_files",
"load_lst_dl1_data_file",
"load_magic_dl1_data_files",
"load_mc_dl2_data_file",
"load_train_data_files",
"load_train_data_files_tel",
"query_data",
"save_pandas_data_in_table",
"telescope_combinations",
"resource_file",
Expand Down
12 changes: 5 additions & 7 deletions magicctapipe/io/gadf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from .. import __version__ as MCP_VERSION
from ..utils.functions import HEIGHT_ORM, LAT_ORM, LON_ORM
from .io import telescope_combinations

__all__ = [
"create_gh_cuts_hdu",
Expand Down Expand Up @@ -88,7 +89,7 @@ def create_gh_cuts_hdu(gh_cuts, reco_energy_bins, fov_offset_bins, **header_card


def create_event_hdu(
event_table, on_time, deadc, source_name, source_ra=None, source_dec=None
event_table, config, on_time, deadc, source_name, source_ra=None, source_dec=None
):
"""
Creates a fits binary table HDU for shower events.
Expand All @@ -97,6 +98,8 @@ def create_event_hdu(
----------
event_table : astropy.table.table.QTable
Table of the DL2 events surviving gammaness cuts
config : dict
Dictionary with information about the telescope IDs.
on_time : astropy.table.table.QTable
ON time of the input data
deadc : float
Expand All @@ -123,12 +126,7 @@ def create_event_hdu(
If the source name cannot be resolved and also either or both of
source RA/Dec coordinate is set to None
"""
TEL_COMBINATIONS = {
"LST1_M1": [1, 2], # combo_type = 0
"LST1_M1_M2": [1, 2, 3], # combo_type = 1
"LST1_M2": [1, 3], # combo_type = 2
"M1_M2": [2, 3], # combo_type = 3
} # TODO: REMOVE WHEN SWITCHING TO THE NEW RFs IMPLEMENTTATION (1 RF PER TELESCOPE)
_, TEL_COMBINATIONS = telescope_combinations(config)
mjdreff, mjdrefi = np.modf(MJDREF.mjd)

time_start = Time(event_table["timestamp"][0], format="unix", scale="utc")
Expand Down
Loading