question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash when extracting flux points with a CompoundSpectralModel

See original GitHub issue

Gammapy version v0.19

Bug description If a compound model is used for the FluxPointsEstimator, an error occurs in FluxEstimator.get_scale_model() because a CompoundSpectralModel has no norm or amplitude attribute.

Expected behavior Using a CompoundSpectralModel should work.

The issue is caused by the mechanism introduced to scale the norm according to the input parameter. It does not work in general for a CompoundSpectralModel which might have different amplitude and norm parameters. So that determining the actual range a priori might be ambiguous.

Note that we miss a test for flux points extraction with a compound model.

To Reproduce

from gammapy.modeling.models import EBLAbsorptionNormSpectralModel, PowerLawSpectralModel, SkyModel
from gammapy.estimators.flux import FluxEstimator

pl = PowerLawSpectralModel()
ebl = EBLAbsorptionNormSpectralModel.read_builtin(reference='finke')
model=SkyModel(spectral_model=pl*ebl)

fe = FluxEstimator()
fe.get_scale_model([model])

Other information Any other information you think will be useful for us to fix the issue can go here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
QRemycommented, Mar 9, 2022

In principle the scaled parameter does not have to be one of the existing parameters as it is already defined by the ScaleModel so in the get_scale_model method you pointed we could have :

        scaled_parameter = None
        if "amplitude" in ref_model.parameters.names:
            scaled_parameter = ref_model.parameters["amplitude"]
        elif "norm" in ref_model.parameters.names:
            scaled_parameter = ref_model.parameters["norm"]
        if scaled_parameter is not None:
            scale_model.norm = self._set_norm_parameter(scale_model.norm, scaled_parameter)
0reactions
adonathcommented, May 3, 2022

Users now have to define the is_norm property, when a SpectralModel is used with a SkyModel. See https://github.com/gammapy/gammapy/blob/master/gammapy/modeling/models/cube.py#L75 The example for the custom model was adapted accordingly: https://docs.gammapy.org/dev/tutorials/api/models.html#Implementing-a-custom-model

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't extract energy from Flux Point · Issue #237 - GitHub
Bug. Short description: New energy networks(any combination of interfaces, importers and exporters) stopped working with Flux Point from Flux Networks.
Read more >
Flux Networks not working : r/feedthebeast - Reddit
i have an atm6 to the sky map and i cant use flux networks. the flux point isnt sending energy for the cables...
Read more >
FTB Beyond Flux Networks Crash - Feed the Beast
Details of the issue Game crashes every time I right click on a flux point, specifically in my setup where I have a...
Read more >
Flux Networks Guide - Getting Started & Troubleshooting
The Flux Point is not receiving any energy, but there is energy in the network! Follow the same steps as you would with...
Read more >
Flux Networks! Bit-by-Bit by Mischief of Mice! - YouTube
MischiefOfMice #BitByBit #FluxNetworksFlux Networks! Bit-by-Bit by Mischief of Mice!Want a wireless power network to run all your machines ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found