NuSpaceSim / nuSpaceSim

The main simulator repository for nuSpaceSim
BSD 3-Clause Clear License
11 stars 1 forks source link

show-plot crashes #72

Closed jfkrizmanic closed 1 year ago

jfkrizmanic commented 1 year ago

[gs66-psiphi-new:SoftWareBetaTests/nuSpaceSim1.3.1/poemma360-7deg] jkrizman% nuspacesim show-plot --plotall nuspacesim_run_20230502024626.fits Traceback (most recent call last): File "/Users/jkrizman/miniforge3/bin/nuspacesim", line 8, in sys.exit(cli()) File "/Users/jkrizman/miniforge3/lib/python3.10/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/Users/jkrizman/miniforge3/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/Users/jkrizman/miniforge3/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/jkrizman/miniforge3/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/jkrizman/miniforge3/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(args, kwargs) File "/Users/jkrizman/Desktop/Work in Progress/nuSpaceSim/SoftWareBetaTests/nuSpaceSim1.3.1/nuSpaceSim/src/nuspacesim/apps/cli.py", line 323, in show_plot simulation.taus.taus.show_plot(sim, plot) File "/Users/jkrizman/Desktop/Work in Progress/nuSpaceSim/SoftWareBetaTests/nuSpaceSim1.3.1/nuSpaceSim/src/nuspacesim/simulation/taus/taus.py", line 187, in show_plot decorators.nss_result_plot_from_file(sim, inputs, outputs, plotfs, plot) File "/Users/jkrizman/Desktop/Work in Progress/nuSpaceSim/SoftWareBetaTests/nuSpaceSim1.3.1/nuSpaceSim/src/nuspacesim/utils/decorators.py", line 230, in nss_result_plot_from_file f(None, f_input, plot=plot) File "/Users/jkrizman/Desktop/Work in Progress/nuSpaceSim/SoftWareBetaTests/nuSpaceSim1.3.1/nuSpaceSim/src/nuspacesim/utils/decorators.py", line 210, in wrapper_f plotf(args, values) File "/Users/jkrizman/Desktop/Work in Progress/nuSpaceSim/SoftWareBetaTests/nuSpaceSim1.3.1/nuSpaceSim/src/nuspacesim/simulation/taus/local_plots.py", line 198, in taus_overview ax[1, 0].errorbar( File "/Users/jkrizman/miniforge3/lib/python3.10/site-packages/matplotlib/init.py", line 1442, in inner return func(ax, map(sanitize_sequence, args), kwargs) File "/Users/jkrizman/miniforge3/lib/python3.10/site-packages/matplotlib/axes/_axes.py", line 3642, in errorbar raise ValueError( ValueError: 'xerr' must not contain negative values

Areustle commented 1 year ago

The --plotall flag correctly triggers all of the plot functions to display. One of those functions - taus_overview - had a bug where a subplot was getting invalid parameters. Specifically the tau profile generated by get_profile returned a set of histogram parameters with negative bin widths.

To fix the issue the function now returns the absolute value of bin width, which was defined as np.abs(bincenter - edges[1:])

It may have been more correct to instead return bincenter - edges[:1], though I suspect the two are equivalent.