refnx.util
- refnx.util.actual_footprint(d1, d2, L12, L2S, angle)[source]
Calculate the actual footprint on a reflectivity sample.
- Parameters
- Returns
(umbra_footprint, penumbra_footprint) – Footprint of the umbra and penumbra
- Return type
- refnx.util.beamfrac(FWHM, length, angle)[source]
Calculate the beam fraction intercepted by a sample.
- refnx.util.beamfrackernel(kernelx, kernely, length, angle)[source]
The beam fraction intercepted by a sample, used for calculating footprints.
- Parameters
- Returns
fraction – The fraction of the beam intercepted by a sample.
- Return type
- refnx.util.div(d1, d2, L12=2859)[source]
Calculate the angular resolution for a set of collimation conditions
- Parameters
- Returns
dtheta, alpha, beta – dtheta is the FWHM of the Gaussian approximation to the trapezoidal resolution function alpha is the angular divergence of the penumbra beta is the angular divergence of the umbra
When calculating dtheta / theta values for resolution, then dtheta is the
value you need to use.
See equations 11-14 in [1]_.
.. [1] de Haan, V.-O.; de Blois, J.; van der Ende, P.; Fredrikze, H.;
van der Graaf, A.; Schipper, M.; van Well, A. A. & J., v. d. Z. ROG, the
neutron reflectometer at IRI Delft Nuclear Instruments and Methods in
Physics Research A, 1995, 362, 434-453
- refnx.util.double_chopper_frequency(min_wavelength, max_wavelength, L, N=1)[source]
Calculates the maximum frequency available for a given wavelength band without getting frame overlap in a chopper spectrometer.
- Parameters
- Returns
max_freq – The maximum frequency a double chopper system can use to avoid frame overlap.
- Return type
- refnx.util.get_scaling_in_overlap(x0, y0, dy0, x1, y1, dy1)[source]
Obtain vertical scaling factor that splices the second dataset onto the first.
- Parameters
x0 (np.ndarray) – abscissae for the first dataset
y0 (np.ndarray) – y values for the first dataset
dy0 (np.ndarray) – dy (standard deviation) values for the first dataset
x1 (np.ndarray) – abscissae values for the second dataset
y1 (np.ndarray) – y values for the second dataset
dy1 (np.ndarray) – dy (standard deviation) values for the second dataset
- Returns
(scale, dscale, overlap_points) – scale and dscale are the scaling and uncertainty in scaling factor. They are np.nan if the abscissae ranges don’t overlap. overlap_points indicates the points in the first dataset that are in the overlap region.
- Return type
- refnx.util.height_of_beam_after_dx(d1, d2, L12, distance)[source]
Calculate the total widths of beam a given distance away from a collimation slit.
if distance >= 0, then it’s taken to be the distance after d2. if distance < 0, then it’s taken to be the distance before d1.
- Parameters
Notes
Units - equivalent distances (inches, mm, light years)
- refnx.util.neutron_transmission(formula, density, wavelength, thickness, xs_type='abs_incoh')[source]
Calculates the transmission of neutrons through a material.
- Parameters
formula (str) – Chemical formula of the material.
density (float) – material density in g/cm^3
wavelength (float, np.ndarray) – wavelength of neutron in Angstrom
thickness (float) – thickness of material in mm
xs_type ({'abs', 'abs_incoh', 'abs_incoh_coh'}) – Cross section to use for penetration depth calculation
- Returns
transmission – transmission of material
- Return type
float or np.ndarray
Notes
The periodictable notes (and the NCNR activation calculator) advise the use of abs_incoh for absorption with respect to the beam.
- refnx.util.penetration_depth(qq, rho)[source]
Calculates the penetration depth of a neutron/xray beam
- refnx.util.q2(omega, twotheta, phi, wavelength)[source]
Convert angles and wavelength (lambda) to Q vector.
- Parameters
- Returns
Qx, Qy, Qz – Momentum transfer.
- Return type
Notes
All angles are assumed to be in degrees.
coordinate system: The beam is incident in the xz plane. x - along beam direction (in small angle approximation) y - transverse to beam direction, in plane of sample z - normal to sample plane.
The xy plane is equivalent to the sample plane.
- refnx.util.refplot(datasets)[source]
Quickly plot a lot of datasets
- Parameters
datasets (iterable) – {str, file, Data1D} specifying the datasets to plot
- Returns
fig – The figure. Use fig.show() to display
- Return type
- refnx.util.resolution_double_chopper(wavelength, z0=0.358, R=0.35, freq=24, H=0.005, xsi=0, L=7.5, tau_da=0)[source]
Calculates the fractional resolution of a double chopper pair, dl/l.
- Parameters
wavelength (float) – wavelength in Angstroms
z0 (float) – distance between chopper pair (m)
R (float) – radius of chopper discs (m)
freq (float) – rotation frequency of choppers (Hz)
N (float) – number of windows in chopper pair
H (float) – height of beam (m)
xsi (float) – phase opening of chopper pair (degrees)
L (float) – Flight length of instrument (m)
tau_da (float) – Width of timebin (s)
- Returns
res – Fractional wavelength resolution of a double chopper system.
- Return type
- refnx.util.resolution_single_chopper(wavelength, R=0.35, freq=24, H=0.005, phi=60, L=7.5)[source]
Calculates the fractional resolution of a single chopper, dl/l.
- Parameters
wavelength (float) – wavelength in Angstroms
R (float) – radius of chopper discs (m)
freq (float) – rotation frequency of choppers (Hz)
N (float) – number of windows in chopper
H (float) – height of beam (m)
phi (float) – angular opening of chopper window (degrees)
L (float) – Flight length of instrument (m)
- Returns
transmission – Transmission of a single chopper system.
- Return type
- refnx.util.slit_optimiser(footprint, resolution, angle=1.0, L12=2859.5, L2S=180, LS3=290.5, LSD=2500, verbose=True)[source]
Optimise slit settings for a given angular resolution, and a given footprint.
- footprint: float
maximum footprint onto sample (mm)
- resolution: float
fractional dtheta/theta resolution (FWHM)
- angle: float, optional
angle of incidence in degrees
- refnx.util.tauC(wavelength, xsi=0, z0=0.358, freq=24)[source]
Calculates the burst time of a double chopper pair
- Parameters
- Returns
tauC – The burst time of a double chopper pair (s)
- Return type
References
[1] A. A. van Well and H. Fredrikze, On the resolution and intensity of a time-of-flight neutron reflectometer, Physica B 357 (2005) 204-207 [2] A. Nelson and C. Dewhurst, Towards a detailed resolution smearing kernel for time-of-flight neutron reflectometers, J. Appl. Cryst. (2013) 46, 1338-1343
- refnx.util.transmission_double_chopper(wavelength, z0=0.358, R=0.35, freq=24, N=1, H=0.005, xsi=0)[source]
Calculates the transmission of a double chopper pair
- Parameters
wavelength (float) – wavelength in Angstroms
z0 (float) – distance between chopper pair (m)
R (float) – radius of chopper discs (m)
freq (float) – rotation frequency of choppers (Hz)
N (float) – number of windows in chopper pair
H (float) – height of beam (m)
xsi (float) – phase opening of chopper pair (degrees)
- Returns
transmission – The transmission of a double chopper system.
- Return type
References
[1] A. A. van Well and H. Fredrikze, On the resolution and intensity of a time-of-flight neutron reflectometer, Physica B 357 (2005) 204-207 [2] A. Nelson and C. Dewhurst, Towards a detailed resolution smearing kernel for time-of-flight neutron reflectometers, J. Appl. Cryst. (2013) 46, 1338-1343
- refnx.util.transmission_single_chopper(R=0.35, phi=60, N=1, H=0.005)[source]
Calculates the transmission of a single chopper
- Parameters
References
[1] A. A. van Well and H. Fredrikze, On the resolution and intensity of a time-of-flight neutron reflectometer, Physica B 357 (2005) 204-207 [2] A. Nelson and C. Dewhurst, Towards a detailed resolution smearing kernel for time-of-flight neutron reflectometers, J. Appl. Cryst. (2013) 46, 1338-1343