Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Division by zero and zero trigger rates from calculate_trigger_rate application #1136

Open
GernotMaier opened this issue Sep 16, 2024 · 1 comment

Comments

@GernotMaier
Copy link
Contributor

The integration test for calculate_trigger_rate.py defined in calculate_trigger_rate_one_file_save_table.yml passes the tests, but does not give reasonable results (some of the other integration tests for calculate_trigger_rate also have this problems, but not all):

python simtools/applications/calculate_trigger_rate.py --config tests/integration_tests/config/calculate_trigger_rate_one_file_save_table.yml
INFO::calculate_trigger_rate(l181)::main::Calculating simulated and triggered event rate
INFO::base(l61)::__init__::Opening new file ./tests/resources/run201_proton_za20deg_azm0deg_North_test_layout_test-prod.simtel.zst
INFO::base(l94)::__init__::Found zstd compressed file
{'view_cone': <Quantity [0., 0.] deg>, 'solid_angle': <Quantity 0. sr>, 'total_area': <Quantity 1.25663706e+11 cm2>, 'energy_range': <Quantity [3.0e-03, 3.3e+02] TeV>, 'total_num_simulated_events': 2000.0, 'total_num_triggered_events': 1.0}
INFO::simtel_io_histograms(l285)::_rates_for_each_file::Histogram 1:
INFO::simtel_io_histograms(l286)::_rates_for_each_file::Total number of simulated events: 2000.0 events
INFO::simtel_io_histograms(l290)::_rates_for_each_file::Total number of triggered events: 1.0 events
/workdir/external/simtools/simtools/simtel/simtel_io_histogram.py:607: RuntimeWarning: divide by zero encountered in scalar divide
  return (stacked_num_simulated_events / first_estimate) * u.s
INFO::simtel_io_histograms(l298)::_rates_for_each_file::Estimated equivalent observation time corresponding to the number of events simulated: inf s
INFO::simtel_io_histograms(l304)::_rates_for_each_file::Simulated event rate: 0.0000e+00 Hz
INFO::simtel_io_histograms(l310)::_rates_for_each_file::System trigger event rate: 0.0000e+00 ± 0.0000e+00 Hz

File ./tests/resources/run201_proton_za20deg_azm0deg_North_test_layout_test-prod.simtel.zst

System trigger rate (Hz): 0.0000e+00 ± 0.0000e+00 Hz
INFO::calculate_trigger_rate(l205)::main::Writing table 1 to /workdir/external/simtools/simtools-tests/simtools-output/calculate_trigger_rate/application-plots/run201_proton_za20deg_azm0deg_North_test_layout_test-prod.simtel.ecsv

Should at least catch the division by zero in simtel/simtel_io_histogram.py:607.

Maybe worth to add also a check for 'RunTimeWarning's in the output of all integration tests.

@orelgueta
Copy link
Contributor

The reason for the unreasonable result might be resolved by the fixes I am introducing.

However, I agree that the test should include checking for warnings like this and also that the output is reasonable. The latter I will add to the production application now, so the same can be done here. Perhaps it's worth waiting a few days to have an example to follow.

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

No branches or pull requests

2 participants