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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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