integrator.utils module#

class integrator.utils.PeriodicAction(interval, function, args=None, kwargs=None)#

Bases: object

start()#
stop()#
cancel()#
class integrator.utils.PatchLogLevel(prefix, loglevel)#

Bases: ContextDecorator

integrator.utils.make_azims(azim_min, azim_max, nb_slices)#
integrator.utils.parse_poni_file(poni_file)#
integrator.utils.check_poni_file_detector(poni_file, detector, force_replace=False)#

Check a poni file so that the detector is replaced with another (user-provided) detector. This is useful when the detector file name within the poni file does not exist, or cannot be accessed.

Parameters
  • poni_file (str) – Path to the poni file

  • detector (str) – Name or path of the detector used to replace the one in the poni file

  • force_replace (bool, optional) – Whether to use the provided detector even if the one in the poni file can be accessed

integrator.utils.get_h5_config_from_pyfai(pyfai_config, ai_config, dataset)#
integrator.utils.create_output_masterfile(files, output_file, ai_config, do_stack_mean, h5_config, entry='/', process_name='azimuthal integration')#
integrator.utils.browse_virtual_sources(dataset, logger)#
integrator.utils.create_legacy_output_file(result_files, output_fname, integrator_info, data_files, dataset_info, n_azim_slices, h5_toplevel_entry=None)#
integrator.utils.retry_create_masterfile(n_retries, logger)#
integrator.utils.walltime_to_seconds(walltime)#

Converts a “walltime” formated string to a number of seconds.

Parameters

walltime (str) – Walltime, in the form “Hours:Minutes:Seconds”

Returns

secs – Number of seconds corresponding to walltime

Return type

int

Examples

walltime_to_seconds(“02:50:27”) gives 10227

integrator.utils.partition_list(list_, n_sets)#
integrator.utils.files_relative_paths(files, reference_file)#

From a list of (absolute) files paths, return a list of relative paths. Each path is relative to ‘reference_file’.

integrator.utils.get_worker_threads_affinity(n_workers, n_threads_per_worker)#

Given a number of workers (processes) and number of threads per worker, returns the optimal affinity list for each worker.

Note that it likely won’t work properly if the current host is used through a task scheduler(eg. SLURM). In this case, one must ensure that at least one full socket is allocated.

integrator.utils.get_opencl_devices(device_type='gpu', excluded_platform=None)#
integrator.utils.exec_shell_command(cmd)#
integrator.utils.get_number_of_available_gpus(on_error='ignore')#

Get the number of available GPUs.

Parameters

on_error (str, optional) – What to do on error. Can be “ignore”, “print” or “raise”.