Skip to content

[AGIPD][FIX] Fix overflow bug on plotting baseline shift if results casted to float16

Egor Sobolev requested to merge fix/agipd-f2-plot-error into master

Description

This fixes overflow issue which happens in case results cast to float16

Traceback
ValueError                                Traceback (most recent call last)
Cell In[41], line 4
2 corrected_ave = np.nansum(corrected, axis=(2, 3))
3 plt.scatter(corrected_ave.flatten()/10**6, blshift.flatten(), s=0.9)
----> 4 plt.xlim(np.nanpercentile(corrected_ave/10**6, [2, 98])) 5 plt.grid()
6 plt.xlabel('Illuminated corrected [MADU] ')
File ~/deployments/development/git.xfel.eu/detectors/pycalibration/current/.venv/lib/ 􏰁→python3.11/site-packages/matplotlib/pyplot.py:1961, in xlim(*args, **kwargs)
1959 if not args and not kwargs:
1960 return ax.get_xlim()
-> 1961 ret = ax.set_xlim(*args, **kwargs)
1962 return ret
File ~/deployments/development/git.xfel.eu/detectors/pycalibration/current/.venv/lib/ 􏰁→python3.11/site-packages/matplotlib/axes/_base.py:3664, in _AxesBase.set_xlim(self,
􏰁→left, 3662 3663 -> 3664
right, emit, auto, xmin, xmax)
raise TypeError("Cannot pass both 'right' and 'xmax'")
right = xmax
return self.xaxis._set_lim(left, right, emit=emit, auto=auto)
File ~/deployments/development/git.xfel.eu/detectors/pycalibration/current/.venv/lib/ 􏰁→python3.11/site-packages/matplotlib/axis.py:1210, in Axis._set_lim(self, v0, v1, 􏰁→emit, auto)
1207 name = self._get_axis_name()
1209 self.axes._process_unit_info([(name, (v0, v1))], convert=False) -> 1210 v0 = self.axes._validate_converted_limits(v0, self.convert_units) 1211 v1 = self.axes._validate_converted_limits(v1, self.convert_units)
1213 if v0 is None or v1 is None:
1214 # Axes init calls set_xlim(0, 1) before get_xlim() can be called,
1215 # so only grab the limits if we really need them.
File ~/deployments/development/git.xfel.eu/detectors/pycalibration/current/.venv/lib/ 􏰁→python3.11/site-packages/matplotlib/axes/_base.py:3585, in _AxesBase._validate_ 􏰁→converted_limits(self, limit, convert)
3582 converted_limit = converted_limit.squeeze() 3583 if (isinstance(converted_limit, Real)
3584 and not np.isfinite(converted_limit)):
-> 3585 raise ValueError("Axis limits cannot be NaN or Inf") 3586 return converted_limit
ValueError: Axis limits cannot be NaN or Inf

How Has This Been Tested?

hotfixed in deployment

Relevant Documents (optional)

SPB_DET_AGIPD1M-1_correct_006880_r0359_241025_112650_413461.pdf

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Reviewers

@ahmedk @schmidtp

Merge request reports