Skip to content

Add back support for fitparam_values arg in public data analysis flux conversion#315

Merged
tomaskontrimas merged 4 commits into
masterfrom
fluxmodel_scaling_factor
May 18, 2026
Merged

Add back support for fitparam_values arg in public data analysis flux conversion#315
tomaskontrimas merged 4 commits into
masterfrom
fluxmodel_scaling_factor

Conversation

@tomaskontrimas
Copy link
Copy Markdown
Collaborator

It seems to work as the new Using fitparam_values with ana should match the reference analysis without fitparam_values test passes:

def test_ana_with_fitparam_values_matches_ana_ref(self):

@tomaskontrimas tomaskontrimas self-assigned this May 14, 2026
Copilot AI review requested due to automatic review settings May 14, 2026 10:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR restores support for evaluating public-data flux conversions at explicit fit-parameter values, especially for gamma-dependent scaling factors.

Changes:

  • Adds fitparam_values plumbing through analysis-level flux conversion helpers.
  • Allows MultiDatasetSignalGenerator to evaluate scaling factors with an explicit source-parameter recarray.
  • Adds regression/integration tests for fit-parameter-based flux conversion and unsupported combinations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
skyllh/core/analysis.py Adds fitparam_values support to scaling, mu2flux, and flux2mu.
skyllh/core/signal_generator.py Adds optional source-parameter recarray support and MC-generator rejection path.
tests/core/test_signal_generator.py Adds unit coverage for the MC-generator src_params_recarray guard.
tests/publicdata_ps/test_time_integrated_ps.py Adds public-data integration tests for fit-parameter flux conversion behavior.
Comments suppressed due to low confidence (5)

skyllh/core/analysis.py:1771

  • This signature reorders the existing second positional argument. Existing code using mu2flux(mu, True) for per-source conversion will now treat True as fitparam_values, so the call no longer returns per-source fluxes and may raise during parameter mapping. Preserve the old positional order or make the new parameter keyword-only.
    def mu2flux(self, mu, fitparam_values=None, per_source=False):

skyllh/core/analysis.py:1792

  • This has the same positional-argument compatibility break as mu2flux: existing flux2mu(flux_norm, True) calls now pass a boolean as fitparam_values instead of setting per_source=True. Keep per_source in the original positional slot or require fitparam_values to be keyword-only.
    def flux2mu(self, flux_norm, fitparam_values=None, per_source=False):

skyllh/core/analysis.py:1769

  • This unconditionally requires every signal generator implementation to accept the new src_params_recarray keyword, even when fitparam_values is not provided. Existing custom sig_generator_cls implementations that support the previous fluxmodel_scaling_factor(per_source=False) interface will now fail on default flux conversions; only pass the new keyword when needed or keep a compatibility path.
        return self._sig_generator.fluxmodel_scaling_factor(
            per_source=per_source,
            src_params_recarray=src_params_recarray,
        )

skyllh/core/signal_generator.py:335

  • When a custom src_params_recarray is provided, this recalculates detector yields at the requested parameters but the later energy-range correction factors remain cached from the reference flux model. For configured energy ranges those factors depend on the spectral parameters, so direct calls to this method can return stale scaling factors even though the analysis-level wrapper rejects that combination.
        src_detsigyield_weights_service.calculate(src_params_recarray=src_params_recarray)

skyllh/core/signal_generator.py:756

  • This also reorders the existing per_source positional argument for the MC signal generator. Existing fluxmodel_scaling_factor(True) calls now pass True as src_params_recarray and hit the new NotImplementedError instead of returning per-source factors; keep per_source in the original positional slot or make the new argument keyword-only.
    def fluxmodel_scaling_factor(self, src_params_recarray=None, per_source=False):

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread skyllh/core/analysis.py
Comment thread skyllh/core/signal_generator.py
Comment thread tests/publicdata_ps/test_time_integrated_ps.py Outdated
Comment thread skyllh/core/analysis.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread skyllh/core/analysis.py
Comment on lines +1782 to +1785
return self._sig_generator.fluxmodel_scaling_factor(
per_source=per_source,
src_params_recarray=src_params_recarray,
)
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.

All existing fluxmodel_scaling_factormethods were updated by this PR

Comment thread skyllh/core/analysis.py Outdated
src_params_recarray = self._src_params_recarray

src_detsigyield_weights_service.calculate(src_params_recarray=self._src_params_recarray)
src_detsigyield_weights_service.calculate(src_params_recarray=src_params_recarray)
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'd say it is fine as it is for now

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@chiarabellenghi chiarabellenghi left a comment

Choose a reason for hiding this comment

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

This is good to go for me

@tomaskontrimas tomaskontrimas merged commit 7da6ce7 into master May 18, 2026
5 checks passed
@tomaskontrimas tomaskontrimas deleted the fluxmodel_scaling_factor branch May 18, 2026 12:42
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.

3 participants