ImageD11.nbGui.nb_utils module#

ImageD11.nbGui.nb_utils.assign_peaks_to_grains(grains, cf, tol)#

Assigns peaks to the best fitting grain

ImageD11.nbGui.nb_utils.clean_esrf_path(fname, fakeroots=('/mnt/storage', '/gpfs/easy'))#
ImageD11.nbGui.nb_utils.clear_notebook(nb_path)#

Clears outputs of a Jupyter notebook.

ImageD11.nbGui.nb_utils.find_datasets_to_process(rawdata_path, skips_dict, dset_prefix, sample_list)#
ImageD11.nbGui.nb_utils.get_rgbs_for_grains(grains, key='tsl', backend='rgb_colors')#

Sets grain.rgb_x, rgb_y, rgb_z: IPF colours of each grain’s ubi (key “tsl” or “hsv”) backend “orix”: orix TSL colours of each grain’s U

ImageD11.nbGui.nb_utils.is_notebook_executed(nb_path)#
ImageD11.nbGui.nb_utils.notebook_exec_pmill(nb_input_path, nb_output_path, params_dict, rename_colliding=False)#
ImageD11.nbGui.nb_utils.notebook_prepare_pmill(nb_input_path, nb_output_path, params_dict, rename_colliding=False)#

Prepare, but not execute, a notebook using papermill

ImageD11.nbGui.nb_utils.plot_all_ipfs(grains, **plot_kwargs)#
ImageD11.nbGui.nb_utils.plot_all_ipfs_from_meta_orien(meta_orien, ref_ucell, **plot_kwargs)#
ImageD11.nbGui.nb_utils.plot_direct_pole_figure(grains, uvw=array([1., 0., 0.]), **plot_kwargs)#
ImageD11.nbGui.nb_utils.plot_eta_vs_omega_error(cf, title=None)#

Diagnostic plot for a wedge error on a .flt.new columnfile coming out of makemap.py

cf = columnfile .flt.new from makemap.py title = title for the plot

ImageD11.nbGui.nb_utils.plot_grain_histograms(fltfile, ubifile, parfile, OmSlop, OmFloat=True, nbins=30, tol=0.05)#
ImageD11.nbGui.nb_utils.plot_grain_positions(grains, colour='npks', centre_plot=False, size_scaling=0.5)#

colour: choose from ‘npks’ or one of ‘x’, ‘y’, ‘z’ for IPF scaling centre_plot: choose whether to centre the plot horizontally (x and y) size_scaling: we only know relative grain sizes, adjust this to scale the diameter of the points on the plot

ImageD11.nbGui.nb_utils.plot_grain_recons(grainsinos, method='iradon')#

Interactive slider viewer for grain reconstructions + sinograms.

Parameters:
  • grainsinos (list) – List of GrainSinogram-like objects, each with .recons[method], .sinoangles, and .ssino attributes.

  • method (str) – Key into grainsinos[i].recons, e.g. “iradon” or “astra”.

  • Note (for best interactive behaviour in Jupyter, run)

  • calling (%matplotlib widget (requires ipympl) once in a cell before)

  • instead. (this function. Falls back gracefully if using webagg/inline)

ImageD11.nbGui.nb_utils.plot_grain_sinograms(grains, cf, n_grains_to_plot=None)#
ImageD11.nbGui.nb_utils.plot_grains_polefig(hkls, cf, grains, dstol=0.006, Imin=0, hbins=128, powder_max_pts=1000000.0, cmapname='jet')#

Plot a plot figure of hkl and show where the grains are

hkls = list of hkls to use. Might be ucell.ringhkls[ ucell.ringds[ j ] ] cf = columnfile for plotting. Probably a cf_2d grains = list of grains for plotting dstol = which peaks from cf.ds to be plotted on pole figure Imin = cutoff to filter cf and remove noise pbins = binning for drawing the pole figure. Depends a bit on your screen resolution. cmapname = color scheme for your grains

ImageD11.nbGui.nb_utils.plot_index_results(ind, colfile, title)#
ImageD11.nbGui.nb_utils.plot_inverse_pole_figure(grains, axis=array([0., 0., 1.]), backend='rgb_colors', **plot_kwargs)#
ImageD11.nbGui.nb_utils.plot_inverse_pole_figure_from_meta_orien(meta_orien, ref_ucell, axis=array([0., 0., 1.]), backend='rgb_colors', **plot_kwargs)#
ImageD11.nbGui.nb_utils.plot_inverse_pole_figure_from_ubis(ubis, ref_ucell, axis=array([0., 0., 1.]), key='tsl', **plot_kwargs)#

IPF of ubi matrices with the point group of ref_ucell, on the colour key: ImageD11.rgb_colors.plot_ipf (plot_kwargs go there, then to scatter)

ImageD11.nbGui.nb_utils.plot_strain_errors(cf, grains, maskfile=None, wavelength=None)#

Diagnostic plot for a strain errors on a .flt.new columnfile coming out of makemap.py

cf = columnfile grains = grains to plot the peaks (matching cf.labels) maskfile = for the f_raw, s_raw plot wavelength = needed for tth to ds if not in colf.parameters

ImageD11.nbGui.nb_utils.prepare_astra_bash(ds, grainsfile, id11_code_path, group_name='grains', memory=150, method='EM_CUDA')#
ImageD11.nbGui.nb_utils.prepare_mlem_bash(ds, grains, id11_code_path, n_simultaneous_jobs=50, cores_per_task=8)#
ImageD11.nbGui.nb_utils.prepare_notebooks(samples_dict, notebooks, dataroot, analysisroot, CHECKOUT_PATH=None, IMAGED11_PATH=None, notebook_parent_dir=None)#

Prepare, but not execute, a series of notebooks for each dataset in samples_dict.

Calls the old prepare_notebooks_for_datasets

Places the prepared notebooks for each dataset like PROCESSED_DATA/sample/sample_dataset/foo.ipynb Returns a list of absolute paths of notebooks to execute.

samples_dict: dict of {sample1: [ds1, ds2, ds3], sample2: [ds1, ds2, ds3]} etc. notebooks: list of tuples of [(notebook_filename.ipynb, {params_for_notebook_1.ipynb})] etc.

Param dicts should not contain dataroot, analysisroot, sample, dataset or dsfile information. Those are instead prepared by this function in the “0…ipynb” notebook that creates the dataset

dataroot: path to raw data folder analysisroot: path to root of analysis folder (usually PROCESSED_DATA) CHECKOUT_PATH: place to check out a git version of ImageD11. IMAGED11_PATH: name of the checkout folder. None means use the system ImageD11. notebook_parent_dir: path to parent directory of input notebooks. Default: current working directory

ImageD11.nbGui.nb_utils.prepare_notebooks_for_datasets(samples_dict, notebooks, dataroot, analysisroot, PYTHONPATH=None, notebook_parent_dir=None)#

Prepare, but not execute, a series of notebooks for each dataset in samples_dict. Places the prepared notebooks for each dataset like PROCESSED_DATA/sample/sample_dataset/foo.ipynb Returns a list of absolute paths of notebooks to execute.

samples_dict: dict of {sample1: [ds1, ds2, ds3], sample2: [ds1, ds2, ds3]} etc. notebooks: list of tuples of [(notebook_filename.ipynb, {params_for_notebook_1.ipynb})] etc. Param dicts should not contain dataroot, analysisroot, sample, dataset or dsfile information - those are instead prepared by this function. dataroot: path to raw data folder analysisroot: path to root of analysis folder (usually PROCESSED_DATA) PYTHONPATH: Python path notebook_parent_dir: path to parent directory of input notebooks. Default: current working directory

ImageD11.nbGui.nb_utils.prepare_pbp_bash(pbp_object, id11_code_path, minpkint)#
ImageD11.nbGui.nb_utils.refine_grain_positions(cf_3d, ds, grains, parfile, symmetry='cubic', cf_frac=0.85, cf_dstol=0.01, hkl_tols=(0.05, 0.025, 0.01))#
ImageD11.nbGui.nb_utils.save_array(grp, name, ary)#
ImageD11.nbGui.nb_utils.save_ubi_map(ds, ubi_map, eps_map, misorientation_map, ipf_x_col_map, ipf_y_col_map, ipf_z_col_map)#
ImageD11.nbGui.nb_utils.slurm_submit_and_wait(bash_script_path, wait_time_sec=60)#
ImageD11.nbGui.nb_utils.slurm_submit_many_and_wait(bash_script_paths, wait_time_sec=60)#
ImageD11.nbGui.nb_utils.stereo(v, ix, iy, iz)#

Stereographic projection

v = vector [3,n] ix = XX axis choice iy = YY axis choice iz = ZZ axis choice (the normal to the plot)

Reflects to the positive hemisphere.

e.g.: if v[iz] < 0 we use -v

Normalises and plots the projection onto the plane to the point at 0,0,-1 (e.g. 1+z further away)