@@ -624,6 +624,7 @@ def eq_chi(x, y, z, wavelength):
624624def change_sample_orientation (fn ):
625625 """
626626 Decorator to change the sample orientation of numpy equation for grazing-incidence units
627+ Maps x,y arrays to new sample orientation
627628 """
628629 @wraps (fn )
629630 def _wrapped (x , y , z , wavelength , incident_angle , tilt_angle , sample_orientation ):
@@ -896,8 +897,8 @@ def q_lab_beam(
896897# )
897898
898899def eq_qbeam (
899- x , #hpos,
900- y , #vpos,
900+ x ,
901+ y ,
901902 z ,
902903 wavelength = None ,
903904 incident_angle = 0.0 ,
@@ -916,37 +917,23 @@ def eq_qbeam(
916917 :param tilt_angle: tilting of the sample orthogonal to the beam direction (analog to rot3): in radians
917918 :return: component of the scattering vector along the beam propagation direction in inverse nm
918919 """
919- scattering_angle_vertical = eq_exit_angle_vert (
920- x = x , y = y , z = z , wavelength = wavelength ,
921- incident_angle = incident_angle , tilt_angle = tilt_angle ,
922- sample_orientation = sample_orientation ,
923- )
924- scattering_angle_horz = eq_exit_angle_horz (
925- x = x , y = y , z = z , wavelength = wavelength ,
926- incident_angle = incident_angle , tilt_angle = tilt_angle ,
920+ (
921+ qsample_beam ,
922+ qsample_horz ,
923+ qsample_vert ,
924+ ) = q_sample (
925+ x = x ,y = y ,z = z ,
926+ wavelength = wavelength ,
927+ incident_angle = incident_angle ,
928+ tilt_angle = tilt_angle ,
927929 sample_orientation = sample_orientation ,
928930 )
929- return 2.0e-9 * PI / wavelength * (numpy .cos (scattering_angle_vertical ) * numpy .cos (scattering_angle_horz ) - 1.0 )
930- rotation = Rotation .from_euler (
931- seq = "xy" ,
932- angles = [tilt_angle , incident_angle ],
933- degrees = False ,
934- )
935-
936-
937- return numpy .tensordot (
938- numpy .dot (
939- rotation_tilt_angle (tilt_angle = tilt_angle ),
940- rotation_incident_angle (incident_angle = incident_angle ),
941- )[0 , :],
942- q_lab (x = hpos , y = vpos , z = z , wavelength = wavelength ),
943- axes = (0 , 0 ),
944- )
931+ return qsample_beam
945932
946933
947934def eq_qhorz (
948- x , #hpos,
949- y , #vpos,
935+ x ,
936+ y ,
950937 z ,
951938 wavelength = None ,
952939 incident_angle = 0.0 ,
@@ -977,30 +964,6 @@ def eq_qhorz(
977964 sample_orientation = sample_orientation ,
978965 )
979966 return qsample_horz
980-
981-
982-
983- exit_angle_vertical = eq_exit_angle_vert (
984- x = x , y = y , z = z , wavelength = wavelength ,
985- incident_angle = incident_angle , tilt_angle = tilt_angle ,
986- sample_orientation = sample_orientation ,
987- )
988- exit_angle_horz = eq_exit_angle_horz (
989- x = x , y = y , z = z , wavelength = wavelength ,
990- incident_angle = incident_angle , tilt_angle = tilt_angle ,
991- sample_orientation = sample_orientation ,
992- )
993- return 2.0e-9 * PI / wavelength * numpy .cos (exit_angle_vertical ) * numpy .sin (exit_angle_horz )
994-
995-
996- # return numpy.tensordot(
997- # numpy.dot(
998- # rotation_tilt_angle(tilt_angle=tilt_angle),
999- # rotation_incident_angle(incident_angle=incident_angle),
1000- # )[1, :],
1001- # q_lab(x=hpos, y=vpos, z=z, wavelength=wavelength),
1002- # axes=(0, 0),
1003- # )
1004967
1005968
1006969def eq_qvert (
@@ -1024,19 +987,19 @@ def eq_qvert(
1024987 :param tilt_angle: tilting of the sample orthogonal to the beam direction (analog to rot3): in radians
1025988 :return: component of the scattering vector along the vertical direction in inverse nm
1026989 """
1027- exit_angle_vertical = eq_exit_angle_vert (
1028- x = x , y = y , z = z , wavelength = wavelength , sample_orientation = sample_orientation ,
1029- incident_angle = incident_angle , tilt_angle = tilt_angle ,
1030- )
1031- return 2.0e-9 / wavelength * PI * numpy .sin (exit_angle_vertical )
1032- return numpy .tensordot (
1033- numpy .dot (
1034- rotation_tilt_angle (tilt_angle = tilt_angle ),
1035- rotation_incident_angle (incident_angle = incident_angle ),
1036- )[2 , :],
1037- q_lab (x = hpos , y = vpos , z = z , wavelength = wavelength ),
1038- axes = (0 , 0 ),
990+ (
991+ qsample_beam ,
992+ qsample_horz ,
993+ qsample_vert ,
994+ ) = q_sample (
995+ x = x ,y = y ,z = z ,
996+ wavelength = wavelength ,
997+ incident_angle = incident_angle ,
998+ tilt_angle = tilt_angle ,
999+ sample_orientation = sample_orientation ,
10391000 )
1001+ return qsample_vert
1002+
10401003
10411004#@rotate_incident_and_tilt
10421005def q_sample (
@@ -1087,28 +1050,6 @@ def q_sample(
10871050 qsample_horz ,
10881051 qsample_vert ,
10891052 )
1090- # return numpy.stack(
1091- # (
1092- # q_lab_beam(x=hpos, y=vpos, z=z, wavelength=wavelength),
1093- # q_lab_horz(x=hpos, y=vpos, z=z, wavelength=wavelength),
1094- # q_lab_vert(x=hpos, y=vpos, z=z, wavelength=wavelength),
1095- # )
1096- # )
1097-
1098-
1099-
1100-
1101-
1102-
1103- # return numpy.tensordot(
1104- # numpy.dot(
1105- # rotation_tilt_angle(tilt_angle=tilt_angle),
1106- # rotation_incident_angle(incident_angle=incident_angle),
1107- # ),
1108- # q_lab(x=hpos, y=vpos, z=z, wavelength=wavelength),
1109- # axes=(1, 0),
1110- # )
1111-
11121053
11131054# def rotate_sample_orientation(x, y, sample_orientation=1):
11141055# """Rotates/Flips the axis x and y following the EXIF orientation values:
@@ -1257,49 +1198,24 @@ def eq_qip(
12571198 :param int sample_orientation: 1-8, orientation of the fiber axis according to EXIF orientation values (see def rotate_sample_orientation)
12581199 :return: component of the scattering vector in the plane YZ, in inverse nm
12591200 """
1260- # hpos, vpos = rotate_sample_orientation(
1261- # x=x, y=y, sample_orientation=sample_orientation
1262- # )
12631201 q_sample_ = q_sample (
12641202 x = x ,
12651203 y = y ,
12661204 z = z ,
12671205 wavelength = wavelength ,
12681206 incident_angle = incident_angle ,
12691207 tilt_angle = tilt_angle ,
1208+ sample_orientation = sample_orientation ,
12701209 )
12711210 qsample_beam , qsample_horz = q_sample_ [0 ], q_sample_ [1 ]
12721211
12731212 return numpy .sqrt (qsample_beam ** 2 + qsample_horz ** 2 ) * numpy .sign (qsample_horz )
12741213
12751214
1276- def eq_qoop (
1277- x , y , z , wavelength , incident_angle = 0.0 , tilt_angle = 0.0 , sample_orientation = 1
1278- ):
1279- """Calculates the component of the scattering vector in the vertical direction in the sample frame (for GI/Fiber diffraction)
1280- First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,
1281- then rotates again around the horizontal axis using an incident angle value in radians
1282-
1283- :param x: horizontal position, towards the center of the ring, from sample position
1284- :param y: vertical position, to the roof, from sample position
1285- :param z: distance from sample along the beam
1286- :param wavelength: in meter
1287- :param incident_angle: tilting of the sample towards the beam (analog to rot2): in radians
1288- :param tilt_angle: tilting of the sample orthogonal to the beam direction (analog to rot3): in radians
1289- :param int sample_orientation: 1-8, orientation of the fiber axis according to EXIF orientation values (see def rotate_sample_orientation)
1290- :return: component of the scattering vector in the plane YZ, in inverse nm
1291- """
1292- return eq_qvert (
1293- x = x ,
1294- y = y ,
1295- z = z ,
1296- wavelength = wavelength ,
1297- incident_angle = incident_angle ,
1298- tilt_angle = tilt_angle ,
1299- sample_orientation = sample_orientation ,
1300- )
1215+ eq_qoop = eq_qvert
13011216
13021217
1218+ @change_sample_orientation
13031219def eq_q_total (
13041220 x , y , z , wavelength , incident_angle = 0.0 , tilt_angle = 0.0 , sample_orientation = 1
13051221):
@@ -1316,10 +1232,7 @@ def eq_q_total(
13161232 :param int sample_orientation: 1-8, orientation of the fiber axis according to EXIF orientation values (see def rotate_sample_orientation)
13171233 :return: component of the scattering vector in the plane YZ, in inverse nm
13181234 """
1319- hpos , vpos = rotate_sample_orientation (
1320- x = x , y = y , sample_orientation = sample_orientation
1321- )
1322- return 4.0e-9 * PI * numpy .sin (eq_2th (hpos , vpos , z ) / 2.0 ) / wavelength
1235+ return 4.0e-9 * PI * numpy .sin (eq_2th (x = x , y = y , z = z ) / 2.0 ) / wavelength
13231236
13241237
13251238def eq_chi_gi (
0 commit comments