Vs Q

This example converts the angular axes of a SphericalDetector GISAS result to the $q_y,q_z$ axes used for reciprocal-space plots. The transformation changes only the axis coordinates: it converts each bin edge, preserves the intensity bin order and does not rebin or interpolate the detector map.

The conversion uses the beam wavelength and incident angle. For API details and its limitations away from the central axes, see Axis coordinates and transformations.

Result

Vs Q result

Sample

Vs Q sample

Python script

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
"""
In this example we demonstrate how to plot a simulation result with
axes in q_y and q_z.
"""
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
from bornagain import deg, nm


def get_sample():
    # Materials
    air_color = (0.90, 0.93, 0.97)
    air_mat = ba.RefractiveMaterial("Air", air_color, 0, 0)
    particle_color = (0.86, 0.24, 0.18)
    particle_mat = ba.RefractiveMaterial("Particle", particle_color, 6e-5, 2e-08)
    substrate_color = (0.28, 0.57, 0.82)
    substrate_mat = ba.RefractiveMaterial("Substrate", substrate_color, 6e-06, 2e-08)

    # Particles
    R = 2.5*nm
    ff = ba.Spheroid(R, R)
    particle = ba.Particle(particle_mat, ff)

    # Interference function
    lattice = ba.SquareLattice2D(10*nm, 2*deg)
    layout = ba.Crystal2D(particle, lattice)
    pdf = ba.Profile2DCauchy(50*nm, 50*nm, 0)
    layout.setDecayFunction(pdf)

    # Layers
    l_air = ba.Layer(air_mat)
    l_air.deposit2D(layout)
    l_substrate = ba.Layer(substrate_mat)

    # Sample
    sample = ba.Sample()
    sample.addLayer(l_air)
    sample.addLayer(l_substrate)
    return sample


def get_simulation(sample, wavelength, alpha_i):
    beam = ba.Beam(1e9, wavelength, alpha_i)
    n = 200
    detector = ba.SphericalDetector(n, -1*deg, 1*deg, n, 0, 1*deg)
    simulation = ba.ScatteringSimulation(beam, sample, detector)
    return simulation

if __name__ == '__main__':
    sample = get_sample()
    wavelength = 0.04*nm
    alpha_i = 0.2*deg
    simulation = get_simulation(sample, wavelength, alpha_i)
    result = simulation.simulate()

    trafo = ba.FrameTrafo.ScatteringToQ(wavelength, alpha_i)
    res2 = trafo.transformedDatafield(result)
    ba.showSample3D(sample, sample_size=100*nm, seed=0)

    ba.plot_datafield(res2, unit_aspect=1)
    ba.plt.show()
auto/Examples/gisas/methods/VsQ.py