SINTEF / PySilCam

SINTEF SilCam acquisition, processing and plotting
BSD 3-Clause "New" or "Revised" License
8 stars 1 forks source link

Silcamgui crashes when trying to export a summary figure with no particles #148

Open davidrwilliamson opened 2 years ago

davidrwilliamson commented 2 years ago

Describe the bug If you try to export a summary montage and load a -STATS.csv file that has no particles, you get the following errorL

0it [00:00, ?it/s] /home/dave/PycharmProjects/PySilCam/pysilcam/postprocess.py:124: RuntimeWarning: invalid value encountered in true_divide vd = tpvol / sv # micro-litres / litre /home/dave/PycharmProjects/PySilCam/pysilcam/postprocess.py:140: RuntimeWarning: invalid value encountered in double_scalars nc = np.sum(count) / sv /home/dave/PycharmProjects/PySilCam/pysilcam/postprocess.py:696: RuntimeWarning: invalid value encountered in true_divide nd = np.float64(nd) / sample_volume # nc per size bin per litre /home/dave/PycharmProjects/PySilCam/pysilcam/postprocess.py:701: RuntimeWarning: invalid value encountered in less nd[nd<0] = np.nan # and nan impossible values! /home/dave/PycharmProjects/PySilCam/pysilcam/postprocess.py:198: RuntimeWarning: invalid value encountered in greater ind = np.argwhere(nd>0) Traceback (most recent call last): File "/home/dave/PycharmProjects/PySilCam/pysilcam/silcamgui/silcamgui.py", line 458, in export_summary_figure self.configfile, monitor=False) File "/home/dave/PycharmProjects/PySilCam/pysilcam/plotting.py", line 281, in summarise_fancy_stats settings.PostProcess, oilgas=oilgas) File "/home/dave/PycharmProjects/PySilCam/pysilcam/postprocess.py", line 199, in nc_vc_from_stats nd[ind[0]] = np.nan IndexError: index 0 is out of bounds for axis 0 with size 0

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Pysilcam will quit or freeze after this error.

To Reproduce Use the attached file to try exporting a summary figure from. run_D20210829T100138-STATS.csv

Expected behavior Should probably present a message saying that the loaded stats file has no particles, and continue without crashing.

Additional context Exporting a summary time series works OK and exports an empty time series.

davidrwilliamson commented 2 years ago

Low priority bug, you should rarely load a stats file with no particles. I'll submit a pull request to fix it by adding a 0-length check when I get around to it.

emlynjdavies commented 2 years ago

what would you like the behavior to be in this case? if there are no particles, there is anyway nothing to plot.

a warning message and error catching so you don't have to reload the GUI is smart but what is supposed to happen afterwards?

davidrwilliamson commented 2 years ago

Yes, I think exactly that would be good. It can just warn that there are no particles, not create a plot and return you to the interface so you can continue. I believe it currently creates empty oil and gas plots and then freezes.