diamond_utils

This file contains a suite of utility functions for processing data acquired specifically at Diamond.

Module Contents

Classes

ProcessArgs

a class to hold all information about the processing settings requested, and provide parsing checks, then job submission

Functions

get_im_path

setup_processing

uses process configuration to create an experiment object and setup a logger if requested returns : Experiment, config, logger

create_process_config

creates a simplenamespace configuration settings object

check_folder

check individual scan folders for corrupt .h5 files

check_folder_corruption

check any folders associated with scan

get_good_paths

checks for corrupted .h5 files in scan folder

colour_text

return a colour string to print using chosen colour and string text

data_corruption_warning

give warning in terminal if corrupt scans found

create_experiment

creates an experiment object from process configuration settings

initial_value_checks

does initial checks on dps_centres, cylinder_axis, setup, output_file_size sets oop value returns: oop

setup_dps

adjust dps settings in scan metadata

standard_adjustments

carries out standard adjustments to the Experiment object keeping track of total images, calculating dps offsets, setting skipscans and skipimages, setting up slitratio values

make_mask_lists

takes in specific pixels and mask regions makes sure specific pixels x,y is correct way round for analysis sets up mask Region objects, and corrects region x,y

make_new_hdf5

makes a new hdf5 file using a process_config, scan_index, name and Experiment

run_one_scan_process

creates a hdf5 file and then sends off a process option to run

run_scanlist_loop

iterates through list of scans and runs requested process options

run_scanlist_combined

sends whole list of scans to run requested process together

get_run_function

returns a dict of functions for mapping either static or moving, depending on configuration requested

run_process_list

separate function for sending of jobs defined by process output list and input arguments

run_full_map_process

runs full reciprocal map processing using a process configuration

save_binoviewer_hdf5

Saves the .npy file as a binoviewer-readable hdf5 file.

get_volume_and_bounds

Takes the path to a .npy file. Loads the volume stored in the .npy file, and also grabs the definition of the corresponding finite differences volume from the bounds file.

API

diamond_utils.get_im_path(directorypath: str, scan_number: int, image_number: int = 0)
diamond_utils.setup_processing(exp_setup_file: pathlib.Path, job_file_path: str, scan_numbers: list, debuglogging: bool)

uses process configuration to create an experiment object and setup a logger if requested returns : Experiment, config, logger

diamond_utils.create_process_config(exp_setup_file: pathlib.Path, job_file_path: str, scan_numbers: list, debuglogging: bool)

creates a simplenamespace configuration settings object

diamond_utils.check_folder(folder)

check individual scan folders for corrupt .h5 files

diamond_utils.check_folder_corruption(folderpath: pathlib.Path)

check any folders associated with scan

diamond_utils.get_good_paths(process_config: types.SimpleNamespace)

checks for corrupted .h5 files in scan folder

diamond_utils.colour_text(colour, string)

return a colour string to print using chosen colour and string text

diamond_utils.data_corruption_warning(cfg: types.SimpleNamespace)

give warning in terminal if corrupt scans found

diamond_utils.create_experiment(process_config: types.SimpleNamespace)

creates an experiment object from process configuration settings

diamond_utils.initial_value_checks(dps_centres, cylinder_axis, setup, output_file_size)

does initial checks on dps_centres, cylinder_axis, setup, output_file_size sets oop value returns: oop

diamond_utils.setup_dps(scan, process_config)

adjust dps settings in scan metadata

diamond_utils.standard_adjustments(experiment, process_config)

carries out standard adjustments to the Experiment object keeping track of total images, calculating dps offsets, setting skipscans and skipimages, setting up slitratio values

diamond_utils.make_mask_lists(specific_pixels, mask_regions)

takes in specific pixels and mask regions makes sure specific pixels x,y is correct way round for analysis sets up mask Region objects, and corrects region x,y

diamond_utils.make_new_hdf5(cfg: types.SimpleNamespace, scan_index: int, name_start: str, experiment: fast_rsm.experiment.Experiment)

makes a new hdf5 file using a process_config, scan_index, name and Experiment

diamond_utils.run_one_scan_process(cfg, i, experiment, inputscan, runoptions)

creates a hdf5 file and then sends off a process option to run

diamond_utils.run_scanlist_loop(cfg, experiment, runoptions)

iterates through list of scans and runs requested process options

diamond_utils.run_scanlist_combined(cfg, experiment, runoptions)

sends whole list of scans to run requested process together

diamond_utils.get_run_function(map_per_image)

returns a dict of functions for mapping either static or moving, depending on configuration requested

diamond_utils.run_process_list(experiment, process_config)

separate function for sending of jobs defined by process output list and input arguments

diamond_utils.run_full_map_process(experiment, cfg)

runs full reciprocal map processing using a process configuration

diamond_utils.save_binoviewer_hdf5(output_path: str, process_config: types.SimpleNamespace)

Saves the .npy file as a binoviewer-readable hdf5 file.

diamond_utils.get_volume_and_bounds(path_to_npy: str) Tuple[numpy.ndarray]

Takes the path to a .npy file. Loads the volume stored in the .npy file, and also grabs the definition of the corresponding finite differences volume from the bounds file.

Args:
path_to_npy:

Path to the .npy file containing the volume of interest.

Returns:

A tuple taking the form (volume, start, stop, step), where each element of the tuple is a numpy array of values. The first value returned is the full reciprocal space volume, and could be very large (up to ~GB).

class diamond_utils.ProcessArgs

a class to hold all information about the processing settings requested, and provide parsing checks, then job submission

exp_path: str = None
calc_path: str = None
version_path: str = None
python_version: str = None
scan_nums: list[int] | None = None
scan_range: list[int] | None = None
out_path: str | None = None
debuglogging: bool = 0
local: bool = 0
dev: bool = 0
start_loggers()
parse_setup()
parse_scans()
create_job_name()
create_jobscript()
create_jobfile()
check_slurmfiles()
print_exp_lines()
print_calc_lines()
run_cluster_job()
parse_and_reduce()