APS-USAXS / livedata

live data from the APS USAXS instrument
https://usaxslive.xray.aps.anl.gov/
0 stars 0 forks source link

divide by zero in livedata/handle_2d.py #37

Open prjemian opened 5 years ago

prjemian commented 5 years ago

during specplots processing (related to APS-USAXS/ipython-usaxs#76), this error was reported in the logs but that did not stop further processing -- should examine this rare occurrence further (in case diagnostics can be improved)

(19266) created: /share1/local_livedata/specplots/2018/08/08_13_NIST/s48.png
(19266) created: /share1/local_livedata/specplots/2018/08/08_13_NIST/s51.png
(19266) created: /s/home/beams11/USAXS/Documents/eclipse/USAXS/livedata/handle_2d.py:73: RuntimeWarning: divide by zero encountered in double_scalars
  image_data *= SCALING_FACTOR / image_data.max()
/home/beams11/USAXS/Documents/eclipse/USAXS/livedata/handle_2d.py:73: RuntimeWarning: invalid value encountered in multiply
  image_data *= SCALING_FACTOR / image_data.max()
/APSshare/anaconda/x86_64/lib/python2.7/site-packages/matplotlib/colors.py:941: UserWarning: Warning: converting a masked element to nan.
  vmin = float(vmin)
/APSshare/anaconda/x86_64/lib/python2.7/site-packages/matplotlib/colors.py:942: UserWarning: Warning: converting a masked element to nan.
  vmax = float(vmax)
hare1/local_livedata/specplots/2018/08/08_13_NIST/s54.png
(19266) created: /share1/local_livedata/specplots/2018/08/08_13_NIST/s57.png
(19266) created: /share1/local_livedata/specplots/2018/08/08_13_NIST/s60.png
prjemian commented 5 years ago

Seems peculiar why a divide-by-zero error happens. Here is a summary of the code:

image_data = numpy.ma.masked_less_equal(hdf5["/entry/data/data"].value, 0)
# replace masked data with min good value
image_data = image_data.filled(image_data.min())

At this point, there should be no unmasked zero values in image_data.

Q: What if image_data.max() == 0? Could that be the issue here?

Need to examine with scan 54 from 2018/08/08_13_NIST. Closing this issue does not look like a requirement for 2019-06 operations.