The Utilities Reference
Utility functions for time unit conversion and file I/O.
- class neutronbraggedge.utilities.Utilities[source]
Utilities class
- static convert_time_units(data=None, from_units='micros', to_units='s')[source]
convert the time units
Parameters: * vdata: single data or array of value to convert * from_units: default ‘micros’. Must be either [‘s’,’micros’,’ns’] * to_units: default ‘s’. Must be either [‘s’, ‘micros’, ‘ns’]
- static get_time_conversion_coeff(from_units='micros', to_units='s')[source]
return the coefficient to use to convert from first units to second units
Arguments: * from_units: default ‘micros’. Must be in the list of list_of_time_units * to_units: default ‘s’. Must be in the list of list_of_time_units
Returns: * coefficient to apply to data to convert from first units to second units provided
Raises: * ValueError: if any of the units is not supported
- static array_multiply_coeff(data=None, coeff=1)[source]
multiply each element of the array by the coeff
Parameters: * data: array to apply coefficient on * coeff: default value is 1. Coefficient to apply
Returns: * data * coefficient
- static array_add_coeff(data=None, coeff=1.0)[source]
Add coefficient to each element of the array
Parameters: * data: array to apply coefficient on * coeff: default value is 1. Coefficient to apply
Returns: * data + coefficient
- static array_divide_array(numerator=None, denominator=None)[source]
Divide two arrays of the same size
Parameters: * numerator: numpy array * denominator: numpy array
Returns: * numerator / denominator
Raises: * ValueError if array do not have the same size
- static array_minus_array(array1=None, array2=None)[source]
Substract second array from first array provided
Parameters: * array1: left side of the ‘-’ operator * array2: right side of the ‘-’ operator
Returns: * Array1 - Array2
Raises: * ValueError if arrays do not have the same size
- static load_csv(filename=None)[source]
Load a csv file and return its content
Parameters: * filename: name of the csv file to load
Returns: contents of the file as an array item for each line
Raise: ValueError if format is wrong
- static load_ascii(filename=None, sep='')[source]
Load an ascii file using the separator provided to separete the value in the same row
Parameters: * filename: ascii full file name of file to load * sep: default ‘ ‘. Separator to use to separate values in the same row
Returns: Array of values
Raise: ValueError if file does not exist or format is wrong