Skip to content

Integration in the fitting procedure#87

Merged
gabemery merged 2 commits into
spatial_fit_astropyfrom
integration_in_fit
Jun 18, 2026
Merged

Integration in the fitting procedure#87
gabemery merged 2 commits into
spatial_fit_astropyfrom
integration_in_fit

Conversation

@gabemery

Copy link
Copy Markdown
Collaborator

Implement a simple integration in the fitting procedure. Allow to fit the actual physical distribution of events instead of the convolution with bin size. Improve stability with varying, or non-uniform, binning.

Also includes a small fix and small improvements.

Closes #77

…ort for positionnal arguments in fitting class.
@gabemery gabemery added this to the v0.5.0 milestone Apr 28, 2026
@gabemery
gabemery requested a review from mdebony April 28, 2026 14:05
@gabemery gabemery self-assigned this Apr 28, 2026
@gabemery gabemery added the enhancement New feature or request label Apr 28, 2026

@MSCarrasco MSCarrasco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @gabemery, just one comment on my side about the offset axis computation

Comment thread baccmod/fit_acceptance_map_creator.py Outdated
exp_ds = exp_map_background.downsample(self.oversample_map, preserve_counts=True)
exp_total_ds = exp_map_background_total.downsample(self.oversample_map, preserve_counts=True)

# 3) build final offset axes (matching Grid3DAcceptanceMapCreator)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I feel like this should be helper function in the base_acceptance_map_creator, if it is used in multiple cases

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It could be added in Grid3DAcceptanceMapCreator since it assumes 2 spatial dimension and the Fit class inherits the Grid3D. I will check and implement your proposal

Comment thread baccmod/fit_acceptance_map_creator.py
Comment thread baccmod/fit_acceptance_map_creator.py Outdated

bin_width_x = np.repeat(extended_offset_axis_x.bin_width[:, np.newaxis], extended_offset_axis_x.nbin, axis=1)
bin_width_y = np.repeat(extended_offset_axis_y.bin_width[np.newaxis, :], extended_offset_axis_y.nbin, axis=0)
solid_angle = 4.0 * (np.sin(bin_width_x / 2) * np.sin(bin_width_y / 2)) * u.steradian

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Do we want to take into account projection effect ?
I would said not mandatory for this PR, but I would leave a comments highlighting this point.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think it makes sense, but this is out of the scope of this PR. Since it also concerns existing functionnality (namely the background normalisation from counts).

Instead of a comment lost in the code I think an issue is better.

@gabemery
gabemery requested a review from MSCarrasco June 15, 2026 13:34

@MSCarrasco MSCarrasco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All good to me, thanks!

@gabemery
gabemery merged commit a41cc3e into spatial_fit_astropy Jun 18, 2026
13 checks passed
@gabemery
gabemery deleted the integration_in_fit branch June 18, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants