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

Add algorithm to compute image parameters via fitting the light distribution #2275

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
daf07f3
first step towards new image parametrization algorithm
clara-escanuela Mar 1, 2023
81e9e4d
Added condition for fitting
clara-escanuela Mar 2, 2023
5e1e186
solved problem
clara-escanuela Mar 2, 2023
b41fba6
add extra information from the fit
clara-escanuela Mar 3, 2023
adc7271
added the three different models and changed the definition of pdfs (…
clara-escanuela Mar 4, 2023
390a685
improved descriptions
clara-escanuela Mar 5, 2023
db3e58c
added details of the model
clara-escanuela Mar 5, 2023
cb68a2d
added test
clara-escanuela Mar 5, 2023
7c86a6e
rebase main branch and reformatting
clara-escanuela Mar 16, 2023
02774fe
add docs/changes/2275.*.rst file
clara-escanuela Mar 16, 2023
20b0b0d
added more tests and made some changes in the method
clara-escanuela Apr 9, 2023
36eae9a
solved issues with tests
clara-escanuela Apr 10, 2023
2f6e677
solved issues with tests
clara-escanuela Apr 10, 2023
242d90a
added simple test on boundaries
clara-escanuela Apr 10, 2023
35648fa
added one test
clara-escanuela Apr 10, 2023
9f6897f
added a test on the skewness of the Skewed and Cauchy
clara-escanuela Apr 12, 2023
03d9877
replaced Cauchy function by Laplace, seems to be a better match
clara-escanuela Apr 17, 2023
6b5d8ed
added PDFType instances and removed not needed line in dilation
clara-escanuela Apr 18, 2023
22e1247
solved problem with skewness boundaries
clara-escanuela Apr 26, 2023
e9a9d4a
removed no needed containers and repeated lines of code
clara-escanuela May 5, 2023
198832d
reduce code duplications
clara-escanuela May 5, 2023
6b1b70d
added one test and adapted code
clara-escanuela May 5, 2023
0a239ca
improved documentation
clara-escanuela May 5, 2023
0043aad
added goodness of fit
clara-escanuela May 6, 2023
c9bef50
removed unnecesary function and repetitions
clara-escanuela Sep 12, 2023
329a772
removed unnecesary function and repetitions
clara-escanuela Sep 12, 2023
09beba4
fixed single pixel unit test
clara-escanuela Sep 13, 2023
e07d947
removed dilation function
clara-escanuela Sep 13, 2023
790ab1f
fixed unit tests for toymodel
clara-escanuela Sep 13, 2023
f81e7d5
added telescope frame
clara-escanuela Sep 13, 2023
fd22cf0
changed variable names
clara-escanuela Sep 13, 2023
dec2e6d
removed Laplace model
clara-escanuela Sep 14, 2023
6a08f04
test changes
clara-escanuela Sep 14, 2023
879c18f
more unit tests
clara-escanuela Sep 14, 2023
12d3738
removed camera frame
clara-escanuela Dec 15, 2023
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
32 changes: 32 additions & 0 deletions ctapipe/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"MorphologyContainer",
"BaseHillasParametersContainer",
"CameraHillasParametersContainer",
"ImageFitParametersContainer",
"CameraTimingParametersContainer",
"ParticleClassificationContainer",
"PedestalContainer",
Expand Down Expand Up @@ -308,6 +309,37 @@ class HillasParametersContainer(BaseHillasParametersContainer):
psi = Field(nan * u.deg, "rotation angle of ellipse", unit=u.deg)


class ImageFitParametersContainer(HillasParametersContainer):
"""
Hillas Parameters after fitting. The cog position
is given in meter from the camera center.
"""

skewness_uncertainty = Field(nan, "measure of skewness uncertainty")
likelihood = Field(nan, "measure of likelihood")
goodness_of_fit = Field(
nan, "measure of goodness of fit, mean likelihood subtracted to the likelihood"
)
n_pixels = Field(-1, "number of pixels used in the fit")
free_parameters = Field(-1, "number of free parameters")
is_valid = Field(False, "True if the fit is valid")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between is_valid and is_accurate?

is_accurate = Field(
False, "returns True if the fit is accurate. If False, the fit is not reliable."
)

fov_lon_uncertainty = Field(nan * u.deg, "centroid x uncertainty", unit=u.deg)
fov_lat_uncertainty = Field(nan * u.deg, "centroid y uncertainty", unit=u.deg)
r_uncertainty = Field(nan * u.deg, "centroid r uncertainty", unit=u.deg)
phi_uncertainty = Field(
nan * u.deg, "polar coordinate of centroid uncertainty", unit=u.deg
)
psi_uncertainty = Field(
nan * u.deg, "Uncertainty in rotation angle of ellipse", unit=u.deg
)
amplitude = Field(nan, "Amplitude of the fitted model")
amplitude_uncertainty = Field(nan, "error in amplitude from the fit")


class LeakageContainer(Container):
"""
Fraction of signal in 1 or 2-pixel width border from the edge of the
Expand Down
10 changes: 5 additions & 5 deletions ctapipe/image/concentration.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import numpy as np
import astropy.units as u
import numpy as np

from ..containers import (
CameraHillasParametersContainer,
ConcentrationContainer,
HillasParametersContainer,
CameraHillasParametersContainer,
)
from .hillas import camera_to_shower_coordinates
from ..instrument import CameraGeometry
from ..utils.quantities import all_to_value
from .hillas import camera_to_shower_coordinates

__all__ = ["concentration_parameters"]

Expand Down Expand Up @@ -53,15 +53,15 @@ def concentration_parameters(geom: CameraGeometry, image, hillas_parameters):
delta_y = pix_y - y

# take pixels within one pixel diameter from the cog
mask_cog = (delta_x ** 2 + delta_y ** 2) < pixel_width ** 2
mask_cog = (delta_x**2 + delta_y**2) < pixel_width**2
conc_cog = np.sum(image[mask_cog]) / h.intensity

if hillas_parameters.width.value != 0:
# get all pixels inside the hillas ellipse
longi, trans = camera_to_shower_coordinates(
pix_x, pix_y, x, y, h.psi.to_value(u.rad)
)
mask_core = (longi ** 2 / length ** 2) + (trans ** 2 / width ** 2) <= 1.0
mask_core = (longi**2 / length**2) + (trans**2 / width**2) <= 1.0
conc_core = image[mask_core].sum() / h.intensity
else:
conc_core = 0.0
Expand Down
Loading