Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCP cleanup #164

Merged
merged 17 commits into from
Nov 3, 2023
Merged
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
13 changes: 0 additions & 13 deletions docs/api-reference/irfs/index.rst

This file was deleted.

47 changes: 0 additions & 47 deletions download_data.sh

This file was deleted.

150 changes: 0 additions & 150 deletions magicctapipe/config/config_MAGIC_LST.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion magicctapipe/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from astropy.table import Table
from ctapipe.utils.download import download_file_cached

from magicctapipe.utils import resource_file
from magicctapipe.io import resource_file

maxjoint = 13000
maxmonly = 500
Expand Down
8 changes: 1 addition & 7 deletions magicctapipe/image/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
from .calib import calibrate
from .cleaning import (
MAGICClean,
PixelTreatment,
clean_image_params,
get_num_islands_MAGIC,
)
from .cleaning import MAGICClean, PixelTreatment, get_num_islands_MAGIC
from .leakage import get_leakage

__all__ = [
"MAGICClean",
"PixelTreatment",
"get_num_islands_MAGIC",
"calibrate",
"clean_image_params",
"get_leakage",
]
40 changes: 0 additions & 40 deletions magicctapipe/image/cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
import itertools

import numpy as np
from ctapipe.image import hillas_parameters, leakage_parameters, timing_parameters
from scipy.sparse.csgraph import connected_components

__all__ = [
"MAGICClean",
"PixelTreatment",
"get_num_islands_MAGIC",
"clean_image_params",
]


Expand Down Expand Up @@ -672,41 +670,3 @@ def get_num_islands_MAGIC(camera, clean_mask, event_image):
clean_neighbors = neighbors[clean_mask][:, clean_mask]
num_islands, labels = connected_components(clean_neighbors, directed=False)
return num_islands


def clean_image_params(geom, image, clean, peakpos):
"""Evaluate cleaned image parameters

Parameters
----------
geom : ctapipe.instrument.camera.geometry.CameraGeometry
camera geometry
image : numpy.ndarray
image
clean : numpy.ndarray
clean mask
peakpos : numpy.ndarray
peakpos

Returns
-------
tuple
tuple of three containers for hillas, leakage and timing parameters
"""
# Hillas parameters, same for LST and MAGIC. From ctapipe
hillas_p = hillas_parameters(geom=geom[clean], image=image[clean])
# Leakage, same for LST and MAGIC. From ctapipe
leakage_p = leakage_parameters(geom=geom, image=image, cleaning_mask=clean)
# Timing parameters, same for LST and MAGIC. From ctapipe
timing_p = timing_parameters(
geom=geom[clean],
image=image[clean],
peak_time=peakpos[clean],
hillas_parameters=hillas_p,
)

# Make sure each telescope get's an arrow
# if abs(time_grad[tel_id]) < 0.2:
# time_grad[tel_id] = 1

return hillas_p, leakage_p, timing_p
2 changes: 2 additions & 0 deletions magicctapipe/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
load_mc_dl2_data_file,
load_train_data_files,
load_train_data_files_tel,
resource_file,
save_pandas_data_in_table,
telescope_combinations,
)
Expand All @@ -51,4 +52,5 @@
"load_train_data_files_tel",
"save_pandas_data_in_table",
"telescope_combinations",
"resource_file",
]
22 changes: 22 additions & 0 deletions magicctapipe/io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
from pyirf.simulations import SimulatedEventsInfo
from pyirf.utils import calculate_source_fov_offset, calculate_theta

try:
from importlib.resources import files
except ImportError:
from importlib_resources import files

from ..utils import calculate_mean_direction, transform_altaz_to_radec

__all__ = [
Expand All @@ -38,6 +43,7 @@
"load_train_data_files_tel",
"save_pandas_data_in_table",
"telescope_combinations",
"resource_file",
]

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -178,7 +184,7 @@
if current_tel == len(
keys
): # The function stops once we reach the last telescope
return

Check warning on line 187 in magicctapipe/io/io.py

View check run for this annotation

Codecov / codecov/patch

magicctapipe/io/io.py#L187

Added line #L187 was not covered by tests

current_comb_name = (
current_comb[0] + "_" + TEL_NAMES[keys[current_tel]]
Expand Down Expand Up @@ -1349,3 +1355,19 @@

with tables.open_file(output_file, mode=mode) as f_out:
f_out.create_table(group_name, table_name, createparents=True, obj=data_array)


def resource_file(filename):
"""Get the absoulte path of magicctapipe resource files.

Parameters
----------
filename : str
Input filename

Returns
-------
str
Absolute path of the input filename
"""
return files("magicctapipe").joinpath("resources", filename)
29 changes: 0 additions & 29 deletions magicctapipe/irfs/__init__.py

This file was deleted.

Loading