-
Notifications
You must be signed in to change notification settings - Fork 1
Description
After updating my python environment I noticed that orGUI is not showing correct H K L del gam values under the central plot anymore. Instead of numbers, the displayed value is ERROR for all five entries. I figured that the latest Numpy update to version 2.4 is causing this:
Expired deprecations
Raise TypeError on attempt to convert array with ndim > 0 to scalar
Conversion of an array with ndim > 0 to a scalar was deprecated in NumPy 1.25. Now, attempting to do so raises TypeError. Ensure you extract a single element from your array before performing this operation.
The xyToHKL() function in orGUI.py is used to calculate HKL from the coordinates and seems to yield erroneous values.
def xyToHKL(x,y):
#print("xytoHKL:")
#print("x,y = %s, %s" % (x,y))
if self.fscan is None:
return np.array([np.nan,np.nan,np.nan, np.nan, np.nan])
mu, om = self.getMuOm(self.imageno)
gamma, delta = self.ubcalc.detectorCal.surfaceAnglesPoint(np.array([y]),np.array([x]), mu)
#print(self.ubcalc.detectorCal)
#print(x,y)
#print(self.ubcalc.detectorCal.tth(np.array([y]),np.array([x])))
pos = [mu,delta[0],gamma[0],om,self.ubcalc.chi,self.ubcalc.phi]
pos = HKLVlieg.crystalAngles(pos,self.ubcalc.n)
hkl = np.concatenate((np.array(self.ubcalc.angles.anglesToHkl(*pos)),np.rad2deg([delta[0],gamma[0]])))
return hkl
return xyToHKL
The actual calculation is performed in HKLVlieg.py which is called via self.ubcalc.angles.anglesToHkl(*pos). In case of phi.size=chi.size=omega.size=1, a matrix called PCO is first created and then filled element-wise:
PCO = np.empty((3, 3), dtype=np.float64)
PCO[0,0] = coschi*cosomega
PCO[0,1] = -sinomega*coschi
PCO[0,2] = -sinchi
PCO[1,0] = sinchi*sinphi*cosomega + sinomega*cosphi
PCO[1,1] = -sinchi*sinomega*sinphi + cosomega*cosphi
PCO[1,2] = sinphi*coschi[0]
PCO[2,0] = sinchi*cosomega*cosphi - sinomega*sinphi
PCO[2,1] = -sinchi*sinomega*cosphi - sinphi*cosomega
PCO[2,2] = coschi*cosphi
This fails with Numpy 2.4 as all sin___ and cos___ objects are arrays and not scalars. Reproduction a MWE of the error with Numpy 2.3 gives the following deprecation warning:
