Harmonize numpy func usage

This commit is contained in:
usov_i 2020-10-12 15:57:19 +02:00
parent aae4783ef9
commit 4ba228690f

View File

@ -7,6 +7,8 @@ from scipy.optimize import curve_fit
import pyzebra
pir = 180 / np.pi
def z4frgn(wave, ga, nu):
"""CALCULATES DIFFRACTION VECTOR IN LAB SYSTEM FROM GA AND NU
@ -16,15 +18,12 @@ def z4frgn(wave, ga, nu):
Returns:
Z4
"""
sin = np.sin
cos = np.cos
pir = 180 / np.pi
gar = ga / pir
nur = nu / pir
z4 = [0.0, 0.0, 0.0]
z4[0] = (sin(gar) * cos(nur)) / wave
z4[1] = (cos(gar) * cos(nur) - 1.0) / wave
z4[2] = (sin(nur)) / wave
z4[0] = (np.sin(gar) * np.cos(nur)) / wave
z4[1] = (np.cos(gar) * np.cos(nur) - 1.0) / wave
z4[2] = (np.sin(nur)) / wave
return z4
@ -38,14 +37,11 @@ def phimat(phi):
Returns:
DUM
"""
sin = np.sin
cos = np.cos
pir = 180 / np.pi
phr = phi / pir
dum = np.zeros(9).reshape(3, 3)
dum[0, 0] = cos(phr)
dum[0, 1] = sin(phr)
dum[0, 0] = np.cos(phr)
dum[0, 1] = np.sin(phr)
dum[1, 0] = -dum[0, 1]
dum[1, 1] = dum[0, 0]
dum[2, 2] = 1
@ -62,7 +58,6 @@ def z1frnb(wave, ga, nu, om):
Returns:
Z1
"""
z4 = z4frgn(wave, ga, nu)
dum = phimat(phi=om)
dumt = np.transpose(dum)
@ -80,14 +75,11 @@ def chimat(chi):
Returns:
DUM
"""
sin = np.sin
cos = np.cos
pir = 180 / np.pi
chr = chi / pir
dum = np.zeros(9).reshape(3, 3)
dum[0, 0] = cos(chr)
dum[0, 2] = sin(chr)
dum[0, 0] = np.cos(chr)
dum[0, 2] = np.sin(chr)
dum[1, 1] = 1
dum[2, 0] = -dum[0, 2]
dum[2, 2] = dum[0, 0]
@ -104,7 +96,6 @@ def z1frz3(z3, chi, phi):
Returns:
Z1
"""
dum1 = chimat(chi)
dum2 = np.transpose(dum1)
z2 = dum2.dot(z3)
@ -152,7 +143,6 @@ def det2pol(ddist, gammad, nud, x, y):
b = ddist * np.cos(yobs / ddist)
z = ddist * np.sin(yobs / ddist)
d = np.sqrt(a * a + b * b)
pir = 180 / np.pi
gamma = gammad + np.arctan2(a, b) * pir
nu = nud + np.arctan2(z, d) * pir
@ -169,8 +159,6 @@ def eqchph(z1):
Returns:
chi, phi
"""
pir = 180 / np.pi
if z1[0] != 0 or z1[1] != 0:
ph = np.arctan2(z1[1], z1[0])
ph = ph * pir
@ -198,8 +186,6 @@ def dandth(wave, z1):
Returns:
ds, th
"""
pir = 180 / np.pi
ierr = 0
dstar = np.sqrt(z1[0] * z1[0] + z1[1] * z1[1] + z1[2] * z1[2])
@ -257,8 +243,6 @@ def fixdnu(wave, z1, ch2, ph2, nu):
Returns:
tth, om, ch, ph
"""
pir = 180 / np.pi
tth, om, ch, ph, ierr = angs4c(wave, z1, ch2, ph2)
theta = om
if ierr != 0:
@ -312,8 +296,6 @@ def angtohkl(wave, ddist, gammad, om, ch, ph, nud, x, y):
Returns:
"""
pir = 180 / np.pi
# define ub matrix if testing angtohkl(wave=1.18,ddist=616,gammad=48.66,om=-22.80,ch=0,ph=0,nud=0,x=128,y=64) against f90:
# ub = np.array([-0.0178803,-0.0749231,0.0282804,-0.0070082,-0.0368001,-0.0577467,0.1609116,-0.0099281,0.0006274]).reshape(3,3)
ub = np.array(