Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 5 additions & 56 deletions hexrd/core/material/crystallography.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@

# units
dUnit = 'angstrom'
outputDegrees = False
outputDegrees_bak = outputDegrees


def hklToStr(hkl: np.ndarray) -> str:
Expand All @@ -79,39 +77,6 @@ def hklToStr(hkl: np.ndarray) -> str:
return re.sub(r'[\[\]\(\)\{\},]', '', str(hkl))


def tempSetOutputDegrees(val: bool) -> None:
"""
Set the global outputDegrees flag temporarily. Can be reverted with
revertOutputDegrees().

Parameters
----------
val : bool
True to output angles in degrees, False to output angles in radians.

Returns
-------
None

"""
global outputDegrees, outputDegrees_bak
outputDegrees_bak = outputDegrees
outputDegrees = val


def revertOutputDegrees() -> None:
"""
Revert the effect of tempSetOutputDegrees(), resetting the outputDegrees
flag to its previous value (True to output in degrees, False for radians).

Returns
-------
None
"""
global outputDegrees, outputDegrees_bak
outputDegrees = outputDegrees_bak


def cosineXform(
a: np.ndarray, b: np.ndarray, c: np.ndarray
) -> tuple[np.ndarray, np.ndarray]:
Expand Down Expand Up @@ -189,10 +154,6 @@ def latticeParameters(lvec):
gama = np.arccos(np.dot(ahat, bhat))
beta = np.arccos(np.dot(ahat, chat))
alfa = np.arccos(np.dot(bhat, chat))
if outputDegrees:
gama = r2d * gama
beta = r2d * beta
alfa = r2d * alfa

return [a, b, c, alfa, beta, gama]

Expand Down Expand Up @@ -297,8 +258,6 @@ def latticePlanes(
d = 1 / np.sqrt(np.sum(G**2, 0))

aconv = 1.0
if outputDegrees:
aconv = r2d

# two thetas
sth = wlen / 2.0 / d
Expand Down Expand Up @@ -548,12 +507,8 @@ def latticeVectors(

BR = np.c_[afable, bfable, cfable]
U0 = np.dot(B, np.linalg.inv(BR))
if outputDegrees:
dparms = np.r_[ad, bd, cd, r2d * np.r_[alpha, beta, gamma]]
rparms = np.r_[ar, br, cr, r2d * np.r_[alfar, betar, gamar]]
else:
dparms = np.r_[ad, bd, cd, np.r_[alpha, beta, gamma]]
rparms = np.r_[ar, br, cr, np.r_[alfar, betar, gamar]]
dparms = np.r_[ad, bd, cd, np.r_[alpha, beta, gamma]]
rparms = np.r_[ar, br, cr, np.r_[alfar, betar, gamar]]

return {
'F': F,
Expand Down Expand Up @@ -600,8 +555,6 @@ def rhombohedralParametersFromHexagonal(a_h, c_h):
"""
a_r = np.sqrt(3 * a_h**2 + c_h**2) / 3.0
alfa_r = 2 * np.arcsin(3.0 / (2 * np.sqrt(3 + (c_h / a_h) ** 2)))
if outputDegrees:
alfa_r = r2d * alfa_r
return a_r, alfa_r


Expand Down Expand Up @@ -1170,7 +1123,6 @@ def makePlaneData(
List of dictionaries, each containing the data for one hkl
"""

tempSetOutputDegrees(False)
latPlaneData = latticePlanes(
hkls,
lparms,
Expand Down Expand Up @@ -1230,7 +1182,6 @@ def makePlaneData(
)
)

revertOutputDegrees()
return latPlaneData, latVecOps, hklDataList

@property
Expand Down Expand Up @@ -1887,8 +1838,7 @@ def getFriedelPair(tth0, eta0, *ome0, **kwargs):
(i.e. ome1 = <result> + ome0). Output is in DEGREES!

2) eta1 contains the azimuthal coordinates of the Friedel
pairs associated with the n input reflections. Output units are
controlled via the module variable 'outputDegrees'
pairs associated with the n input reflections.

NOTES:

Expand Down Expand Up @@ -2077,9 +2027,8 @@ def getFriedelPair(tth0, eta0, *ome0, **kwargs):
# put eta1 in [-180, 180]
eta1 = mapAngle(r2d * eta_min, [-180, 180], units='degrees')

if not outputDegrees:
ome1 *= d2r
eta1 *= d2r
ome1 *= d2r
eta1 *= d2r

return ome1, eta1

Expand Down
Loading