garnet.reduction package#

Submodules#

garnet.reduction.background module#

class Normalization(plan)[source]#

Bases: object

Methods

combine

combine_parallel

get_file

normalize

normalize_parallel

symmetry_name

validate_params

combine(files)[source]#
static combine_parallel(plan, files)[source]#
get_file(file, ws='')[source]#
normalize()[source]#
static normalize_parallel(plan, runs, proc)[source]#
symmetry_name(file)[source]#
validate_params()[source]#

garnet.reduction.crystallography module#

garnet.reduction.data module#

class BaseDataModel(instrument_config)[source]#

Bases: object

Methods

add_UBW(ws, ub_file, projections[, run_number])

Attach sample UB and projection matrix to workspace

bin_in_Q(md, extents, bins, projections)

Histogram data into Q-space.

calculate_binning_from_bins(xmin, xmax, bins)

Determine the binning from the number of bins.

calculate_binning_from_step(xmin, xmax, step)

Determine the binning from step size.

combine_Q_sample(combine, merge)

Merge Q-sample workspaces into one.

combine_files(IPTS, process_map)

Combine runs together based on crystal orientation.

combine_histograms(ws, merge)

Add two histogram workspaces together.

combine_splits(md, log_name, log_vals, ...)

Remove all accumulation workspaces.

delete_workspace(ws)

Delete workspace.

divide_histograms(ws, num, den)

Divide two histogram workspaces.

extract_axis_info(ws)

Obtain the axis information from a histogram.

extract_bin_info(ws)

Obtain the bin information from a histogram.

extract_counts(ws)

Obtain the bin counts from a histogram.

file_names(IPTS, runs)

Complete file paths.

get_file_name_list(IPTS, runs)

Complete list of file paths.

get_hkl_limits(ws)

The minimum and maximum Q-values.

get_min_max_values()

The minimum and maximum Q-values.

get_resolution_in_Q(lamda, two_theta)

Obtain the wavelength and detector-dependent Q-resolution

load_clear_UB(filename, ws[, run_number])

Load UB from file and replace.

load_histograms(filename, ws)

Load histograms file.

log_split_info(ws, log_name, log_limits, ...)

Generate split information for filtering events by log values.

merge_Q_sample(filenames, filename, merge)

Merge Q-sample files into one.

save_UB(filename, ws)

Save UB to file.

save_histograms(filename, ws[, sample_logs])

Save histograms file.

set_goniometer(ws)

Set the goniomter motor angles

subtract_histograms(ws, ws1, ws2)

Difference between two histograms.

update_raw_path(plan)

Set additional parameters for data file.

check_volume_preservation

clear_norm

get_counting_rate

slice_extents

slice_roi

update_logs_for_time

update_wavelength

workspace_exists

add_UBW(ws, ub_file, projections, run_number=None)[source]#

Attach sample UB and projection matrix to workspace

Parameters:
wsstr

Name of histogram to be added.

filenamestr

Name of UB file with extension .mat.

projectionslist

Axis projections.

bin_in_Q(md, extents, bins, projections)[source]#

Histogram data into Q-space.

Parameters:
mdstr

3D Q-space data.

extentslist

Min/max pairs for each dimension.

binslist

Number of bins for each dimension.

projectionslist

Direction of projection for each dimension.

calculate_binning_from_bins(xmin, xmax, bins)[source]#

Determine the binning from the number of bins.

Parameters:
xminfloat

Minimum bin center.

xmaxfloat

Maximum bin center.

binsint

Number of bins.

Returns:
min_edgefloat

Minimum bin edge.

max_edgefloat

Maximum bin edge.

stepfloat

Bin step.

calculate_binning_from_step(xmin, xmax, step)[source]#

Determine the binning from step size.

Parameters:
xminfloat

Minimum bin center.

xmaxfloat

Maximum bin center.

stepfloat

Bin step.

Returns:
min_edgefloat

Minimum bin edge.

max_edgefloat

Maximum bin edge.

binsint

Number of bins.

check_volume_preservation(ws)[source]#
clear_norm(md)[source]#
combine_Q_sample(combine, merge)[source]#

Merge Q-sample workspaces into one.

Parameters:
combinelist

Name of Q-sample workspaces to be accumulated.

mergestr

Name of combined Q-sample workspace.

combine_files(IPTS, process_map)[source]#

Combine runs together based on crystal orientation.

combine_histograms(ws, merge)[source]#

Add two histogram workspaces together.

Parameters:
wsstr

Name of histogram to be added.

mergestr

Name of histogram to be accumulated.

combine_splits(md, log_name, log_vals, log_units, index, runs)[source]#

Remove all accumulation workspaces.

Parameters:
mdstr

Base name of histogram.

delete_workspace(ws)[source]#

Delete workspace.

Parameters:
wsstr

Workspace to remove.

divide_histograms(ws, num, den)[source]#

Divide two histogram workspaces.

Parameters:
wsstr

Name of resulting histogram.

numstr

Name of numerator histogram.

denstr

Name of denominator histogram.

extract_axis_info(ws)[source]#

Obtain the axis information from a histogram.

Parameters:
wsstr

Name of histogram.

Returns:
UB3x3-matrix

UB-matrix.

W3x3-matrix

Projection matrix.

titleslist

Axis names and units.

x0, x1, …array

Bin center coordinates.

extract_bin_info(ws)[source]#

Obtain the bin information from a histogram.

Parameters:
wsstr

Name of histogram.

Returns:
signalarray

Data signal.

errorarray

Data uncertanies.

x0, x1, …array

Dense bin center coordinates.

extract_counts(ws)[source]#

Obtain the bin counts from a histogram.

Parameters:
wsstr

Name of histogram.

Returns:
Countsarray

Number of events.

file_names(IPTS, runs)[source]#

Complete file paths.

Parameters:
IPTSint

Proposal number.

runslist, int

List of run number(s).

Returns:
filenamesstr

Comma separated filepaths.

get_counting_rate()[source]#
get_file_name_list(IPTS, runs)[source]#

Complete list of file paths.

Parameters:
IPTSint

Proposal number.

runslist, int

List of run number(s).

Returns:
filenameslist

List of filepaths.

get_hkl_limits(ws)[source]#

The minimum and maximum Q-values.

Returns:
hkl_min_vals: list

Minumum hkl.

hkl_max_vals: list

Maximum hkl.

get_min_max_values()[source]#

The minimum and maximum Q-values.

Returns:
Q_min_vals: list

Minumum Q.

Q_max_vals: list

Maximum Q.

get_resolution_in_Q(lamda, two_theta)[source]#

Obtain the wavelength and detector-dependent Q-resolution

Parameters:
lamdafloat

Incident wavelength.

two_thetafloat

Detector scattering angle in degrees.

Returns:
dQarray

Q-resolution.

load_clear_UB(filename, ws, run_number=None)[source]#

Load UB from file and replace.

Parameters:
filenamestr

Name of UB file with extension .mat.

wsstr, optional

Name of data.

run_numberstr, optional

Run number to replace starred expression in filename.

load_histograms(filename, ws)[source]#

Load histograms file.

Parameters:
filenamestr

Name of peaks file with extension .nxs.

wsstr

Name of histogram to be added.

log_split_info(ws, log_name, log_limits, log_bins, log_ramp='Both')[source]#

Generate split information for filtering events by log values.

Parameters:
wsstr

Workspace with log time and values.

log_namestr

Name of the log.

log_limitslist, float

Min/max values of log (bin center).

log_binsint

Number of equally space bins.

log_rampstr

Filter log by ramp direction. The default is Both.

merge_Q_sample(filenames, filename, merge)[source]#

Merge Q-sample files into one.

Parameters:
filenameslist

Name of Q-sample filenames to be combined.

filename: str

Name of Q-sample filename to be saved.

mergestr

Name of Q-sample workspace to be accumulated.

save_UB(filename, ws)[source]#

Save UB to file.

Parameters:
filenamestr

Name of UB file with extension .mat.

wsstr, optional

Name of data.

save_histograms(filename, ws, sample_logs=False)[source]#

Save histograms file.

Parameters:
filenamestr

Name of peaks file with extension .nxs.

wsstr

Name of histogram to be added.

set_goniometer(ws)[source]#

Set the goniomter motor angles

Parameters:
wsstr, optional

Name of raw data.

slice_extents(UB, hkl)[source]#
slice_roi(md, UB, hkl)[source]#
subtract_histograms(ws, ws1, ws2)[source]#

Difference between two histograms.

Parameters:
wsstr

Name of resulting histogram.

ws1str

Name of first histogram.

ws2str

Name of second histogram.

update_logs_for_time(ws)[source]#
update_raw_path(plan)[source]#

Set additional parameters for data file.

Parameters:
plandict

Reduction plan.

update_wavelength(wl)[source]#
workspace_exists(ws)[source]#
DataModel(instrument_config)[source]#
class LaueData(instrument_config)[source]#

Bases: BaseDataModel

Methods

add_UBW(ws, ub_file, projections[, run_number])

Attach sample UB and projection matrix to workspace

apply_calibration(event_name, ...[, ...])

Apply detector calibration.

apply_mask(event_name, detector_mask[, save])

Apply detector mask.

bin_in_Q(md, extents, bins, projections)

Histogram data into Q-space.

calculate_binning_from_bins(xmin, xmax, bins)

Determine the binning from the number of bins.

calculate_binning_from_step(xmin, xmax, step)

Determine the binning from step size.

calculate_maximum_Q([scale])

Update maximum Q.

combine_Q_sample(combine, merge)

Merge Q-sample workspaces into one.

combine_files(IPTS, process_map)

Combine runs together based on crystal orientation.

combine_histograms(ws, merge)

Add two histogram workspaces together.

combine_splits(md, log_name, log_vals, ...)

Remove all accumulation workspaces.

convert_to_Q_lab(event_name, md_name[, ...])

Convert raw data to Q-lab.

convert_to_Q_sample(event_name, md_name[, ...])

Convert raw data to Q-sample.

convert_to_hkl(event_name, md_name[, ...])

Convert raw data to hkl.

crop_for_normalization(event_name)

Convert units to momentum and crop to momentum band.

delete_workspace(ws)

Delete workspace.

divide_histograms(ws, num, den)

Divide two histogram workspaces.

extract_axis_info(ws)

Obtain the axis information from a histogram.

extract_bin_info(ws)

Obtain the bin information from a histogram.

extract_counts(ws)

Obtain the bin counts from a histogram.

file_names(IPTS, runs)

Complete file paths.

filter_events(ws, run, runs)

Split workspaces according to log.

get_counting_rate(event_name)

Counting rate.

get_file_name_list(IPTS, runs)

Complete list of file paths.

get_hkl_limits(ws)

The minimum and maximum Q-values.

get_min_max_values()

The minimum and maximum Q-values.

get_resolution_in_Q(lamda, two_theta)

Obtain the wavelength and detector-dependent Q-resolution

load_background(filename, event_name[, ...])

Load a background file and scale to data.

load_clear_UB(filename, ws[, run_number])

Load UB from file and replace.

load_data(event_name, IPTS, runs[, time_cut])

Load raw data into time-of-flight vs counts.

load_generate_normalization(vanadium_file, ...)

Load a vanadium file and generate normalization data.

load_histograms(filename, ws)

Load histograms file.

log_split_info(ws, log_name, log_limits, ...)

Generate split information for filtering events by log values.

mask_to_bank(event_name, bank_name)

Mask to bank

merge_Q_sample(filenames, filename, merge)

Merge Q-sample files into one.

normalize_to_hkl(md, projections, extents, bins)

Normalize to binned hkl.

preprocess_detector_banks(bank)

Generate detector coordinates for each bank.

preprocess_detectors([ws])

Generate detector coordinates.

save_UB(filename, ws)

Save UB to file.

save_histograms(filename, ws[, sample_logs])

Save histograms file.

set_goniometer(ws)

Set the goniomter motor angles

subtract_histograms(ws, ws1, ws2)

Difference between two histograms.

update_raw_path(plan)

Set additional parameters for data file.

absorption_correction

approximate_norm

check_volume_preservation

clear_norm

get_monitor_ratio

get_volume_in_Q

grouping_list

slice_extents

slice_roi

subtract_background

update_logs_for_time

update_wavelength

workspace_exists

absorption_correction(event_name, shapestl, angles, material)[source]#
apply_calibration(event_name, detector_calibration, tube_calibration=None, goniometer_calibration=None)[source]#

Apply detector calibration.

Parameters:
event_namestr

Name of raw event_name data.

detector_calibrationstr

Detector calibration as either .xml or .DetCal.

tube_calibrationstr, optional

CORELLI-only tube calibration. The default is None.

goniometer_calibrationstr

Goniometer calibration as .xml. The default is None.

apply_mask(event_name, detector_mask, save=False)[source]#

Apply detector mask.

Parameters:
event_namestr

Name of raw event_name data.

detector_maskstr

Detector mask as .xml.

approximate_norm(lamda, two_theta, det_ID)[source]#
calculate_maximum_Q(scale=1)[source]#

Update maximum Q.

convert_to_Q_lab(event_name, md_name, lorentz_corr=False)[source]#

Convert raw data to Q-lab.

Parameters:
event_namestr

Name of raw event name data.

md_namestr

Name of Q-sample workspace.

lorentz_corrbool, optional

Apply Lorentz correction. The default is False.

convert_to_Q_sample(event_name, md_name, lorentz_corr=False, preproc_dets=None)[source]#

Convert raw data to Q-sample.

Parameters:
event_namestr

Name of raw event name data.

md_namestr

Name of Q-sample workspace.

lorentz_corrbool, optional

Apply Lorentz correction. The default is False.

preproc_dets: str, optional

Preprocess detector information workspace.

convert_to_hkl(event_name, md_name, lorentz_corr=False, preproc_dets=None)[source]#

Convert raw data to hkl.

Parameters:
event_namestr

Name of raw event name data.

md_namestr

Name of Q-sample workspace.

lorentz_corrbool, optional

Apply Lorentz correction. The default is False.

preproc_dets: str, optional

Preprocess detector information workspace.

crop_for_normalization(event_name)[source]#

Convert units to momentum and crop to momentum band.

event_namestr

Name of raw event data.

filter_events(ws, run, runs)[source]#

Split workspaces according to log. If no splitting, index according to run number.

Parameters:
wsstr

Workspace to split.

runint

Run number.

runslist

All run numbers

Returns:
indiceslist, str

Split index.

workspaceslist, float

Split workspace.

get_counting_rate(event_name)[source]#

Counting rate.

Parameters:
event_namestr

Name of raw event_name data.

Returns:
cntrtfloat

Counting rate in events per proton charge.

get_monitor_ratio()[source]#
get_volume_in_Q(lamda, two_theta, det_ID)[source]#
grouping_list(ws, cols, rows, lite_c, lite_r, group_c, group_r)[source]#
load_background(filename, event_name, detector_calibration=None, tube_calibration=None, save=False, subtract=False)[source]#

Load a background file and scale to data.

Parameters:
filenamestr

Background file.

event_namestr

Name of raw event data.

subtractbool

If True, scale background by run proton charge and subtract directly from event_name (event-space subtraction, one-time load kept as “bkg”). If False, restore original counts and convert to Q-lab as “bkg_md” for use in normalization.

load_data(event_name, IPTS, runs, time_cut=None)[source]#

Load raw data into time-of-flight vs counts.

Parameters:
event_namestr

Name of raw event_name data.

IPTSint

Proposal number.

runslist, int

List of run number(s).

time_cut: float, optional

Time cut off for faster loading.

load_generate_normalization(vanadium_file, flux_file, save=False)[source]#

Load a vanadium file and generate normalization data.

Parameters:
vanadium_filestr

Solid angle file.

flux_filestr

Flux file.

mask_to_bank(event_name, bank_name)[source]#

Mask to bank

Parameters:
event_namestr

Name of raw event_name data.

bank_namestr

Bank name.

normalize_to_hkl(md, projections, extents, bins, symmetry=None)[source]#

Normalize to binned hkl.

Parameters:
mdstr

3D Q-sample data.

projectionslist

Projection axis vectors.

extentslist

Min/max pairs defining the bin center limits.

binslist

Number of bins.

symmetrystr, optional

Laue point group. The default is None.

preprocess_detector_banks(bank)[source]#

Generate detector coordinates for each bank.

Parameters:
bankstr

Bank-only event data.

preprocess_detectors(ws=None)[source]#

Generate detector coordinates.

Parameters:
event_namestr

Workspace with instrument data.

subtract_background(md_name, event_name)[source]#
class MonochromaticData(instrument_config)[source]#

Bases: BaseDataModel

Methods

add_UBW(ws, ub_file, projections[, run_number])

Attach sample UB and projection matrix to workspace

bin_in_Q(md, extents, bins, projections)

Histogram data into Q-space.

calculate_binning_from_bins(xmin, xmax, bins)

Determine the binning from the number of bins.

calculate_binning_from_step(xmin, xmax, step)

Determine the binning from step size.

combine_Q_sample(combine, merge)

Merge Q-sample workspaces into one.

combine_files(IPTS, process_map)

Combine runs together based on crystal orientation.

combine_histograms(ws, merge)

Add two histogram workspaces together.

combine_splits(md, log_name, log_vals, ...)

Remove all accumulation workspaces.

convert_to_Q_sample(histo_name, md_name[, ...])

Convert raw data to Q-sample.

delete_workspace(ws)

Delete workspace.

divide_histograms(ws, num, den)

Divide two histogram workspaces.

extract_axis_info(ws)

Obtain the axis information from a histogram.

extract_bin_info(ws)

Obtain the bin information from a histogram.

extract_counts(ws)

Obtain the bin counts from a histogram.

file_names(IPTS, runs)

Complete file paths.

get_file_name_list(IPTS, runs)

Complete list of file paths.

get_hkl_limits(ws)

The minimum and maximum Q-values.

get_min_max_values()

The minimum and maximum Q-values.

get_resolution_in_Q(lamda, two_theta)

Obtain the wavelength and detector-dependent Q-resolution

load_background(filename[, histo_name])

Load a background file and scale to data.

load_clear_UB(filename, ws[, run_number])

Load UB from file and replace.

load_data(histo_name, IPTS, runs)

Load raw data into detector counts vs rotation index.

load_generate_normalization(filename[, ...])

Load a vanadium file and generate normalization data.

load_histograms(filename, ws)

Load histograms file.

log_split_info(ws, log_name, log_limits, ...)

Generate split information for filtering events by log values.

merge_Q_sample(filenames, filename, merge)

Merge Q-sample files into one.

normalize_to_hkl(ws, projections, extents, bins)

Normalizae to binned hkl.

save_UB(filename, ws)

Save UB to file.

save_histograms(filename, ws[, sample_logs])

Save histograms file.

set_goniometer(ws)

Set the goniomter motor angles

subtract_histograms(ws, ws1, ws2)

Difference between two histograms.

update_raw_path(plan)

Set additional parameters for data file.

check_volume_preservation

clear_norm

get_counting_rate

slice_extents

slice_roi

update_logs_for_time

update_wavelength

workspace_exists

convert_to_Q_sample(histo_name, md_name, lorentz_corr=False)[source]#

Convert raw data to Q-sample.

Parameters:
histo_namestr

Name of raw histogram data.

md_namestr

Name of Q-sample workspace.

lorentz_corrbool, optional

Apply Lorentz correction. The default is False.

load_background(filename, histo_name=None)[source]#

Load a background file and scale to data.

Parameters:
filenamestr

Background file.

histo_namestr

Name of raw histogram data.

load_data(histo_name, IPTS, runs)[source]#

Load raw data into detector counts vs rotation index.

Parameters:
histo_namestr

Name of raw histogram data.

IPTSint

Proposal number.

runslist, int

List of run number(s).

groupingstr, optional

Options for grouping pixels.

load_generate_normalization(filename, histo_name=None)[source]#

Load a vanadium file and generate normalization data. Provided a histogram workspace name, generate corresponding shape.

Parameters:
filenamestr

Vanadium file.

histo_namestr, optional

Name of raw histogram data.

normalize_to_hkl(ws, projections, extents, bins, symmetry=None)[source]#

Normalizae to binned hkl.

Parameters:
wsstr

3D detector counts vs rotation index data.

projectionslist

Projection axis vectors.

extentslist

Min/max pairs defining the bin center limits.

binslist

Number of bins.

symmetrystr, optional

Laue point group. The default is None.

garnet.reduction.ellipsoid module#

class PeakEllipsoid[source]#

Bases: object

Methods

background_profile(x0, x1, x2, d, n, b, m)

Projected 1D background intensity and Poisson uncertainty for each axis, cropped to the same region as the fit so x values match best_prof.

S_matrix

U_deriv_u

U_matrix

calculate_intensity

centroid_inverse_covariance

coerce_weight

coerce_weights

collect_mode_fit_metrics

copy_combine

counts_to_intensity_uncertainty

data_norm

det_S

ellipsoid_covariance

estimate_center_weighted

estimate_envelope

estimate_intensity

estimate_peak_strength

extract_amplitude_background

extract_intensity

extract_raw_intensity

extract_result

fit

fitted_profile

gaussian

gaussian_integral

gaussian_integral_jac_S

gaussian_jac_S

gaussian_jac_c

integrate

inv_S_deriv_r

inv_S_deriv_u

inv_S_matrix

jacobian

jacobian_1d

jacobian_2d

jacobian_3d

jacobian_mode_poisson

matched_filter

mode_model_counts

normalize

peak_roi

poisson_deviance_fit

poisson_deviance_residual_factor

prior_jacobian

prior_residual

prior_strength_from_sn

profile_project

project_background

quick_gaussian

residual

residual_1d

residual_2d

residual_3d

residual_mode_poisson

safe_sn

set_resolution_sigma

subtract_profile

sweep

uniform_mode_weights

update_adaptive_prior

update_constraints

update_estimate

vech6

voxel_volume

voxels

S_matrix(r0, r1, r2, u0, u1, u2)[source]#
U_deriv_u(u0, u1, u2, delta=1e-06)[source]#
U_matrix(u0, u1, u2)[source]#
background_profile(x0, x1, x2, d, n, b, m)[source]#

Projected 1D background intensity and Poisson uncertainty for each axis, cropped to the same region as the fit so x values match best_prof.

Returns:
list of 3 tuples (x, y_bkg, e_bkg), one per axis, or None if unavailable.
calculate_intensity(A, H, r0, r1, r2, u0, u1, u2, mode='3d')[source]#
centroid_inverse_covariance(c0, c1, c2, r0, r1, r2, u0, u1, u2)[source]#
coerce_weight(target, weight=None)[source]#
coerce_weights(targets, weights=None)[source]#
collect_mode_fit_metrics(x0, x1, x2, c, inv_S, mode_data, bkg_offset=None)[source]#
copy_combine()[source]#
counts_to_intensity_uncertainty(d, n)[source]#
data_norm(d, n, v, rel_err=30)[source]#
det_S(r0, r1, r2, u0, u1, u2)[source]#
ellipsoid_covariance(inv_S, mode='3d', perc=99.7)[source]#
estimate_center_weighted(d, n, kernel, frac=0.9, min_weight=1e-12)[source]#
estimate_envelope(x0, x1, x2, d_int, n_int, wgt, report_fit=False, b=None, m=None)[source]#
estimate_intensity(x0, x1, x2, c, inv_S, y_fit, y, e, mode='3d', bkg_offset=None)[source]#
estimate_peak_strength()[source]#
extract_amplitude_background()[source]#
extract_intensity(d, n, pk, bkg, kernel, vol_frac=1.0, bkg_meas=None, bkg_var_meas=None)[source]#
extract_raw_intensity(counts, pk, bkg)[source]#
extract_result(args_1d, args_2d, args_3d, xmod)[source]#
fit(x0_prof, x1_proj, x2_proj, d, n, dx, xmod, voxel_weights, b=None, m=None)[source]#
fitted_profile(x0, x1, x2, d, n, c, S, p=0.997, eta=0.5, bkg_meas=None)[source]#
gaussian(x0, x1, x2, c, inv_S, mode='3d')[source]#
gaussian_integral(inv_S, mode='3d')[source]#
gaussian_integral_jac_S(inv_S, d_inv_S, mode='3d')[source]#
gaussian_jac_S(x0, x1, x2, c, inv_S, d_inv_S, mode='3d')[source]#
gaussian_jac_c(x0, x1, x2, c, inv_S, mode='3d')[source]#
integrate(x0, x1, x2, d, n, c, S, b=None, m=None)[source]#
inv_S_deriv_r(r0, r1, r2, u0, u1, u2)[source]#
inv_S_deriv_u(r0, r1, r2, u0, u1, u2)[source]#
inv_S_matrix(r0, r1, r2, u0, u1, u2)[source]#
jacobian(params, args_1d, args_2d, args_3d)[source]#
jacobian_1d(params, x0, x1, x2, ds, ns, ws=None, bkgs=None, c=None, inv_S=None, dr=None, du=None)[source]#
jacobian_2d(params, x0, x1, x2, ds, ns, ws=None, bkgs=None, c=None, inv_S=None, dr=None, du=None)[source]#
jacobian_3d(params, x0, x1, x2, d, n, w=None, bkg=None, c=None, inv_S=None, dr=None, du=None)[source]#
jacobian_mode_poisson(params, x0, x1, x2, d, n, w, c, inv_S, dr, du, mode, bkg=None)[source]#
matched_filter(d, n, kernel, mask, bkg_meas=None)[source]#
mode_model_counts(params, x0, x1, x2, d, n, w, c, inv_S, mode, bkg=None)[source]#
normalize(x0, x1, x2, d, n, w, mode='3d')[source]#
peak_roi(x0, x1, x2, c, S, scale, p=0.997)[source]#
poisson_deviance_fit(x0, x1, x2, c, inv_S, y_fit, y, e, mode='3d')[source]#
poisson_deviance_residual_factor(d, mu, w=None, eps=1e-12)[source]#
prior_jacobian(params, S, dr, du)[source]#
prior_residual(params)[source]#
prior_strength_from_sn(sn_eff, sn0=10.0, power=2.0, lam_min=1.0, lam_max=10.0)[source]#
profile_project(x0, x1, x2, d, n, w, mode='3d')[source]#
project_background(bkg, mode)[source]#
quick_gaussian(x0, x1, x2, d, n, mode='3d', b=None, m=None)[source]#
residual(params, args_1d, args_2d, args_3d)[source]#
residual_1d(params, x0, x1, x2, ds, ns, ws=None, bkgs=None, c=None, inv_S=None)[source]#
residual_2d(params, x0, x1, x2, ds, ns, ws=None, bkgs=None, c=None, inv_S=None)[source]#
residual_3d(params, x0, x1, x2, d, n, w=None, bkg=None, c=None, inv_S=None)[source]#
residual_mode_poisson(params, x0, x1, x2, d, n, w, c, inv_S, mode, bkg=None)[source]#
safe_sn(sn, floor=1.0, ceiling=10000.0)[source]#
set_resolution_sigma(prior_center_sigma, prior_cov_sigma, Q_mag=1.0)[source]#
subtract_profile(d, n, perc=30)[source]#
sweep(args_1d, args_2d, args_3d, protocol, n_iter=50, report_fit=False)[source]#
uniform_mode_weights(ys, es, val=1.0)[source]#
update_adaptive_prior(args_1d, args_2d, args_3d)[source]#
update_constraints(x0, x1, x2, dx)[source]#
update_estimate(shape)[source]#
vech6(M)[source]#
voxel_volume(x0, x1, x2)[source]#
voxels(x0, x1, x2)[source]#

garnet.reduction.integration module#

class Integration(plan)[source]#

Bases: IntegrationModel

Methods

append_name(file)

Update filename with identifier name.

cell_centering_name()

Lattice and reflection condition.

extract_peak_info(peaks_ws, r_cut[, norm, ...])

Obtain peak information for envelope determination.

get_diagnostic_file(name[, ext])

Diagnostic file.

get_diagnostic_path()

Diagnostic path.

get_file(file[, ws])

Update filename with identifier name and optional workspace name.

get_output_file([ext])

Output file.

get_output_path()

Output path.

get_plot_file(name[, ext])

Plot file.

get_plot_path()

Plot path.

modulation_name()

Modulation vectors.

resolution_name()

Minimum d-spacing and starting radii

add_with_padding

bin_axes

bin_extent

check

cleanup

combine

combine_parallel

create_directories

integrate

integrate_parallel

integrate_peaks

pad_to_shape

predict_add_satellite_peaks

project_ellipsoid_parameters

revert_ellipsoid_parameters

transform_Q

unit_key

update_peak_info

update_peak_offsets

validate_params

voxel_weights

write

add_with_padding(a, b, fill=0)[source]#
append_name(file)[source]#

Update filename with identifier name.

Parameters:
filestr

Original file name.

Returns:
output_filestr

File with updated name for identifier name.

cell_centering_name()[source]#

Lattice and reflection condition.

Returns:
lat_refstr

Underscore separated strings.

combine(files)[source]#
static combine_parallel(plan, files)[source]#
extract_peak_info(peaks_ws, r_cut, norm=False, fit=True, bank=None)[source]#

Obtain peak information for envelope determination.

Parameters:
peaks_wsstr

Peaks table.

r_cutlist or float

Cutoff radius parameter(s).

get_file(file, ws='')[source]#

Update filename with identifier name and optional workspace name.

Parameters:
filestr

Original file name.

wsstr, optional

Name of workspace. The default is ‘’.

Returns:
output_filestr

File with updated name for identifier and workspace name.

integrate()[source]#
static integrate_parallel(plan, runs, proc)[source]#
integrate_peaks(data)[source]#
modulation_name()[source]#

Modulation vectors.

Returns:
modstr

Underscore separated vectors and max order

pad_to_shape(x, shape, fill=0)[source]#
predict_add_satellite_peaks(lamda_min, lamda_max)[source]#
resolution_name()[source]#

Minimum d-spacing and starting radii

Returns:
res_radstr

Underscore separated strings.

unit_key(v, tol=0.01)[source]#
update_peak_info(peaks_ws, peak_dict)[source]#
update_peak_offsets(peaks_ws, offsets, peak_dict)[source]#
validate_params()[source]#
write(result_file)[source]#

garnet.reduction.normalization module#

class Normalization(plan)[source]#

Bases: SubPlan

Methods

append_name(file)

Update filename with identifier name.

binning_name()

Bin size for each dimension.

combine(files)

Merge data and normalization files.

elastic_name()

Elastic channel.

extents_name()

Min/max pairs for each dimensional extents.

get_diagnostic_file(name[, ext])

Diagnostic file.

get_diagnostic_path()

Diagnostic path.

get_file(file[, ws])

Update filename with identifier name and optional workspace name.

get_output_file([ext])

Output file.

get_output_path()

Output path.

get_plot_file(name[, ext])

Plot file.

get_plot_path()

Plot path.

projection_name()

Axes projections.

symmetry_name()

Laue group name.

check

cleanup

combine_parallel

create_directories

normalize

normalize_parallel

validate_params

view

append_name(file)[source]#

Update filename with identifier name.

Parameters:
filestr

Original file name.

Returns:
output_filestr

File with updated name for identifier name.

binning_name()[source]#

Bin size for each dimension.

_N0xN1xN2

Returns:
binsstr

Cross separated integers.

combine(files)[source]#

Merge data and normalization files.

Parameters:
fileslist

Files to be combined.

static combine_parallel(plan, files)[source]#
elastic_name()[source]#

Elastic channel.

Returns:
ccstr

Total or elastic channel.

extents_name()[source]#

Min/max pairs for each dimensional extents.

_[min_0,max_0]_[min_1,max_1]_[min_2,max_2]

Returns:
extentsstr

Underscore separated list.

get_file(file, ws='')[source]#

Update filename with identifier name and optional workspace name.

Parameters:
filestr

Original file name.

wsstr, optional

Name of workspace. The default is ‘’.

Returns:
output_filestr

File with updated name for identifier and workspace name.

normalize()[source]#
static normalize_parallel(plan, runs, proc)[source]#
projection_name()[source]#

Axes projections.

Returns:
projstr

Name of slices.

symmetry_name()[source]#

Laue group name. Spaces are removed and slashes are replaced with underscore.

Returns:
symmetrystr

None or Hermann-Mauguin point group symbol.

validate_params()[source]#
view(result_file)[source]#

garnet.reduction.parallel module#

garnet.reduction.parametrization module#

class Parametrization(plan)[source]#

Bases: SubPlan

Methods

append_name(file)

Update filename with identifier name.

binning_name()

Bin size for each dimension.

combine(files)

Merge data and normalization files.

elastic_name()

Elastic channel.

extents_name()

Min/max pairs for each dimensional extents.

get_diagnostic_file(name[, ext])

Diagnostic file.

get_diagnostic_path()

Diagnostic path.

get_file(file[, ws])

Update filename with identifier name and optional workspace name.

get_output_file([ext])

Output file.

get_output_path()

Output path.

get_plot_file(name[, ext])

Plot file.

get_plot_path()

Plot path.

log_name()

Log name.

projection_name()

Axes projections.

check

cleanup

combine_parallel

create_directories

parametrize

parametrize_parallel

validate_params

view

append_name(file)[source]#

Update filename with identifier name.

Parameters:
filestr

Original file name.

Returns:
output_filestr

File with updated name for identifier name.

binning_name()[source]#

Bin size for each dimension.

_N0xN1xN2

Returns:
binsstr

Cross separated integers.

combine(files)[source]#

Merge data and normalization files.

Parameters:
fileslist

Files to be combined.

static combine_parallel(plan, files)[source]#
elastic_name()[source]#

Elastic channel.

Returns:
ccstr

Total or elastic channel.

extents_name()[source]#

Min/max pairs for each dimensional extents.

_[min_0,max_0]_[min_1,max_1]_[min_2,max_2]

Returns:
extentsstr

Underscore separated list.

get_file(file, ws='')[source]#

Update filename with identifier name and optional workspace name.

Parameters:
filestr

Original file name.

wsstr, optional

Name of workspace. The default is ‘’.

Returns:
output_filestr

File with updated name for identifier and workspace name.

log_name()[source]#

Log name. Spaces are removed and slashes are replaced with underscore.

Returns:
logstr

None or Hermann-Mauguin point group symbol.

parametrize()[source]#
static parametrize_parallel(plan, runs, proc)[source]#
projection_name()[source]#

Axes projections.

Returns:
projstr

Name of slices.

validate_params()[source]#
view(result_file)[source]#

garnet.reduction.peaks module#

class PeakModel(peaks)[source]#

Bases: object

Methods

add_diagnostic_info(no, info)

Log diagnostic info.

get_UB()

UB matrix.

get_angles(no)

Scattering and azimuthal angle of the peak.

get_bank_name(no)

Obtain the bank name.

get_d_from_ub(no)

D-spacing from current oriented lattice for the given peak.

get_d_spacing(no)

Obtain the peak d-spacing.

get_detector_id(no)

Obtain the peak detector id number.

get_goniometer_angles(no)

Goniometer Euler angles of the peak.

get_goniometer_matrix(no)

Goniometer matrix of the peak.

get_hkl(no)

Miller indices.

get_hklmnp(no)

Miller indices.

get_number_peaks()

Total number of peaks in the table.

get_peak_name(no[, merge, d])

Name of peak.

get_peak_shape(no[, r_cut])

Obtain the peak shape parameters.

get_sample_Q(no)

Scattering vector in Q sample coordinates.

get_signal_to_noise(no)

Intensity to uncertainty ratio.

get_wavelength(no)

Wavelength of the peak.

set_hklmnp(no, hklmnp)

Update Miller indices.

set_peak_center(no, c0, c1, c2)

Update the shape of the peak.

set_peak_intensity(no, intens, sig)

Update the peak intensity.

set_peak_shape(no, c0, c1, c2, r0, r1, r2, ...)

Update the shape of the peak.

set_scale_factor(no, scale)

update the peak normalization scale factor.

set_wavelength(no, lamda)

Update the wavelength of the peak.

get_projection_matrix

get_projection_peak_origin

add_diagnostic_info(no, info)[source]#

Log diagnostic info.

Parameters:
noint

Peak index number.

infodict

Mapping of diagnostic key → scalar value. Keys must be a subset of diagnostic_keys (positional run/hkl keys are filled from the peak itself and must not appear in info).

get_UB()[source]#

UB matrix.

Returns:
UB2d-array, 3x3

UB-matrix

get_angles(no)[source]#

Scattering and azimuthal angle of the peak.

Parameters:
noint

Peak index number.

Returns:
two_thetafloat

Scattering (polar) angle in degrees.

az_phifloat

Azimuthal angle in degrees.

get_bank_name(no)[source]#

Obtain the bank name.

Parameters:
noint

Peak index number.

Returns:
bankstr

Bank name.

get_d_from_ub(no)[source]#

D-spacing from current oriented lattice for the given peak.

Parameters:
noint

Peak index number.

Returns:
dfloat

D-spacing in Angstroms.

get_d_spacing(no)[source]#

Obtain the peak d-spacing.

Parameters:
noint

Peak index number.

Returns:
dfloat

Interplanar spacing.

get_detector_id(no)[source]#

Obtain the peak detector id number.

Parameters:
noint

Peak index number.

Returns:
det_idint

Detector number.

get_goniometer_angles(no)[source]#

Goniometer Euler angles of the peak.

Parameters:
noint

Peak index number.

Returns:
angleslist

Euler angles (YZY convention) in degrees.

get_goniometer_matrix(no)[source]#

Goniometer matrix of the peak.

Parameters:
noint

Peak index number.

Returns:
R2d-array

Rotation matrix.

get_hkl(no)[source]#

Miller indices.

Parameters:
noint

Peak index number.

Returns:
hkllist

Components of Miller indices.

get_hklmnp(no)[source]#

Miller indices.

Parameters:
noint

Peak index number.

Returns:
hklmnptuple

Components of Miller indices.

get_number_peaks()[source]#

Total number of peaks in the table.

Returns:
nint

Number of peaks

get_peak_name(no, merge=False, d=None)[source]#

Name of peak.

Parameters:
noint

Peak index number.

dfloat, optional

D-spacing to use in the name. When provided the lattice lookup is skipped, so the name is stable even after UB refinement.

Returns:
namestr

Readable name of peak.

get_peak_shape(no, r_cut=inf)[source]#

Obtain the peak shape parameters.

Parameters:
noint

Peak index number.

Returns:
c0, c1, c2float

Peak center.

r0, r1, r2float

Principal radii.

v0, v1, v2list

Principal axis directions.

get_projection_matrix(no)[source]#
get_projection_peak_origin(no)[source]#
get_sample_Q(no)[source]#

Scattering vector in Q sample coordinates.

Parameters:
noint

Peak index number.

Returns:
Qlist

Scattering Q-vector.

get_signal_to_noise(no)[source]#

Intensity to uncertainty ratio.

Parameters:
noint

Peak index number.

Returns:
I_sigfloat

Signal-noise ratio.

get_wavelength(no)[source]#

Wavelength of the peak.

Parameters:
noint

Peak index number.

Returns:
lamdafloat

Wavelength in angstroms.

set_hklmnp(no, hklmnp)[source]#

Update Miller indices.

Parameters:
noint

Peak index number.

hklmnplist

Components of Miller indices.

set_peak_center(no, c0, c1, c2)[source]#

Update the shape of the peak.

Parameters:
noint

Peak index number.

c0, c1, c2float

Peak center.

set_peak_intensity(no, intens, sig)[source]#

Update the peak intensity.

Parameters:
noint

Peak index number.

intensfloat

Intensity.

sigfloat

Uncertainty.

set_peak_shape(no, c0, c1, c2, r0, r1, r2, v0, v1, v2)[source]#

Update the shape of the peak.

Parameters:
noint

Peak index number.

c0, c1, c2float

Peak center.

r0, r1, r2float

Principal radii.

v0, v1, v2list

Principal axis directions.

set_scale_factor(no, scale)[source]#

update the peak normalization scale factor.

Parameters:
noint

Peak index number.

scalefloat

Peak scale factor

set_wavelength(no, lamda)[source]#

Update the wavelength of the peak.

Parameters:
noint

Peak index number.

lamdafloat

Wavelength in angstroms.

class PeaksModel[source]#

Bases: object

Methods

add_peak(peaks, hkl)

Add a peak to an existing table.

centroid_peaks(md, peaks, peak_radius)

Re-center peak locations using centroid within given radius

combine_peaks(peaks, merge)

Merge two peaks workspaces into one.

convert_peaks(peaks)

Remove instrument from peaks.

create_peaks(ws, peaks[, lean])

Create a new peaks table.

delete_peaks(peaks)

Remove peaks.

filter_unique_hkl(peaks, unique_peaks)

Keep one representative per unique (h,k,l,m,n,p) group.

find_peaks(md, peaks, min_Q[, density, ...])

Harvest strong peak locations from Q-sample into a peaks table.

get_UB(ws)

Obtain UB from the oriented lattice.

get_all_goniometer_matrices(ws)

Extract all goniometer matrices.

get_bank_names(peaks)

Obtain the bank names.

get_max_d_spacing(ws)

Obtain the maximum d-spacing from the oriented lattice.

get_peaks_name(peaks)

Name of peaks.

integrate_peaks(md, peaks, peak_radius[, ...])

Integrate peaks using spherical or ellipsoidal regions.

intensity_profile(md, peaks, peak_radius[, ...])

Integrate peak intensity as profile.

intensity_projection(md, peaks, peak_radius)

Integrate peak intensity as profile.

intensity_vs_radius(md, peaks, peak_radius)

Integrate peak intensity with radius varying from zero to cut off.

load_peaks(filename, peaks)

Load peaks file.

predict_modulated_peaks(peaks, centering, ...)

Predict the modulated peak positions based on main peaks.

predict_peaks(ws, peaks, centering, d_min, ...)

Predict peak Q-sample locations with UB and lattice centering.

predict_satellite_peaks(peaks_ws, data_ws, ...)

Locate satellite peaks from goniometer angles.

remove_duplicate_peaks(peaks)

Omit duplicate peaks from different based on indexing.

remove_peaks_by_d_tolerance(peaks[, tol])

Filter out peaks based on d-spacing tolerance.

remove_unindexed_peaks(peaks)

Filter out unindexes peaks.

remove_weak_peaks(peaks[, sig_noise])

Filter out weak peaks based on signal-to-noise ratio.

renumber_runs_by_index(ws, peaks)

Re-label the runs by index based on goniometer setting.

save_hkl_cw(filename, peaks)

Save peaks in SHELXL CW format sorted by d-spacing.

save_peaks(filename, peaks)

Save peaks file.

scan_threshold(md, peaks, min_Q)

Scan peak density threshold from predicted peaks and minimum Q.

set_goniometer(peaks, R)

Update the goniometer on the run.

sort_peaks_by_bank(peaks)

Sort peaks table by ascending bank number

sort_peaks_by_d(peaks)

Sort peaks table by descending d-spacing.

sort_peaks_by_hkl(peaks)

Sort peaks table by descending hkl values.

update_scale_factor(peaks, value)

Update counting statistic refrence value for normalization

extract_peaks_roi

get_number_peaks

index_peaks

remove_aluminum_contamination

reset_satellites

add_peak(peaks, hkl)[source]#

Add a peak to an existing table.

Parameters:
peaksstr

Name of peaks table.

hkllist

Miller index.

centroid_peaks(md, peaks, peak_radius)[source]#

Re-center peak locations using centroid within given radius

Parameters:
mdstr

Name of Q-sample.

peaksstr

Name of peaks table.

peak_radiusfloat

Integration region radius.

combine_peaks(peaks, merge)[source]#

Merge two peaks workspaces into one.

Parameters:
peaksstr

Name of peaks table to be added.

mergestr

Name of peaks table to be accumulated.

convert_peaks(peaks)[source]#

Remove instrument from peaks.

Parameters:
peaksstr

Name of peaks table.

create_peaks(ws, peaks, lean=False)[source]#

Create a new peaks table.

wsstr

Name of workspace.

peaksstr

Name of peaks table.

delete_peaks(peaks)[source]#

Remove peaks.

Parameters:
peaksstr

Name of peaks table to be added.

extract_peaks_roi(md, peaks, r_cut, n_bins=21)[source]#
filter_unique_hkl(peaks, unique_peaks)[source]#

Keep one representative per unique (h,k,l,m,n,p) group.

The representative is the peak whose wavelength is closest to the median wavelength of the group (middle-wavelength observation).

Parameters:
peaksstr

Name of input peaks table.

unique_peaksstr

Name of output peaks table with one peak per unique Miller index.

find_peaks(md, peaks, min_Q, density=50, max_peaks=1000)[source]#

Harvest strong peak locations from Q-sample into a peaks table.

Parameters:
mdstr

Name of Q-sample.

peaksstr

Name of peaks table.

min_Qfloat

Minimum Q-spacing enforcing lower limit of peak spacing.

densityint, optional

Threshold density. The default is 1000.

max_peaksint, optional

Maximum number of peaks to find. The default is 50.

get_UB(ws)[source]#

Obtain UB from the oriented lattice.

Parameters:
wsstr

Workspace with UB defined on oriented lattice.

Returns:
UB2d-array

UB matrix.

get_all_goniometer_matrices(ws)[source]#

Extract all goniometer matrices.

Parameters:
wsstr

Name of workspace with goniometer indexing.

Returns:
Rs: list

Goniometer matrices.

get_bank_names(peaks)[source]#

Obtain the bank names.

Parameters:
peaksstr

Name of peaks table.

Returns:
banksstr

Unique bank names.

get_max_d_spacing(ws)[source]#

Obtain the maximum d-spacing from the oriented lattice.

Parameters:
wsstr

Workspace with UB defined on oriented lattice.

Returns:
d_maxfloat

Maximum d-spacing.

get_number_peaks()[source]#
get_peaks_name(peaks)[source]#

Name of peaks.

Returns:
namestr

Readable name of peaks.

index_peaks(peaks, tol=np.float64(0.3466806371753174))[source]#
integrate_peaks(md, peaks, peak_radius, radius_scale=0, background_inner_fact=np.float64(1.2599210498948734), background_outer_fact=np.float64(1.4422495703074083), method='ellipsoid', centroid=True, update=True)[source]#

Integrate peaks using spherical or ellipsoidal regions. Ellipsoid integration adapts itself to the peak distribution.

Parameters:
mdstr

Name of Q-sample.

peaksstr

Name of peaks table.

peak_radiusfloat

Integration region radius.

radius_scalefloat, optional

Radius scale factor with |Q|. The default is 0.

background_inner_factfloat, optional

Factor of peak radius for background shell. The default is 1.

background_outer_factfloat, optional

Factor of peak radius for background shell. The default is 1.5.

methodstr, optional

Integration method. The default is ‘sphere’.

centroidbool, optional

Shift peak position to centroid. The default is True.

updatebool, optional

Update peak position. The defualt is True.

intensity_profile(md, peaks, peak_radius, background_inner_fact=1, background_outer_fact=1.5)[source]#

Integrate peak intensity as profile.

Parameters:
mdstr

Name of Q-sample.

peaksstr

Name of peaks table.

peak_radiusfloat

Integrat region radius cut off.

background_inner_factfloat, optional

Factor of peak radius for background shell. The default is 1.

background_outer_factfloat, optional

Factor of peak radius for background shell. The default is 1.5.

Returns:
xlist

Peak profile.

ylist

Peak intensity.

lamdalist

Peak wavelength.

intensity_projection(md, peaks, peak_radius, background_inner_fact=1, background_outer_fact=1.5)[source]#

Integrate peak intensity as profile.

Parameters:
mdstr

Name of Q-sample.

peaksstr

Name of peaks table.

peak_radiusfloat

Integrat region radius cut off.

background_inner_factfloat, optional

Factor of peak radius for background shell. The default is 1.

background_outer_factfloat, optional

Factor of peak radius for background shell. The default is 1.5.

Returns:
xlist

Peak projection.

ylist

Peak intensity.

thetalist

Peak angle.

intensity_vs_radius(md, peaks, peak_radius, background_inner_fact=1, background_outer_fact=1.5, steps=51, fix=False)[source]#

Integrate peak intensity with radius varying from zero to cut off.

Parameters:
mdstr

Name of Q-sample.

peaksstr

Name of peaks table.

peak_radiusfloat

Integration region radius cut off.

background_inner_factfloat, optional

Factor of peak radius for background shell. The default is 1

background_outer_factfloat, optional

Factor of peak radius for background shell. The default is 1.5.

stepsint, optional

Number of integration steps. The default is 101.

fixbool, optional

Fix the background shell size

Returns:
radiuslist

Peak radius.

sig_noiselist

Peak signal/noise ratio at lowest threshold.

intenslist

Peak intensity.

load_peaks(filename, peaks)[source]#

Load peaks file.

Parameters:
filenamestr

Name of peaks file with extension .nxs.

peaksstr

Name of peaks table.

predict_modulated_peaks(peaks, centering, d_min, lamda_min, lamda_max, mod_vec_1=[0, 0, 0], mod_vec_2=[0, 0, 0], mod_vec_3=[0, 0, 0], max_order=0, cross_terms=False)[source]#

Predict the modulated peak positions based on main peaks.

Parameters:
wsstr

Name of workspace to predict peaks with UB.

peaksstr

Name of main peaks table.

centeringstr

Lattice centering that provides the reflection condition.

d_minfloat

The lower d-spacing resolution to predict peaks.

lamda_min, lamda_maxfloat

The wavelength band over which to predict peaks.

mod_vec_1, mod_vec_2, mod_vec_3list, optional

Modulation vectors. The default is [0,0,0].

max_orderint, optional

Maximum order greater than zero for satellites. The default is 0.

cross_termsbool, optional

Include modulation cross terms. The default is False.

predict_peaks(ws, peaks, centering, d_min, lamda_min, lamda_max)[source]#

Predict peak Q-sample locations with UB and lattice centering.

Symbol

Reflection condition

P

None

I

\(h+k+l=2n\)

F

\(h,k,l\) unmixed

R

\(-h+k+l=3n\) or \(-h+k+l=3n\)

R(obv)

\(-h+k+l=3n\)

R(rev)

\(h-k+l=3n\)

A

\(k+l=2n\)

B

\(l+h=2n\)

C

\(h+k=2n\)

Parameters:
wsstr

Name of workspace to predict peaks with UB.

peaksstr

Name of peaks table.

centeringstr

Lattice centering that provides the reflection condition.

d_minfloat

The lower d-spacing resolution to predict peaks.

lamda_min, lamda_maxfloat

The wavelength band over which to predict peaks.

predict_satellite_peaks(peaks_ws, data_ws, centering, lamda_min, lamda_max, d_min, mod_vec_1=[0, 0, 0], mod_vec_2=[0, 0, 0], mod_vec_3=[0, 0, 0], max_order=0, cross_terms=False)[source]#

Locate satellite peaks from goniometer angles.

Parameters:
peaks_wsstr

Reference peaks table.

data_wsstr

Q-sample data with goniometer(s).

centeringstr

Lattice centering that provides the reflection condition.

lamda_minfloat

Minimum wavelength.

lamda_maxfloat

Maximum wavelength.

d_minfloat

The lower d-spacing resolution to predict peaks.

mod_vec_1, mod_vec_2, mod_vec_3list, optional

Modulation vectors. The default is [0,0,0].

max_orderint, optional

Maximum order greater than zero for satellites. The default is 0.

cross_termsbool, optional

Include modulation cross terms. The default is False.

remove_aluminum_contamination(peaks, d_min, d_max, delta=0.1)[source]#
remove_duplicate_peaks(peaks)[source]#

Omit duplicate peaks from different based on indexing. Table will be sorted.

Parameters:
peaksstr

Name of peaks table.

remove_peaks_by_d_tolerance(peaks, tol=0.05)[source]#

Filter out peaks based on d-spacing tolerance.

Parameters:
peaksstr

Name of peaks table.

tolfloat, optional

d-spacing tolerance. The default is 0.05.

remove_unindexed_peaks(peaks)[source]#

Filter out unindexes peaks.

Parameters:
peaksstr

Name of peaks table.

remove_weak_peaks(peaks, sig_noise=3)[source]#

Filter out weak peaks based on signal-to-noise ratio.

Parameters:
peaksstr

Name of peaks table.

sig_noisefloat, optional

Minimum signal-to-noise ratio. The default is 3.

renumber_runs_by_index(ws, peaks)[source]#

Re-label the runs by index based on goniometer setting.

Parameters:
wsstr

Name of workspace with goniometer indexing.

peaksstr

Name of peaks table.

reset_satellites(peaks)[source]#
save_hkl_cw(filename, peaks)[source]#

Save peaks in SHELXL CW format sorted by d-spacing.

Parameters:
filenamestr

Name of output file with extension .hkl.

peaksstr

Name of peaks table.

save_peaks(filename, peaks)[source]#

Save peaks file.

Parameters:
filenamestr

Name of peaks file with extension .nxs.

peaksstr

Name of peaks table.

scan_threshold(md, peaks, min_Q)[source]#

Scan peak density threshold from predicted peaks and minimum Q.

Parameters:
mdstr

Name of Q-sample.

peaksstr

Name of predicted peaks table.

min_Qfloat

Minimum Q-spacing enforcing lower limit of peak spacing.

set_goniometer(peaks, R)[source]#

Update the goniometer on the run.

Parameters:
peaksstr

Name of peaks table.

R2d-array

Goniometer matrix.

sort_peaks_by_bank(peaks)[source]#

Sort peaks table by ascending bank number

Parameters:
peaksstr

Name of peaks table.

sort_peaks_by_d(peaks)[source]#

Sort peaks table by descending d-spacing.

Parameters:
peaksstr

Name of peaks table.

sort_peaks_by_hkl(peaks)[source]#

Sort peaks table by descending hkl values.

Parameters:
peaksstr

Name of peaks table.

update_scale_factor(peaks, value)[source]#

Update counting statistic refrence value for normalization

Parameters:
value: float

Monitor count or proton charge

garnet.reduction.plan module#

class Dumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)[source]#

Bases: SafeDumper

Methods

add_implicit_resolver

add_multi_representer

add_path_resolver

add_representer

analyze_scalar

anchor_node

ascend_resolver

check_empty_document

check_empty_mapping

check_empty_sequence

check_resolver_prefix

check_simple_key

choose_scalar_style

close

descend_resolver

determine_block_hints

dispose

emit

expect_alias

expect_block_mapping

expect_block_mapping_key

expect_block_mapping_simple_value

expect_block_mapping_value

expect_block_sequence

expect_block_sequence_item

expect_document_end

expect_document_root

expect_document_start

expect_first_block_mapping_key

expect_first_block_sequence_item

expect_first_document_start

expect_first_flow_mapping_key

expect_first_flow_sequence_item

expect_flow_mapping

expect_flow_mapping_key

expect_flow_mapping_simple_value

expect_flow_mapping_value

expect_flow_sequence

expect_flow_sequence_item

expect_node

expect_nothing

expect_scalar

expect_stream_start

flush_stream

generate_anchor

ignore_aliases

increase_indent

need_events

need_more_events

open

prepare_anchor

prepare_tag

prepare_tag_handle

prepare_tag_prefix

prepare_version

process_anchor

process_scalar

process_tag

represent

represent_binary

represent_bool

represent_data

represent_date

represent_datetime

represent_dict

represent_float

represent_int

represent_list

represent_mapping

represent_none

represent_scalar

represent_sequence

represent_set

represent_str

represent_undefined

represent_yaml_object

resolve

serialize

serialize_node

write_double_quoted

write_folded

write_indent

write_indicator

write_line_break

write_literal

write_plain

write_single_quoted

write_stream_end

write_stream_start

write_tag_directive

write_version_directive

represent_list(data)[source]#
yaml_representers = {<class 'NoneType'>: <function SafeRepresenter.represent_none>, <class 'bool'>: <function SafeRepresenter.represent_bool>, <class 'bytes'>: <function SafeRepresenter.represent_binary>, <class 'datetime.date'>: <function SafeRepresenter.represent_date>, <class 'datetime.datetime'>: <function SafeRepresenter.represent_datetime>, <class 'dict'>: <function SafeRepresenter.represent_dict>, <class 'float'>: <function SafeRepresenter.represent_float>, <class 'int'>: <function SafeRepresenter.represent_int>, <class 'list'>: <function Dumper.represent_list>, <class 'set'>: <function SafeRepresenter.represent_set>, <class 'str'>: <function SafeRepresenter.represent_str>, <class 'tuple'>: <function SafeRepresenter.represent_list>, None: <function SafeRepresenter.represent_undefined>}[source]#
class ReductionPlan[source]#

Bases: object

Methods

generate_plan(instrument)

Create a template plan.

load_plan(filename)

Load a data reduction plan.

runs_list_to_string(runs)

Convert runs list to string with step notation.

runs_string_to_list(runs_str)

Convert runs string to list.

save_plan(filename[, set_output])

Save a data reduction plan.

set_output(filename)

Change the output directory and name.

template_integration(instrument)

Generate template integration plan.

template_normalization()

Generate template normalization plan.

template_parametrization()

Generate template parametrization plan.

check

validate_file

validate_plan

check(*args, **kwargs)[source]#
generate_plan(instrument)[source]#

Create a template plan.

Parameters:
instrumentstr

Beamline name.

load_plan(filename)[source]#

Load a data reduction plan.

Parameters:
filenamestr

yaml file of reduction plan.

runs_list_to_string(runs)[source]#

Convert runs list to string with step notation.

Parameters:
runslist

Integer run numbers.

Returns:
runs_strstr

Condensed notation for run numbers, including step notation.

runs_string_to_list(runs_str)[source]#

Convert runs string to list.

Parameters:
runs_strstr

Condensed notation for run numbers.

Returns:
runslist

Integer run numbers.

save_plan(filename, set_output=True)[source]#

Save a data reduction plan.

Parameters:
filenamestr

yaml file of reduction plan.

set_output(filename)[source]#

Change the output directory and name.

Parameters:
filenamestr

yaml file of reduction plan.

template_integration(instrument)[source]#

Generate template integration plan.

Parameters:
instrumentstr

Beamline name.

Returns:
paramsdict

Integration plan.

template_normalization()[source]#

Generate template normalization plan.

Parameters:
instrumentstr

Beamline name.

Returns:
paramsdict

Integration plan.

template_parametrization()[source]#

Generate template parametrization plan.

Parameters:
instrumentstr

Beamline name.

Returns:
paramsdict

Integration plan.

validate_file(fname, ext)[source]#
validate_plan()[source]#
class SubPlan(plan)[source]#

Bases: object

Methods

append_name(file)

Update filename with identifier name.

get_diagnostic_file(name[, ext])

Diagnostic file.

get_diagnostic_path()

Diagnostic path.

get_output_file([ext])

Output file.

get_output_path()

Output path.

get_plot_file(name[, ext])

Plot file.

get_plot_path()

Plot path.

check

cleanup

create_directories

append_name(file)[source]#

Update filename with identifier name.

Parameters:
filestr

Original file name.

Returns:
output_filestr

File with updated name for identifier name.

check(*args, **kwargs)[source]#
cleanup()[source]#
create_directories()[source]#
get_diagnostic_file(name, ext='.nxs')[source]#

Diagnostic file.

Returns:
namestr

Name to use for file.

diag_filestr

Path name to save diagnostics file.

get_diagnostic_path()[source]#

Diagnostic path.

Returns:
diag_pathstr

Path to save diagnostics file.

get_output_file(ext='.nxs')[source]#

Output file.

Returns:
output_filestr

Output file.

get_output_path()[source]#

Output path.

Returns:
output_pathstr

Output path.

get_plot_file(name, ext='.png')[source]#

Plot file.

Returns:
namestr

Name to use for file.

plot_filestr

Path name to save plots file.

get_plot_path()[source]#

Plot path.

Returns:
plot_pathstr

Path to save plots file.

check(value, op, other=None, message=None)[source]#

General-purpose assertion with flexible condition types.

Parameters:
valueany

Parameter.

opstr

Conditional operator.

otherTYPE, optional

Reference value. The default is None.

messagestr, optional

Invalid message. The default is None.

Raises:
ValueError

Invalud operator.

TypeError

Invalud conditional.

AssertionError

Invalid value.

Examples

check(3, ‘>’, 0) check(5, ‘in’, [1, 3, 5]) check(None, ‘is’, None) check(3, lambda v: v % 2 == 1)

delete_directory(path)[source]#

Fast removal of nonempty directories.

Parameters:
pathstr

Directory to remove.

load_YAML(filename)[source]#

Load reduction input file.

Parameters:
filenamestr

Output file name.

Returns:
outputdict

Parameters.

save_JSON(output, filename)[source]#

Save reduction output file.

Parameters:
outputstr

Name of file.

filenamestr

Output file name.

save_YAML(output, filename)[source]#

Save reduction output file.

Parameters:
outputdict

Parameters.

filenamestr

Output file name.

garnet.reduction.resolution module#

class ResolutionEllipsoid(peaks_ws, r_cut=inf, sig_noise_cut=5.0, min_peaks=10, scale_bounds=(0.5, 2.0), mosaic='isotropic')[source]#

Bases: object

Methods

estimate_prior_sigmas([moment_covs])

Estimate prior width for covariance and centroid parameters.

robust_nnls(A, y[, max_iter, c, eps])

Robust NNLS using Huber-style iterative reweighting.

apply

diagnostics

fit

plot_diagnostics

predict_lab_cov

predict_sample_cov

apply()[source]#
diagnostics()[source]#
estimate_prior_sigmas(moment_covs=None)[source]#

Estimate prior width for covariance and centroid parameters.

Parameters:
moment_covsdict or None

{peak_index: (3,3) sample-frame empirical covariance} from PeakEstimator.moment_covs. When provided these true data-driven observations are used instead of the peak shapes in the workspace (which are set by res.apply() and are trivially 1:1 with the model).

fit()[source]#
plot_diagnostics(filename)[source]#
predict_lab_cov(peak_index)[source]#
predict_sample_cov(peak_index)[source]#
robust_nnls(A, y, max_iter=20, c=1.345, eps=1e-12)[source]#

Robust NNLS using Huber-style iterative reweighting. A x ~= y, x >= 0

garnet.reduction.sample module#

class SampleMaterial(plan, filename)[source]#

Bases: object

Methods

get_material

get_sample_material

get_shape

save_ellipsoid_stl

set_material

set_sample

set_shape

verify_chemical_formula

get_material()[source]#
get_sample_material()[source]#
get_shape()[source]#
save_ellipsoid_stl(filename='/tmp/ellipsoid.stl')[source]#
set_material(material)[source]#
set_sample(sample)[source]#
set_shape(filename)[source]#
verify_chemical_formula(formula)[source]#

garnet.reduction.ub module#

class FindUB(peaks, a, b, c, alpha, beta, gamma, tol=0.12)[source]#

Bases: object

Methods

metric_tensor(a, b, c, alpha, beta, gamma)

Calculate the metric tensor \(G\).

objective(x)

Objective function.

orientation_matrix(u0, u1, u2)

The sample orientation matrix \(U\).

cost

get_UB

cost(x)[source]#
get_UB(x)[source]#
metric_tensor(a, b, c, alpha, beta, gamma)[source]#

Calculate the metric tensor \(G\).

Returns:
G2d-array

3x3 matrix of lattice parameter info for Cartesian transforms.

objective(x)[source]#

Objective function.

Parameters:
xarray

Refineable parameters.

Returns:
neg_indint

Negative number of peaks indexed.

orientation_matrix(u0, u1, u2)[source]#

The sample orientation matrix \(U\).

Parameters:
u0, u1, u2float

Rotation paramters.

Returns:
U2d-array

3x3 sample orientation matrix.

class Optimization(peaks, tol=0.1)[source]#

Bases: object

Methods

get_UB()

Current UB matrux.

get_lattice_parameters()

Current lattice parameters.

get_orientation_angles()

Current orientation angles.

optimize_lattice(cell[, n_cycles, sigma_cut])

Refine the orientation and lattice parameters under constraints.

optimize_lattice_only(cell[, n_cycles, ...])

Refine lattice parameters under cell constraints with U fixed.

residual(x, hkl, Q, fun[, W, weights])

Optimization residual function.

B_matrix

U_matrix

cubic

fixed

hexagonal

monoclinic

orthorhombic

rhombohedral

tetragonal

triclinic

whiten_weight_matrix

B_matrix(a, b, c, alpha, beta, gamma)[source]#
U_matrix(phi, theta, omega)[source]#
cubic(x)[source]#
fixed(x)[source]#
get_UB()[source]#

Current UB matrux.

Returns:
UB2d-array

UB-matrix.

get_lattice_parameters()[source]#

Current lattice parameters.

Returns:
a, b, cfloat

Lattice constants in angstroms.

alpha, beta, gammafloat

Lattice angles in degrees.

get_orientation_angles()[source]#

Current orientation angles.

Returns:
phifloat

Rotation axis azimuthal angle in radians.

thetafloat

Rotation axis polar angle in radians.

omegafloat

Rotation angle in radians.

hexagonal(x)[source]#
monoclinic(x)[source]#
optimize_lattice(cell, n_cycles=5, sigma_cut=3.0)[source]#

Refine the orientation and lattice parameters under constraints.

Iterates least-squares refinement with I/σ weighting and σ-clipping outlier rejection. After each cycle peaks whose unweighted residual norm exceeds sigma_cut times the median are removed, and the next cycle starts from the previous solution.

Parameters:
cellstr

Lattice centering to constrain parameters.

n_cyclesint, optional

Maximum number of sigma-clipping cycles. The default is 5.

sigma_cutfloat, optional

Outlier rejection threshold in units of the median residual norm. The default is 3.0.

optimize_lattice_only(cell, n_cycles=5, sigma_cut=3.0)[source]#

Refine lattice parameters under cell constraints with U fixed.

The crystal orientation (U matrix) is held constant; only the free lattice parameters allowed by cell are optimized.

Parameters:
cellstr

Lattice system to constrain parameters.

n_cyclesint, optional

Maximum number of sigma-clipping cycles. The default is 5.

sigma_cutfloat, optional

Outlier rejection threshold in units of the median residual norm. The default is 3.0.

orthorhombic(x)[source]#
residual(x, hkl, Q, fun, W=array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]), weights=None)[source]#

Optimization residual function.

Parameters:
xlist

Parameters.

hkllist

Miller indices.

Qlist

Q-sample vectors.

funfunction

Lattice constraint function.

W: 3x3-array

Weight matrix.

weights1d-array, optional

Per-peak scalar weights (e.g. I/σ). The default is None (uniform).

Returns:
residuallist

Least squares residuals.

rhombohedral(x)[source]#
tetragonal(x)[source]#
triclinic(x)[source]#
whiten_weight_matrix(Q)[source]#
class RefineSingleCrystalGoniometer(peaks, tol=0.12, cell='Triclinic', n_iter=1)[source]#

Bases: object

Methods

get_lattice_parameters()

Current lattice parameters.

get_orientation_angles()

Current orientation angles.

optimize_lattice(cell)

Refine the orientation and lattice parameters under constraints.

residual(x, peak_dict, func)

Optimization residual function.

B_matrix

U_matrix

calculate_goniometer

cubic

fixed

hexagonal

monoclinic

orthorhombic

rhombohedral

tetragonal

triclinic

B_matrix(a, b, c, alpha, beta, gamma)[source]#
U_matrix(phi, theta, omega)[source]#
calculate_goniometer(omega, chi, phi)[source]#
cubic(x)[source]#
fixed(x)[source]#
get_lattice_parameters()[source]#

Current lattice parameters.

Returns:
a, b, cfloat

Lattice constants in angstroms.

alpha, beta, gammafloat

Lattice angles in degrees.

get_orientation_angles()[source]#

Current orientation angles.

Returns:
phifloat

Rotation axis azimuthal angle in radians.

thetafloat

Rotation axis polar angle in radians.

omegafloat

Rotation angle in radians.

hexagonal(x)[source]#
monoclinic(x)[source]#
optimize_lattice(cell)[source]#

Refine the orientation and lattice parameters under constraints.

Parameters:
cellstr

Lattice centering to constrain paramters.

orthorhombic(x)[source]#
residual(x, peak_dict, func)[source]#

Optimization residual function.

Parameters:
xlist

Parameters.

peak_dictdictionary

Goniometer angles, Q-lab vectors, Miller indices. .

funcfunction

Lattice constraint function.

Returns:
residuallist

Least squares residuals.

rhombohedral(x)[source]#
tetragonal(x)[source]#
triclinic(x)[source]#
class Reorient(peaks, crystal_system='Triclinic', lattice_system=None)[source]#

Bases: object

Methods

cell_symmetry_matrices

minimize

cell_symmetry_matrices(crystal_system, lattice_system)[source]#
minimize(transforms, tol=0.12)[source]#
class UBModel(peaks)[source]#

Bases: object

Methods

calculate_hkl()

Calculate hkl values without rounding.

copy_UB(workspace)

Copy UB to another workspace.

determine_UB_with_lattice_parameters(a, b, ...)

Determine UB with prior known lattice parameters.

determine_UB_with_primitive_cell(min_d, max_d)

Determine UB with primitive lattice using min/max lattice constant.

generate_lattice_transforms(cell)

Obtain possible transforms compatabile with a unit cell lattice.

get_lattice_parameters()

Current lattice parameters.

get_max_d_spacing()

Obtain the maximum d-spacing from the oriented lattice.

has_UB()

Check if peaks table has a UB determined.

index_peaks([tol, sat_tol, mod_vec_1, ...])

Index the peaks and calculate the lattice parameter uncertainties.

load_UB(filename[, run_number])

Load UB from file.

possible_conventional_cells([max_error, ...])

List possible conventional cells.

refine_UB_with_constraints(cell[, tol])

Refine UB with constraints corresponding to lattice system.

refine_UB_without_constraints([tol, sat_tol])

Refine UB with unconstrained lattice parameters.

refine_U_only(a, b, c, alpha, beta, gamma)

Refine the U orientation only.

save_UB(filename)

Save UB to file.

select_cell(number[, tol])

Transform to conventional cell using form number.

select_type(cell, centering[, tol])

Transform to conventional cell using cell and centering type.

transform_lattice(transform[, tol])

Apply a cell transformation to the lattice.

calculate_transform_extents

centering_matrix

convert_conventional_to_primitive

get_primitive_cell_length_range

shortest_reciprocal_spacing

transform_conventional_to_primitive

transform_primitive_to_conventional

calculate_hkl()[source]#

Calculate hkl values without rounding.

calculate_transform_extents(centering)[source]#
centering_matrix(centering)[source]#
convert_conventional_to_primitive(a, b, c, alpha, beta, gamma, centering)[source]#
copy_UB(workspace)[source]#

Copy UB to another workspace.

Parameters:
workspacefloat

Target workspace to copy the UB to.

determine_UB_with_lattice_parameters(a, b, c, alpha, beta, gamma, tol=0.2)[source]#

Determine UB with prior known lattice parameters.

Parameters:
a, b, cfloat

Lattice constants in angstroms.

alpha, beta, gammafloat

Lattice angles in degrees.

tolfloat, optional

Indexing tolerance. The default is 0.1.

determine_UB_with_primitive_cell(min_d, max_d, tol=0.15)[source]#

Determine UB with primitive lattice using min/max lattice constant.

Parameters:
min_dfloat

Minimum lattice parameter in ansgroms.

max_dfloat

Maximum lattice parameter in angstroms.

tolfloat, optional

Indexing tolerance. The default is 0.15.

generate_lattice_transforms(cell)[source]#

Obtain possible transforms compatabile with a unit cell lattice.

Parameters:
cellstr

Latttice system.

Returns:
transformsdict

Transform dictionary with symmetry operation as key.

get_lattice_parameters()[source]#

Current lattice parameters.

Returns:
a, b, cfloat

Lattice constants in angstroms.

alpha, beta, gammafloat

Lattice angles in degrees.

get_max_d_spacing()[source]#

Obtain the maximum d-spacing from the oriented lattice.

Returns:
d_maxfloat

Maximum d-spacing.

get_primitive_cell_length_range(centering)[source]#
has_UB()[source]#

Check if peaks table has a UB determined.

index_peaks(tol=0.15, sat_tol=None, mod_vec_1=[0, 0, 0], mod_vec_2=[0, 0, 0], mod_vec_3=[0, 0, 0], max_order=0, cross_terms=False)[source]#

Index the peaks and calculate the lattice parameter uncertainties.

Parameters:
tolfloat, optional

Indexing tolerance. The default is 0.1.

sat_tolfloat, optional

Satellite indexing tolerance. The default is None.

mod_vec_1, mod_vec_2, mod_vec_3list, optional

Modulation vectors. The default is [0,0,0].

max_orderint, optional

Maximum order greater than zero for satellites. The default is 0.

cross_termsbool, optional

Include modulation cross terms. The default is False.

Returns:
indexinglist

Result of indexing including number indexed and errors.

load_UB(filename, run_number=None)[source]#

Load UB from file.

Parameters:
filenamestr

Name of UB file with extension .mat.

run_numberstr, optional

Run number to replace starred expression.

possible_conventional_cells(max_error=0.2, permutations=True)[source]#

List possible conventional cells.

Parameters:
max_errorfloat, optional

Max scalar error to report form numbers. The default is 0.2.

permutationsbool, optional

Allow permutations of the lattice. The default is True.

Returns:
valslist

List of form results.

refine_UB_with_constraints(cell, tol=0.1)[source]#

Refine UB with constraints corresponding to lattice system.

Lattice system

Lengths

Angles

Cubic

\(a=b=c\)

\(α=β=γ=90\)

Hexagonal

\(a=b\)

\(α=β=90,γ=120\)

Rhombohedral

\(a=b=c\)

\(α=β=γ\)

Tetragonal

\(a=b\)

\(α=β=γ=90\)

Orthorhombic

None

\(α=β=γ=90\)

Monoclinic

None

\(α=γ=90\)

Triclinic

None

None

Parameters:
cellfloat

Lattice system.

tolfloat, optional

Indexing tolerance. The default is 0.1.

refine_UB_without_constraints(tol=0.1, sat_tol=None)[source]#

Refine UB with unconstrained lattice parameters.

Parameters:
tolfloat, optional

Indexing tolerance. The default is 0.1.

sat_tolfloat, optional

Satellite indexing tolerance. The default is None.

refine_U_only(a, b, c, alpha, beta, gamma)[source]#

Refine the U orientation only.

Parameters:
a, b, cfloat

Lattice constants in angstroms.

alpha, beta, gammafloat

Lattice angles in degrees.

save_UB(filename)[source]#

Save UB to file.

Parameters:
filenamestr

Name of UB file with extension .mat.

select_cell(number, tol=0.1)[source]#

Transform to conventional cell using form number.

Parameters:
numberint

Form number.

tolfloat, optional

Indexing tolerance. The default is 0.1.

select_type(cell, centering, tol=0.1)[source]#

Transform to conventional cell using cell and centering type.

Parameters:
cellstr

Cell type.

centeringstr

Centering type.

tolfloat, optional

Indexing tolerance. The default is 0.1.

shortest_reciprocal_spacing(centering, max_index=2)[source]#
transform_conventional_to_primitive(centering)[source]#
transform_lattice(transform, tol=0.1)[source]#

Apply a cell transformation to the lattice.

Parameters:
transform3x3 array-like

Transform to apply to hkl values.

tolfloat, optional

Indexing tolerance. The default is 0.1.

transform_primitive_to_conventional(centering)[source]#

Module contents#