cta-observatory / pyirf

Python IRF builder
https://pyirf.readthedocs.io/en/stable/
MIT License
15 stars 25 forks source link

attribute renamed in SimulatedEventsInfo but not in PowerLaw.from_simulation #257

Closed kosack closed 1 year ago

kosack commented 1 year ago
simualtion_info = SimulatedEventsInfo(
    n_showers=shower_distribution["histogram"].sum(),
    energy_min=simulation_config["energy_range_min"][0],
    energy_max=simulation_config["energy_range_max"][0],
    max_impact=simulation_config["max_scatter_range"][0],
    spectral_index=simulation_config["spectral_index"][0],
    viewcone_min=simulation_config["min_viewcone_radius"][0],
    viewcone_max=simulation_config["max_viewcone_radius"][0],
)

spectral.PowerLaw.from_simulation(simulation_info, obstime=obstime)
    117 index = simulated_event_info.spectral_index
    118 n_showers = simulated_event_info.n_showers
--> 119 viewcone = simulated_event_info.viewcone
    121 if viewcone.value > 0:
    122     solid_angle = 2 * np.pi * (1 - np.cos(viewcone)) * u.sr

AttributeError: 'SimulatedEventsInfo' object has no attribute 'viewcone'

Should use the new viewcone_min and viewcone_max attributes.

maxnoe commented 1 year ago

Huh... that means that this part is not covered by tests. How embarrassing...

kosack commented 1 year ago

The class is immutable with __slots__ as well, so i can't even fake it!

kosack commented 1 year ago

By the way, might as well make it a dataclass (if you don't have to support pre python 3.7)