The Experiment Handler Reference

class neutronbraggedge.experiment_handler.experiment.Experiment(tof=None, lambda_array=None, distance_source_detector_m=None, detector_offset_micros=None)[source]

Class that allows: - convert the TOF scale into Lambda - distance source - detector - detector time offset

Arguments: * tof: tof array in s * lambda_array: mandatory only if detector_offset or distance_source_detector are unknown * distance_source_detector: mandatory only if lambda is the unknown parameter (m) * detector_offset: mandatory only if lambda is the unknown parameter (micros)

Parameters:
__init__(tof=None, lambda_array=None, distance_source_detector_m=None, detector_offset_micros=None)[source]
Parameters:
  • tof (ArrayLike | None)

  • lambda_array (ArrayLike | None)

  • distance_source_detector_m (float | None)

  • detector_offset_micros (float | None)

Return type:

None

tof_array: ndarray[tuple[Any, ...], dtype[floating]]
distance_source_detector: float | None
detector_offset_micros: float | None
lambda_array: ndarray[tuple[Any, ...], dtype[floating]] | None
calculate_tof_with_detector_offset()[source]

return the tof with detector_offset applied to it

Return type:

ndarray[tuple[Any, …], dtype[floating]]

calculate_distance_source_detector()[source]

return the distance source detector

If lambda_array and tof_array are provided, the distance is calculated Otherwise, the distance_source_detector must be provided

Return type:

None

calculate_detector_offset()[source]

return the detector time offset value

If lambda_array and tof_array are provided, the offset is calculated Otherwise, the detector_offset argument must be provided

Return type:

None

calculate_lambda()[source]

return the lambda array when tof_array, distance_source_detector and detector_offset are provided

Return type:

None

export_lambda(filename=None)[source]

export the lambda array into a CSV data file

Parameters: * filename: name of output file to create

Parameters:

filename (str | None)

Return type:

None

class neutronbraggedge.experiment_handler.tof.TOF(filename=None, tof_array=None, units='s')[source]

This class handles the loading of the TOF and the automatic conversion to ‘s’

Parameters:
counts_array: ndarray[tuple[Any, ...], dtype[floating]]
__init__(filename=None, tof_array=None, units='s')[source]

Constructor of the TOF class

Arguments: * filename: optional input file name. If file exist, data will be automatically loaded (only CSV file is supported so far)

example: file_tof.txt

#first row of the file 1.0 34 2.2 31 3.4 5 4.5 10 5.6 22 …

or #first column, second column

1.0,34 2.2,31 3.4,5 4.5,10 5.6,22 …

  • tof_array: optional tof array. This argument will be ignored if filename is not None

  • units: optional units of the input tof array (default to ‘seconds’)

Raises: * ValueError: - input file provided as the wrong format

  • neither input file and tof_array are provided

  • IOError: - file does not exist

Parameters:
  • filename (str | None)

  • tof_array (ArrayLike | None)

  • units (Literal['s', 'ms', 'micros', 'ns'])

Return type:

None

filename: str
tof_array: ndarray[tuple[Any, ...], dtype[floating]]
load_data()[source]

Load the data from the filename name provided

Return type:

None

class neutronbraggedge.experiment_handler.lambda_wavelength.LambdaWavelength(filename=None, data=None)[source]

This class handles the loading of the Lambda

Parameters:
  • filename (str)

  • data (ArrayLike | None)

__init__(filename=None, data=None)[source]

Constructor of the LambdaWavelength class

Arguments: * filename: optional input file name if data array is provided If file exist, data will be automatically loaded (only CSV file is supported so far)

example: file_lambda.txt

#first row of the file 1. 2. 3. 4. 5.

  • data: optional if filename name provided. Array of lambda

Raises: * ValueError: - input file provided as the wrong format

  • neither input file and tof_array are provided

  • IOError: - file does not exist

Parameters:
  • filename (str | None)

  • data (ArrayLike | None)

Return type:

None

filename: str
lambda_array: ndarray[tuple[Any, ...], dtype[floating]] | list[float]
load_data()[source]

Load the data from the filename name provided

Return type:

None