utils module

Helper functions for the analysis of TR-WAXS data.

analysis.utils.common_delay_rescale(data, delay='1ms', ref=0, loss='linear')[source]

Rescale the data sets to minimize the differences on common delay.

Parameters:
  • data (list of dict) – Assumes a list of dictionary output from txs.datared.datared each corresponding to a measurement run with multiple time delays.

  • delay (str, optional) – Delay label to be used. It should present in each data set in data argument. (default, ‘1ms’)

  • ref (int, optional) – Index of a reference data set to be used for rescaling. (default, 0)

  • loss (str, {'linear', 'cauchy', 'soft_l1', 'huber', 'arctan'}) – Loss function to be used for the least-square problem. (default, ‘linear’, standard least-square)

analysis.utils.get_time_delta(data, delay, return_abs=False)[source]

Measurement time of difference patterns for given delay.

Parameters:
  • data (dict) – Assumes a dictionary output from txs.datared.datared.

  • delay (str or int) – Either a string corresponding to the time delay to be used or an integer giving the index of this time delay in the data[‘t’] value.

  • return_abs (bool, optional) – If True, the absolute patterns and errors are also returned for the corresponding measurement time deltas.

analysis.utils.manual_merging_selection(data, labels=None, invert=False)[source]

Group data with common time delays and ask user which are to be kept.

The data are copied and a new list is returned where the unwanted time delays for each sample has been removed.

Parameters:
  • data (list of dict) – Assumes a list of dictionary output from txs.datared.datared each corresponding to a measurement run with multiple time delays.

  • labels (list of str, optional) – The names corresponding to each sample in data for easier identification. (default, None, numbers are used instead of names)

  • invert (bool) – If True, selected data are discarded instead of being kept.

analysis.utils.merge_same_delays(data, max_chi_square=10, cutoff=None, verbose=True)[source]

Average data corresponding to the same time delay.

Parameters:
  • data (list of dict) – Assumes a list of dictionary output from txs.datared.datared each corresponding to a measurement run with multiple time delays.

  • max_chi_square (float, optional) – Maximum value for the chi-square computed between the average of the data and the individual data sets. The chi-square is averaged over matching time delays. Each data set that has a chi-square value bigger that provided argument is discarded. (default, 10)

  • cutoff (float or None, optional) – Time in minute where the data should be cut. The average is computed up to this point for all measurement in data.

  • verbose (bool, optional) – Whether or not report on the number of shots kept for each time delay. (optional, True)

Returns:

  • out_av (2D array) – The averaged difference patterns for each time delay (columns).

  • out_err (2D array) – The standard deviation for each time delay (columns).

  • delays (list of str) – The time delays corresponding to each column in out_av and out_err.

analysis.utils.qrange_rescale(data, qrange=(1.4, 1.5), ref=0, loss='linear')[source]

Rescale the data sets to minimize the differences on a given q-range.

Parameters:
  • data (list of dict) – Assumes a list of dictionary output from txs.datared.datared each corresponding to a measurement run with multiple time delays.

  • qrange (tuple, optional) – Range of q-values to be used. (default, (1.4, 1.5))

  • ref (int, optional) – Index of a reference data set to be used for rescaling. (default, 0)

  • loss (str, {'linear', 'cauchy', 'soft_l1', 'huber', 'arctan'}) – Loss function to be used for the least-square problem. (default, ‘linear’, standard least-square)

analysis.utils.sort_delays(data, ref_delays=None, include_ref=True)[source]

Sort the data according to the time delays

Parameters:
  • data (txs.datared.datared) – A txs.datared.datared instance.

  • ref_delays (list of str) – The delays corresponding to the reference dark measurements.

  • include_ref (bool) – If False, the reference delays given in ref_delays are removed from the data.