Add back support for fitparam_values arg in public data analysis flux conversion#315
Conversation
There was a problem hiding this comment.
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_valuesplumbing through analysis-level flux conversion helpers. - Allows
MultiDatasetSignalGeneratorto 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 treatTrueasfitparam_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: existingflux2mu(flux_norm, True)calls now pass a boolean asfitparam_valuesinstead of settingper_source=True. Keepper_sourcein the original positional slot or requirefitparam_valuesto 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_recarraykeyword, even whenfitparam_valuesis not provided. Existing customsig_generator_clsimplementations that support the previousfluxmodel_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_recarrayis 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_sourcepositional argument for the MC signal generator. Existingfluxmodel_scaling_factor(True)calls now passTrueassrc_params_recarrayand hit the newNotImplementedErrorinstead of returning per-source factors; keepper_sourcein 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.
| return self._sig_generator.fluxmodel_scaling_factor( | ||
| per_source=per_source, | ||
| src_params_recarray=src_params_recarray, | ||
| ) |
There was a problem hiding this comment.
All existing fluxmodel_scaling_factormethods were updated by this PR
| 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) |
There was a problem hiding this comment.
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>
chiarabellenghi
left a comment
There was a problem hiding this comment.
This is good to go for me
It seems to work as the new
Using fitparam_values with ana should match the reference analysis without fitparam_valuestest passes:skyllh/tests/publicdata_ps/test_time_integrated_ps.py
Line 380 in b56df81