diffpy.labpdfproc package

Tools for processing x-ray powder diffraction data from laboratory sources.

Subpackages

Submodules

diffpy.labpdfproc.functions module

class diffpy.labpdfproc.functions.Gridded_circle(radius=1, n_points_on_diameter=300, mu=None)[source]

Bases: object

get_path_length(grid_point, angle)[source]

return the path length

This is the pathlength of a horizontal line entering the circle at the same height to the grid point then exiting at angle angle

Parameters:
  • floats (grid_point double of) – the coordinate inside the circle

  • float (angle) – the angle of the output beam

  • radius – the radius of the circle

Return type:

floats total distance, primary distance and secondary distance

set_distances_at_angle(angle)[source]

given an angle, set the distances from the grid points to the entry and exit coordinates

Parameters:

float (angle) – the angle in degrees

Return type:

the list of distances containing total distance, primary distance and secondary distance

set_muls_at_angle(angle)[source]

compute muls = exp(-mu*distance) for a given angle

Parameters:

float (angle) – the angle in degrees

Return type:

an array of floats containing the muls corresponding to each angle

diffpy.labpdfproc.functions.apply_corr(diffraction_pattern, absorption_correction)[source]

Apply absorption correction to the given diffraction object modo with the correction diffraction object abdo

Parameters:
  • Diffraction_object (absorption_correction) – the input diffraction object to which the cve will be applied

  • Diffraction_object – the diffraction object that contains the cve to be applied

Return type:

a corrected diffraction object with the correction applied through multiplication

diffpy.labpdfproc.functions.compute_cve(diffraction_data, mud, method='polynomial_interpolation')[source]

diffpy.labpdfproc.tools module

diffpy.labpdfproc.tools.load_metadata(args, filepath)[source]

Load relevant metadata from args

Parameters:

argparse.Namespace (args) – the arguments from the parser

Return type:

A dictionary with relevant arguments from the parser

diffpy.labpdfproc.tools.load_package_info(args)[source]

Load diffpy.labpdfproc package name and version into args using get_package_info function from diffpy.utils

Parameters:

argparse.Namespace (args) – the arguments from the parser, default is None

Return type:

the updated argparse Namespace with diffpy.labpdfproc name and version inserted

diffpy.labpdfproc.tools.load_user_info(args)[source]

Update username and email using get_user_info function from diffpy.utils

Parameters:

argparse.Namespace (args) – the arguments from the parser, default is None

Return type:

the updated argparse Namespace with username and email inserted

diffpy.labpdfproc.tools.load_user_metadata(args)[source]

Load user metadata into the provided argparse Namespace, raise ValueError if in incorrect format

Parameters:

argparse.Namespace (args) – the arguments from the parser

Return type:

the updated argparse Namespace with user metadata inserted as key-value pairs

diffpy.labpdfproc.tools.preprocessing_args(args)[source]

Perform preprocessing on the provided argparse Namespace

Parameters:

argparse.Namespace (args) – the arguments from the parser, default is None

Return type:

the updated argparse Namespace with arguments preprocessed

diffpy.labpdfproc.tools.set_input_lists(args)[source]

Set input directory and files.

It takes cli inputs, checks if they are files or directories and creates a list of files to be processed which is stored in the args Namespace.

Parameters:

argparse.Namespace (args) – the arguments from the parser

Return type:

args argparse.Namespace

diffpy.labpdfproc.tools.set_mud(args)[source]

Set the mud based on the given input arguments

Parameters:

argparse.Namespace (args) – the arguments from the parser

Return type:

args argparse.Namespace

diffpy.labpdfproc.tools.set_output_directory(args)[source]

set the output directory based on the given input arguments

Parameters:
  • argparse.Namespace (args) – the arguments from the parser

  • follows (it is determined as)

  • directory (If user provides an output)

  • it. (use)

  • Otherwise

  • provided. (we set it to the current directory if nothing is)

  • exist. (We then create the directory if it does not)

Return type:

a Path object that contains the full path of the output directory

diffpy.labpdfproc.tools.set_wavelength(args)[source]

Set the wavelength based on the given input arguments

Parameters:
  • argparse.Namespace (args) – the arguments from the parser

  • non-positive (we raise a ValueError if the input wavelength is)

  • sources (or if the input anode_type is not one of the known)

Return type:

args argparse.Namespace

diffpy.labpdfproc.mud_calculator module

diffpy.labpdfproc.mud_calculator.compute_mud(filepath)[source]

compute the best-fit mu*D value from a z-scan file

Parameters:

str (filepath) – the path to the z-scan file

Return type:

a float contains the best-fit mu*D value

diffpy.labpdfproc.labpdfprocapp module

diffpy.labpdfproc.labpdfprocapp.get_args(override_cli_inputs=None)[source]
diffpy.labpdfproc.labpdfprocapp.main()[source]