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

PSF model #2643

Merged
merged 36 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e9296fe
adding PSF model
Oct 31, 2024
dc46bfb
adding tests and documentation
Nov 1, 2024
3a00501
adding changelog, fixing test
Nov 10, 2024
c260bfb
renaming changelog
Nov 10, 2024
f4c95a3
Moving the psf models to ctapipe.instrument.optics
Nov 11, 2024
31a56bb
Updating docustrings
Nov 11, 2024
317609b
upate docustring
Nov 11, 2024
163b0a9
Updating and renaming from_name method
Nov 11, 2024
5b807fe
updating doumentation with comamodel math
Nov 13, 2024
3697b35
Fixing issues in documentation
Nov 13, 2024
e8d29b8
update to docustrings
Nov 14, 2024
9ddc35c
fixing issue in docustring
Nov 14, 2024
2a3ce78
removing the update_location method
Nov 14, 2024
a1f0b1e
fixing more issues with docustrings
Nov 14, 2024
5041e52
Refactoring as `TelescopeComponent`
Nov 14, 2024
30233b0
Moving some documentation
Nov 15, 2024
6dfc537
Fixing some docustring
Nov 15, 2024
148c043
Merge branch 'main' into PSFModel
ctoennis Nov 27, 2024
36c8748
fixing issue in reference bibtex file
Nov 27, 2024
3518a8b
implementing reviewer comments
Dec 2, 2024
b7d6498
changing tests
Dec 3, 2024
4af9bdb
fixing sign issue in psf test parameters
Dec 3, 2024
2f9900f
using trait validation
Dec 3, 2024
c0f27cf
moving traitlets validate import statement
Dec 4, 2024
c3c0af8
Make psf work on nd inputs with units
maxnoe Jan 23, 2025
f8aef5d
Improve notation with respect to paper, fix polyval evaluation (wrong…
maxnoe Jan 23, 2025
cc2457b
More changes to bring notation closer to the paper
maxnoe Jan 23, 2025
5a2ba72
Merge remote-tracking branch 'origin/main' into psf_model_fixes
maxnoe Jan 24, 2025
7245934
Enforcing the edge case of the PSF model
mexanick Jan 28, 2025
3cb33f3
Merge pull request #2689 from cta-observatory/psf_model_fixes
maxnoe Jan 30, 2025
7043868
Fixing division by 0 warning at the camera center
mexanick Feb 4, 2025
f2f1e33
Exposing PSFModel and ComaPSFModel at the ``instrument`` module level
mexanick Feb 4, 2025
f0a686e
Fix formulas in doc
mexanick Feb 4, 2025
b01fa77
Update docs, remove redundant constructor
mexanick Feb 4, 2025
16562dd
Update docstrings addressing @Tobychev comments
mexanick Feb 6, 2025
3a92486
Fix SonarQube-detected code smells
mexanick Feb 6, 2025
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
4 changes: 1 addition & 3 deletions docs/changes/2643.feature.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
Adds psf models to ``ctapipe.instrument.optics`` with the parent class ``PSFModel`` and a psf model based on pure coma abbaration called ``ComaModel``
- All psf models have a function ``PSFModel.update_location`` that updates the location in the focal plane where the PSF is evaluated from
- The function ``PSFModel.update_model_parameters`` allows to update the parameters of the PSF model
Adds psf models to ``ctapipe.instrument.optics`` with the parent class ``PSFModel`` and a psf model based on pure coma aberration called ``ComaModel``
- The function ``PSFModel.pdf`` gives the value of the PSF in a given location
2 changes: 1 addition & 1 deletion src/ctapipe/instrument/optics.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class ComaModel(PSFModel):
radial_scale_params describes the dependency of the radial scale on the distance to the center of the camera
Used to calculate width Sr of the asymmetric radial laplacian in the PSF as a of function the distance r to the optical axis

.. math:: S_{R}(r) & = b_1 - b_2\,r + b_3\,r^2 + b_4\,r^3
.. math:: S_{R}(r) & = b_1 + b_2\,r + b_3\,r^2 + b_4\,r^3

az_scale_params Describes the dependency of the azimuthal scale on the distance to the center of the camera
Used to calculate the width Sf of the azimuthal laplacian in the PSF as a function of the angle :math:`phi`
Expand Down
33 changes: 25 additions & 8 deletions src/ctapipe/instrument/tests/test_psf_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,43 @@
from ctapipe.instrument.optics import PSFModel


def test_psf(example_subarray):
@pytest.fixture(scope="session")
def asymmetry_params():
return [0.49244797, 9.23573115, 0.15216096]
Copy link
Member

Choose a reason for hiding this comment

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

Fixtures are not really meant for simple data like this.

You could just enter them in the test itself.

Also: why these highly specific values just for a unit test? Wouldn't nice round values in the right order of magnitude be easier on the eyes?



@pytest.fixture(scope="session")
def radial_scale_params():
return [0.01409259, -0.02947208, 0.06000271, -0.02969355]


@pytest.fixture(scope="session")
def az_scale_params():
return [0.24271557, 7.5511501, 0.02037972]


def test_psf(example_subarray, asymmetry_params, radial_scale_params):
with pytest.raises(
ValueError,
match="asymmetry_params and az_scale_params needs to have length 3 and radial_scale_params length 4",
):
PSFModel.from_name(
mexanick marked this conversation as resolved.
Show resolved Hide resolved
"ComaModel",
subarray=example_subarray,
asymmetry_params=[0.49244797, 9.23573115, 0.15216096],
radial_scale_params=[0.01409259, 0.02947208, 0.06000271, -0.02969355],
az_scale_params=[0.24271557, 7.5511501],
asymmetry_params=asymmetry_params,
radial_scale_params=radial_scale_params,
az_scale_params=[0.0],
)


def test_asymptotic_behavior(example_subarray):
def test_asymptotic_behavior(
example_subarray, asymmetry_params, radial_scale_params, az_scale_params
):
psf_coma = PSFModel.from_name(
"ComaModel",
subarray=example_subarray,
asymmetry_params=[0.49244797, 9.23573115, 0.15216096],
radial_scale_params=[0.01409259, 0.02947208, 0.06000271, -0.02969355],
az_scale_params=[0.24271557, 7.5511501, 0.02037972],
asymmetry_params=asymmetry_params,
radial_scale_params=radial_scale_params,
az_scale_params=az_scale_params,
)
assert np.isclose(psf_coma.pdf(10.0, 0.0, 1.0, 0.0), 0.0)
Loading