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

Make PSF work with nd-input #2689

Draft
wants to merge 70 commits into
base: PSFModel
Choose a base branch
from
Draft

Make PSF work with nd-input #2689

wants to merge 70 commits into from

Conversation

maxnoe
Copy link
Member

@maxnoe maxnoe commented Jan 23, 2025

Trying to make #2643 work with ND input.

Using this script to plot:

import astropy.units as u
import numpy as np
from ctapipe.instrument.optics import ComaModel
from ctapipe.instrument import SubarrayDescription
import matplotlib.pyplot as plt

subarray = SubarrayDescription.read("dataset://gamma_prod5.simtel.zst")

lst1 = subarray.select_subarray([1])
psf_model = ComaModel(
    subarray=lst1,
    asymmetry_params=[0.5, 10, 0.15],
    radial_scale_params=[0.015, -0.1, 0.06, 0.03],
    az_scale_params=[0.25, 7.5, 0.02],
)

edges_x = np.linspace(-0.1, 0.1, 250) * u.m
edges_y = np.linspace(-0.1, 0.1, 250) * u.m
centers_x = 0.5 * (edges_x[:-1] + edges_x[1:])
centers_y = 0.5 * (edges_y[:-1] + edges_y[1:])
x, y = np.meshgrid(centers_x, centers_y)

psf_center = psf_model.pdf(x, y, 0.0 * u.m, 0.0 * u.m)
psf_border = psf_model.pdf(x + 1 * u.m, y + 1 * u.m, 1 * u.m, 1 * u.m)

fig, (ax1, ax2) = plt.subplots(1, 2, layout="constrained")

ax1.pcolormesh(
    edges_x.to_value(u.m),
    edges_y.to_value(u.m),
    psf_center,
    cmap='inferno',
)

ax2.pcolormesh(
    edges_x.to_value(u.m),
    edges_y.to_value(u.m),
    psf_border,
    cmap='inferno',
)

ax1.set(
    aspect=1,
    title="PSF at (0 m, 0 m)",
)
ax2.set(
    aspect=1,
    title="PSF at (1 m, 1 m)",
)

plt.show()

This is the current result on this branch (The PSF at (1, 1) all evaluates to nan_:
psf_mode

maxnoe and others added 30 commits November 21, 2024 18:43
Fix uncertainty calculation in StereoMeanCombiner
Fix error in ctapipe-process in case telescope event is missing true image
maxnoe and others added 24 commits December 5, 2024 17:40
Fix broken Numpy style guide link.
Current link is broken showing "no status" message
Update the link to the CI status badge in README
Add explicit cast necessary in numpy >=2.1
Co-authored-by: Daniel Morcuende <[email protected]>

Co-authored-by: Daniel Morcuende <[email protected]>
Fill `containers.SimulatedCameraContainer.true_image_sum` in HDF5eventsource
Make sonar coverage badge link point to coverage
@maxnoe maxnoe requested a review from mexanick January 23, 2025 18:10
@maxnoe
Copy link
Member Author

maxnoe commented Jan 23, 2025

I checked, the result is the same in #2643 when using loops to evaluate single points, so the vectorization here is correct and the results are weird.

@maxnoe
Copy link
Member Author

maxnoe commented Jan 23, 2025

@mexanick I pushed some changes to notation and fixed the order of paramters to polyval, with those changes, I now get this for the PSF plots:

psf_model

Still not what I would expect... but no nans is an improvement I'd say

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants