hexrd.grainmap.nfutil module
Refactor of simulate_nf so that an experiment is mocked up.
Also trying to minimize imports
- class hexrd.grainmap.nfutil.ProcessController(result_handler=None, progress_observer=None, ncpus=1, chunk_size=100)[source]
Bases:
object
This is a ‘controller’ that provides the necessary hooks to track the results of the process as well as to provide clues of the progress of the process
- hexrd.grainmap.nfutil.build_controller(check=None, generate=None, ncpus=2, chunk_size=10, limit=None)[source]
- hexrd.grainmap.nfutil.checking_result_handler(filename)[source]
returns a return handler that checks the results against a reference file.
The Check will consider a FAIL either a result not present in the reference file (saved as a numpy savez or savez_compressed) or a result that differs. It will consider a PARTIAL PASS if the reference file has a shorter result, but the existing results match. A FULL PASS will happen when all existing results match
- hexrd.grainmap.nfutil.evaluate_diffraction_angles(experiment, controller=None)[source]
Uses simulateGVecs to generate the angles used per each grain. returns a list containg one array per grain.
- experiment – a bag of experiment values, including the grains specs
and other required parameters.
- hexrd.grainmap.nfutil.gen_nf_cleaned_image_stack(data_folder, img_nums, dark, nrows, ncols, process_type='gaussian', process_args=[4.5, 5], threshold=1.5, ome_dilation_iter=1, stem='nf_', num_digits=5, ext='.tif')[source]
- hexrd.grainmap.nfutil.gen_nf_dark(data_folder, img_nums, num_for_dark, nrows, ncols, dark_type='median', stem='nf_', num_digits=5, ext='.tif')[source]
- hexrd.grainmap.nfutil.gen_trial_exp_data(grain_out_file, det_file, mat_file, mat_name, max_tth, comp_thresh, chi2_thresh, misorientation_bnd, misorientation_spacing, ome_range_deg, nframes, beam_stop_parms)[source]
- hexrd.grainmap.nfutil.generate_test_grid(low, top, samples)[source]
generates a test grid of coordinates
- hexrd.grainmap.nfutil.get_dilated_image_stack(image_stack, experiment, controller, cache_file='gold_cubes_dilated.npy')[source]
- hexrd.grainmap.nfutil.get_simulate_diffractions(grain_params, experiment, cache_file='gold_cubes.npy', controller=None)[source]
getter functions that handles the caching of the simulation
- hexrd.grainmap.nfutil.grand_loop_pool(ncpus, state)[source]
function that handles the initialization of multiprocessing. It handles properly the use of spawned vs forked multiprocessing. The multiprocessing can be either ‘fork’ or ‘spawn’, with ‘spawn’ being required in non-fork platforms (like Windows) and ‘fork’ being preferred on fork platforms due to its efficiency.
- hexrd.grainmap.nfutil.multiproc_inner_loop(chunk)[source]
function to use in multiprocessing that computes the simulation over the task’s alloted chunk of data
- hexrd.grainmap.nfutil.output_grain_map(data_location, data_stems, output_stem, vol_spacing, top_down=True, save_type=['npz'])[source]
- hexrd.grainmap.nfutil.plot_ori_map(grain_map, confidence_map, exp_maps, layer_no, mat, id_remap=None)[source]
- hexrd.grainmap.nfutil.process_raw_confidence(raw_confidence, vol_shape=None, id_remap=None, min_thresh=0.0)[source]
- hexrd.grainmap.nfutil.save_nf_data(save_dir, save_stem, grain_map, confidence_map, Xs, Ys, Zs, ori_list, id_remap=None)[source]
- hexrd.grainmap.nfutil.save_raw_confidence(save_dir, save_stem, raw_confidence, id_remap=None)[source]
- hexrd.grainmap.nfutil.saving_result_handler(filename)[source]
returns a result handler that saves the resulting arrays into a file with name filename
- hexrd.grainmap.nfutil.scan_detector_parm(image_stack, experiment, test_crds, controller, parm_to_opt, parm_range, slice_shape, ang='deg')[source]
- hexrd.grainmap.nfutil.simulate_diffractions(grain_params, experiment, controller)[source]
actual forward simulation of the diffraction
- hexrd.grainmap.nfutil.test_orientations(image_stack, experiment, test_crds, controller, multiprocessing_start_method='fork')[source]
grand loop precomputing the grown image stack
image-stack – is the dilated image stack to be tested against.
experiment – A bunch of experiment related parameters.
test_crds – Coordinates to test orientations on, units mm.
- controller – An external object implementing the hooks to notify progress
as well as figuring out what to do with results.