Event based reduction for the Liquids Reflectometer

EventReflectivity

Data reduction for the Liquids Reflectometer. List of items to be taken care of outside this class:

  • Edge points cropping
  • Angle offset
  • Putting runs together in one R(q) curve
  • Scaling factors

Pixel ranges include the min and max pixels.

Parameters:
  • scattering_workspace

    Mantid workspace containing the reflected data

  • direct_workspace

    Mantid workspace containing the direct beam data [if None, normalization won't be applied]

  • signal_peak (list) –

    Pixel min and max for the specular peak

  • signal_bck (list) –

    Pixel range of the background [if None, the background won't be subtracted]

  • norm_peak (list) –

    Pixel range of the direct beam peak

  • norm_bck (list) –

    Direct background subtraction is not used [deprecated]

  • specular_pixel (float) –

    Pixel of the specular peak

  • signal_low_res (list) –

    Pixel range of the specular peak out of the scattering plane

  • norm_low_res (list) –

    Pixel range of the direct beam out of the scattering plane

  • q_min (float, default: None ) –

    Value of lowest q point

  • q_step (float, default: -0.02 ) –

    Step size in Q. Enter a negative value to get a log scale

  • q_min (float, default: None ) –

    Value of largest q point

  • tof_range ((list, None), default: None ) –

    TOF range,or None

  • theta (float, default: 1.0 ) –

    Theta scattering angle in radians

  • dead_time (float, default: False ) –

    If not zero, dead time correction will be used

  • paralyzable (bool, default: True ) –

    If True, the dead time calculation will use the paralyzable approach

  • dead_time_value (float, default: 4.2 ) –

    value of the dead time in microsecond

  • dead_time_tof_step (float, default: 100 ) –

    TOF bin size in microsecond

  • use_emmission_time (bool) –

    If True, the emission time delay will be computed

__repr__

Generate a string representation of the reduction settings.

Returns:
  • str

    String representation of the reduction settings

bck_subtraction

Perform background subtraction on the signal. This method provides a higher-level call for background subtraction, hiding the ranges needed to define the Region of Interest (ROI).

Parameters:
  • normalize_to_single_pixel (bool, default: False ) –

    If True, normalize the background to a single pixel.

  • q_bins

    array of bins for the momentum transfer (q) values.

  • wl_dist

    Array of wavelength (wl) values.

  • wl_bins

    Array of bins for the wavelength (wl) values.

  • q_summing (bool, default: False ) –

    If True, sum the q values.

Returns:
  • Workspace

    The workspace with the background subtracted.

emission_time_correction

Coorect TOF for emission time delay in the moderator.

Parameters:
  • ws (Workspace) –

    Mantid workspace to extract correction meta-data from

  • tofs (ndarray) –

    Array of uncorrected TOF values

Returns:
  • ndarray

    Array of corrected TOF values

extract_meta_data

Extract meta data from the loaded data file.

extract_meta_data_4A

4A-specific meta data

extract_meta_data_4B

4B-specific meta data

Distance from source to sample was 13.63 meters prior to the source to detector distance being determined with Bragg edges to be 15.75 m.

gravity_correction

Gravity correction for each event

Parameters:
  • ws (Workspace) –

    Mantid workspace to extract correction meta-data from.

  • wl_list (ndarray) –

    Array of wavelengths for each event.

Returns:
  • ndarray

    Array of gravity-corrected theta values for each event, in radians.

norm_bck_subtraction

Higher-level call for background subtraction for the normalization run.

off_specular

Compute off-specular

Parameters:
  • x_axis (int, default: None ) –

    Axis selection from QX_VS_QZ, KZI_VS_KZF, DELTA_KZ_VS_QZ

  • x_min (float, default: -0.015 ) –

    Min value on x-axis

  • x_max (float, default: 0.015 ) –

    Max value on x-axis

  • x_npts (int, default: 50 ) –

    Number of points in x (negative will produce a log scale)

  • z_min (float, default: None ) –

    Min value on z-axis (if none, default Qz will be used)

  • z_max (float, default: None ) –

    Max value on z-axis (if none, default Qz will be used)

  • z_npts (int, default: -120 ) –

    Number of points in z (negative will produce a log scale)

slice

Retrieve a slice from the off-specular data.

specular

Compute specular reflectivity.

For constant-Q binning, it's preferred to use tof_weighted=True.

Parameters:
  • q_summing (bool, default: False ) –

    Turns on constant-Q binning

  • tof_weighted (bool, default: False ) –

    If True, binning will be done by weighting each event to the DB distribution

  • bck_in_q (bool, default: False ) –

    If True, the background will be estimated in Q space using the constant-Q binning approach

  • clean (bool, default: False ) –

    If True, and Q summing is True, then leading artifact will be removed

  • normalize (bool, default: True ) –

    If True, and tof_weighted is False, normalization will be skipped

Returns:
  • q_bins

    The Q bin boundaries

  • refl

    The reflectivity values

  • d_refl

    The uncertainties in the reflectivity values

specular_unweighted

Simple specular reflectivity calculation. This is the same approach as the original LR reduction, which sums up pixels without constant-Q binning. The original approach bins in TOF, then rebins the final results after transformation to Q. This approach bins directly to Q.

Parameters:
  • q_summing (bool, default: False ) –

    If True, sum the data in Q-space.

  • normalize (bool, default: True ) –

    If True, normalize the reflectivity by the direct beam.

Returns:
  • q_bins

    The Q bin boundaries

  • refl

    The reflectivity values

  • d_refl

    The uncertainties in the reflectivity values

specular_weighted

Compute reflectivity by weighting each event by flux. This allows for summing in Q and to estimate the background in either Q or pixels next to the peak.

Parameters:
  • q_summing (bool, default: True ) –

    If True, sum the data in Q-space.

  • bck_in_q (bool, default: False ) –

    If True, subtract background along Q lines.

Returns:
  • q_bins

    The Q bin boundaries

  • refl

    The reflectivity values

  • d_refl

    The uncertainties in the reflectivity values

to_dict

Returns meta-data to be used/stored.

Returns:
  • dict

    Dictionary with meta-data

apply_dead_time_correction

Apply dead time correction, and ensure that it is done only once per workspace.

Parameters:
  • ws

    Workspace with raw data to compute correction for

  • template_data (ReductionParameters) –

    Reduction parameters

Returns:
  • Workspace

    Workspace with dead time correction applied

compute_resolution

Compute the Q resolution from the meta data.

Parameters:
  • ws (Workspace) –

    Mantid workspace to extract correction meta-data from.

  • theta (float, default: None ) –

    Scattering angle in radians

  • q_summing (bool, default: False ) –

    If True, the pixel size will be used for the resolution

Returns:
  • float

    The dQ/Q resolution (FWHM)

get_attenuation_info

Retrieve information about attenuation from a Mantid workspace. This function calculates the total thickness of all attenuators that are in the path of the beam by summing up the thicknesses of the attenuators specified in the global variable CD_ATTENUATORS.

Parameters:
  • ws

    Mantid workspace from which to retrieve the attenuation information.

Returns:
  • float

    The total thickness of the attenuators in the path of the beam.

get_dead_time_correction

Compute dead time correction to be applied to the reflectivity curve. The method will also try to load the error events from each of the data files to ensure that we properly estimate the dead time correction.

Parameters:
  • ws

    Workspace with raw data to compute correction for

  • template_data (ReductionParameters) –

    Reduction parameters

Returns:
  • Workspace

    Workspace with dead time correction to apply

get_q_binning

Determine Q binning.

This function calculates the binning for Q values based on the provided minimum, maximum, and step values. If the step value is positive, it generates a linear binning. If the step value is negative, it generates a logarithmic binning.

Parameters:
  • q_min (float, default: 0.001 ) –

    The minimum Q value.

  • q_max (float, default: 0.15 ) –

    The maximum Q value.

  • q_step (float, default: -0.02 ) –

    The step size for Q binning. If positive, linear binning is used. If negative, logarithmic binning is used.

Returns:
  • ndarray

    A numpy array of Q values based on the specified binning.

get_wl_range

Determine TOF range from the data

Parameters:
  • ws

    Mantid workspace to work with

Returns:
  • list

    [min, max] wavelength range

process_attenuation

Correct for absorption by assigning weight to each neutron event

Parameters:
  • ws

    Mantid workspace to correct

  • thickness

    Attenuator thickness in cm (default is 0).

Returns:
  • Mantid workspace

    Corrected Mantid workspace

read_settings

Read settings file and return values for the given timestamp

Parameters:
  • ws

    Mantid workspace

Returns:
  • dict

    Dictionary with settings