[1]:
import nexus as nx
import numpy as np
import matplotlib.pyplot as plt
[2]:
# create ConussObject from kref output file
ang = nx.Var(30e-6, min = 0, max = 100e-6, fit = True, id = "angle")
div = nx.Var(15e-6, min = 0, max = 50e-6, fit = True, id = "divergence")
co = nx.ConussObject(file_name = 'default.rof', angle = ang, divergence = div, id = "my conuss object")
[3]:
# print the object
print(co)
# print additional object information
co.ObjectInfo()
# get single quantity from co.object_info dict
print("\n", co.object_info["energy start"])
ConussObject:
.id: my conuss object
.file_name: default.rof
.angles: [-1.0e-04 -9.8e-05 -9.6e-05 -9.4e-05 -9.2e-05 -9.0e-05 -8.8e-05 -8.6e-05
-8.4e-05 -8.2e-05 -8.0e-05 -7.8e-05 -7.6e-05 -7.4e-05 -7.2e-05 -7.0e-05
-6.8e-05 -6.6e-05 -6.4e-05 -6.2e-05 -6.0e-05 -5.8e-05 -5.6e-05 -5.4e-05
-5.2e-05 -5.0e-05 -4.8e-05 -4.6e-05 -4.4e-05 -4.2e-05 -4.0e-05 -3.8e-05
-3.6e-05 -3.4e-05 -3.2e-05 -3.0e-05 -2.8e-05 -2.6e-05 -2.4e-05 -2.2e-05
-2.0e-05 -1.8e-05 -1.6e-05 -1.4e-05 -1.2e-05 -1.0e-05 -8.0e-06 -6.0e-06
-4.0e-06 -2.0e-06 0.0e+00 2.0e-06 4.0e-06 6.0e-06 8.0e-06 1.0e-05
1.2e-05 1.4e-05 1.6e-05 1.8e-05 2.0e-05 2.2e-05 2.4e-05 2.6e-05
2.8e-05 3.0e-05 3.2e-05 3.4e-05 3.6e-05 3.8e-05 4.0e-05 4.2e-05
4.4e-05 4.6e-05 4.8e-05 5.0e-05 5.2e-05 5.4e-05 5.6e-05 5.8e-05
6.0e-05 6.2e-05 6.4e-05 6.6e-05 6.8e-05 7.0e-05 7.2e-05 7.4e-05
7.6e-05 7.8e-05 8.0e-05 8.2e-05 8.4e-05 8.6e-05 8.8e-05 9.0e-05
9.2e-05 9.4e-05 9.6e-05 9.8e-05 1.0e-04]
.detuning: [-300. -299.85 -299.7 ... 299.7 299.85 300. ]
.angle: Var.value = 3e-05, .min = 0.0, .max = 0.0001, .fit: True, .id: angle
.divergecne: Var.value = 1.5e-05, .min = 0.0, .max = 5e-05, .fit: True, .id: divergence
header : b'calculation ID: [**.00.92-**:00:**] -- project: FeBO3 003 reflection <==57Fe{0.20}B{0.20}O{0.60} '
Miller indices of reflection : (0.0, 0.0, 3.0)
surface normal Bragg : (0.0, 0.0, 1.0)
angle btw surface and netplanes : 0.0
conversion : 10.306486718230305
angle btw surface normal and incident x-ray : 1.6587349200228163
angle btw projection of incident x-ray k_in onto the surface and a reference vector : 1.570796326794896
angle btw surface normal and reflected x-ray : 1.4828577335669766
angle btw projection of reflected x-ray onto the surface and a reference vector : 1.570796326794896
Bragg angle : 0.08793859322791986
energy start : -300.0
energy step : 0.15
energy number of points : 4001
angle minimum : -9.999999999999999e-05
thickness step : 2e-06
angle number of points : 101
crystal thickness : 2.4999999999999998e-05
half lifetime : 9.781000000000001e-08
abundance : 0.95
mode : b'Bragg reflection '
-300.0
[4]:
print(np.array(co.detuning))
print(np.array(co.angles))
[-300. -299.85 -299.7 ... 299.7 299.85 300. ]
[-1.0e-04 -9.8e-05 -9.6e-05 -9.4e-05 -9.2e-05 -9.0e-05 -8.8e-05 -8.6e-05
-8.4e-05 -8.2e-05 -8.0e-05 -7.8e-05 -7.6e-05 -7.4e-05 -7.2e-05 -7.0e-05
-6.8e-05 -6.6e-05 -6.4e-05 -6.2e-05 -6.0e-05 -5.8e-05 -5.6e-05 -5.4e-05
-5.2e-05 -5.0e-05 -4.8e-05 -4.6e-05 -4.4e-05 -4.2e-05 -4.0e-05 -3.8e-05
-3.6e-05 -3.4e-05 -3.2e-05 -3.0e-05 -2.8e-05 -2.6e-05 -2.4e-05 -2.2e-05
-2.0e-05 -1.8e-05 -1.6e-05 -1.4e-05 -1.2e-05 -1.0e-05 -8.0e-06 -6.0e-06
-4.0e-06 -2.0e-06 0.0e+00 2.0e-06 4.0e-06 6.0e-06 8.0e-06 1.0e-05
1.2e-05 1.4e-05 1.6e-05 1.8e-05 2.0e-05 2.2e-05 2.4e-05 2.6e-05
2.8e-05 3.0e-05 3.2e-05 3.4e-05 3.6e-05 3.8e-05 4.0e-05 4.2e-05
4.4e-05 4.6e-05 4.8e-05 5.0e-05 5.2e-05 5.4e-05 5.6e-05 5.8e-05
6.0e-05 6.2e-05 6.4e-05 6.6e-05 6.8e-05 7.0e-05 7.2e-05 7.4e-05
7.6e-05 7.8e-05 8.0e-05 8.2e-05 8.4e-05 8.6e-05 8.8e-05 9.0e-05
9.2e-05 9.4e-05 9.6e-05 9.8e-05 1.0e-04]
[5]:
# angle at index 5
print(co.angles[5])
print(co.ScatteringFactorAtIndex(5))
print(np.squeeze(co.ObjectMatrixAtIndex(5)))
# or obtain an interpolated scattering matrix via
new_detuning = np.linspace(-200, 200, 1001)
print(np.squeeze(co.ObjectMatrixAtIndex(5, detuning=new_detuning)))
-8.999999999999999e-05
0j
[[[ 0.00000000e+00+0.j -3.89954781e-06-0.0003019j ]
[ 3.89954793e-06+0.0003019j 0.00000000e+00+0.j ]]
[[ 0.00000000e+00+0.j -3.90729391e-06-0.00030222j]
[ 3.90729408e-06+0.00030222j 0.00000000e+00+0.j ]]
[[ 0.00000000e+00+0.j -3.91504795e-06-0.00030255j]
[ 3.91504815e-06+0.00030255j 0.00000000e+00+0.j ]]
...
[[ 0.00000000e+00+0.j -4.71370435e-07-0.00030605j]
[ 4.71370625e-07+0.00030605j 0.00000000e+00+0.j ]]
[[ 0.00000000e+00+0.j -4.61300279e-07-0.00030574j]
[ 4.61300464e-07+0.00030574j 0.00000000e+00+0.j ]]
[[ 0.00000000e+00+0.j -4.51258672e-07-0.00030542j]
[ 4.51258864e-07+0.00030542j 0.00000000e+00+0.j ]]]
[[[ 0.00000000e+00+0.j -4.24239541e-06-0.00074025j]
[ 4.24239645e-06+0.00074025j 0.00000000e+00+0.j ]]
[[ 0.00000000e+00+0.j -4.14384502e-06-0.00074362j]
[ 4.14384610e-06+0.00074362j 0.00000000e+00+0.j ]]
[[ 0.00000000e+00+0.j -4.04299638e-06-0.00074702j]
[ 4.04299746e-06+0.00074702j 0.00000000e+00+0.j ]]
...
[[ 0.00000000e+00+0.j -1.70409244e-05-0.00070642j]
[ 1.70409255e-05+0.00070642j 0.00000000e+00+0.j ]]
[[ 0.00000000e+00+0.j -1.69409222e-05-0.00070351j]
[ 1.69409232e-05+0.00070351j 0.00000000e+00+0.j ]]
[[ 0.00000000e+00+0.j -1.68406598e-05-0.00070062j]
[ 1.68406608e-05+0.00070062j 0.00000000e+00+0.j ]]]
[6]:
plt.plot(np.abs(np.array(co.ObjectMatrix())[:,1,0]))
plt.show()
[7]:
co.SetPropertiesAtIndex(2)
print(co.angles[2])
plt.plot(np.abs(np.array(co.ObjectMatrix())[:,1,0]))
plt.show()
-9.599999999999999e-05
[8]:
plt.plot(np.abs(np.array(co.ObjectMatrixAtIndex(10))[:,1,0]))
plt.plot(np.abs(np.array(co.ObjectMatrixAtIndex(10))[:,0,1]))
plt.show()
[9]:
plt.plot(np.angle(np.array(co.ObjectMatrixAtIndex(50))[:,1,0]))
plt.plot(np.angle(np.array(co.ObjectMatrixAtIndex(50))[:,0,1]))
plt.show()
[10]:
co2 = nx.ConussObject(file_name = 'default_last_only.rof', angle = ang, divergence = div, id = "my conuss object")
[11]:
plt.plot(np.array(co.detuning),np.angle(np.array(co.ObjectMatrixAtIndex(100))[:,1,0]))
plt.plot(np.array(co.detuning),np.angle(np.array(co2.ObjectMatrixAtIndex(0))[:,1,0]))
plt.vlines(-7.5, ymin = -3, ymax= 3, color = "r")
plt.show()
[12]:
plt.plot(np.array(co.detuning),np.abs(np.array(co.ObjectMatrixAtIndex(100))[:,1,0]))
plt.plot(np.array(co.detuning),np.abs(np.array(co2.ObjectMatrixAtIndex(0))[:,1,0]))
plt.show()
[13]:
plt.plot(np.array(co.detuning),np.angle(np.array(co.ObjectMatrixAtIndex(100))[:,0,1]))
plt.plot(np.array(co.detuning),np.angle(np.array(co2.ObjectMatrixAtIndex(0))[:,0,1]))
plt.show()