Pressure calibration

Functions to do pressure calibration using Au or Ag diffraction.

load_ag_params(temperature)

Load the Ag parameters for calculating the pressure.

load_au_params(temperature)

Load the Au parameters for calculating the pressure.

calculate_tth(pressure, temperature, energy, ...)

Calculate the two theta of Au or Ag Bragg peak of given a pressure.

calculate_pressure(tth, temperature, energy, ...)

Calculate the pressure using diffraction from Au, Ag, or Pt.

xrd_calibrate_pressure(scan, source[, ...])

Calibrate pressure using x-ray diffraction.

polartools.pressure_calibration.calculate_pressure(tth, temperature, energy, bragg_peak, calibrant, tth_off=0.0)[source]

Calculate the pressure using diffraction from Au, Ag, or Pt.

For Au and Ag see Holzapfel et al., J. Phys. Chem. Ref. Data 30, 515 (2001) for more details.

For Pt see Holmes et al., J. Appl. Phys. 66, 2962–2967 (1989) for more details.

Parameters:
tthfloat or iterable

Two theta of the selected Bragg peak. It can be a list of two theta.

temperaturefloat

Measurement temperature in Kelvin.

energyfloat

X-ray energy used in keV.

bragg_peakiterable

List containing the Bragg peak indices [H, K, L].

calibrantstring

Selects the calibrant used. Options are ‘Au’, ‘Ag’, or ‘Pt’.

tth_offfloat, optional

Offset between the reference two theta and the measured value.

Returns:
pressurefloat or numpy.array

Calculated pressure in GPa. A numpy.array is returned if an iterable is passed to tth.

polartools.pressure_calibration.calculate_tth(pressure, temperature, energy, bragg_peak, calibrant, tth_off=0.0)[source]

Calculate the two theta of Au or Ag Bragg peak of given a pressure.

See Holzapfel et al., J. Phys. Chem. Ref. Data 30, 515 (2001) for more details.

Parameters:
pressurefloat or iterable

Pressure (or list of) to be converted.

temperaturefloat

Measurement temperature in Kelvin.

energyfloat

X-ray energy used in keV.

bragg_peakiterable

List containing the Bragg peak indices [H, K, L].

calibrantstring

Selects the calibrant used. Options are ‘Au’ or ‘Ag’.

tth_offfloat, optional

Offset between the reference two theta and the measured value.

Returns:
tthfloat or numpy.array

Calculated tth in degrees. A numpy.array is returned if an iterable is passed to pressure.

polartools.pressure_calibration.fit_bragg_peak(x, y, center=None, sigma=None, amplitude=None, fraction=None, fit_fraction=True, slope=None, intercept=None, fit_slope=True)[source]

Fit Bragg peak with a pseudo-voigt function.

Uses lmfit (https://lmfit.github.io/lmfit-py/).

WARNING: This imposes constrains to the fit that are described in polartools.pressure_calibration._generate_initial_guess

Parameters:
xiterable

List of x-axis values.

yiterable

List of y-axis values.

center, sigma, amplitude, fractionfloat, optional

Initial guess parameters of pseudo-voigt function. For more details, see: :func: lmfit.models.PseudoVoigtModel

fit_fractionboolean, optional

Flag to control if fraction will be varied.

slope, interceptfloat, optional

Initial guess parameters of linear function. For more details, see: :func: lmfit.models.LinearModel

fit_slopeboolean, optional

Flag to control if slope will be varied.

Returns:
fitlmfit ModelResult class

Contains the fit results. See: https://lmfit.github.io/lmfit-py/model.html#the-modelresult-class

See also

lmfit.models.PseudoVoigtModel()
lmfit.models.LinearModel()
polartools.pressure_calibration.load_ag_params(temperature)[source]

Load the Ag parameters for calculating the pressure.

These parameters were extracted from Holzapfel et al., J. Phys. Chem. Ref. Data 30, 515 (2001). It linearly interpolates the data.

Parameters:
temperaturefloat

Measurement temperature in Kelvin.

Returns:
v0_out, k0_out, kp0_outfloat

Volume, K and K’ calibration parameters.

polartools.pressure_calibration.load_au_params(temperature)[source]

Load the Au parameters for calculating the pressure.

These parameters were extracted from Holzapfel et al., J. Phys. Chem. Ref. Data 30, 515 (2001). It linearly interpolates the data.

Parameters:
temperaturefloat

Measurement temperature in Kelvin.

Returns:
v0_out, k0_out, kp0_outfloat

Volume, K and K’ calibration parameters.

polartools.pressure_calibration.xrd_calibrate_pressure(scan, source, bragg_peak=(1, 1, 1), calibrant='Au', temperature=300, energy='monochromator_energy', positioner='huber_tth', detector='APDSector4', monitor=None, center=None, sigma=None, amplitude=None, fraction=None, fit_fraction=True, slope=None, intercept=None, fit_slope=True, tth_offset=0.0, **kwargs)[source]

Calibrate pressure using x-ray diffraction.

This is a wrapper of multiple functions in polartools meant to make it more convenient to extract the pressure in XRD measurements.

For a given experiment, it is recommended to create a kwarg dictionary that holds the input parameters that are different from the standard defaults, and make it easier to process multiple scans. For instance:

kwargs = {'db': db, 'calibrant': 'Ag', 'temperature': 10}
pressure = xrd_calibrate_pressure(100, **kwargs)
Parameters:
scanint or string

Scan our uid. It will load the last scan with that scan_id. See kwargs for search options.

sourcedatabroker database, name of the spec file, or ‘csv’

Note that applicable kwargs depend on this selection.

bragg_peakiterable, optional

List containing the Bragg peak indices [H, K, L].

calibrantstring, optional

Selects the calibrant used. Options are ‘Au’, ‘Ag’, or ‘Pt’.

temperaturefloat or string, optional

A string can only be passed if using databroker. In this case it will read the temperature from the database baseline stream. If float is passed, then it is the temperature in Kelvin.

energyfloat or string, optional

A string can only be passed if using databroker. In this case it will read the energy from the database baseline stream. If float is passed, then it is the energy in keV.

positionerstring, optional

2 theta motor name.

detectorstring, optional

XRD detector name.

monitorstring, optional

Monitor detector name.

center, sigma, amplitude, fractionfloat, optional

Initial guess parameters of pseudo-voigt function. For more details, see: lmfit.models.PseudoVoigtModel.

fit_fractionboolean, optional

Flag to control if fraction will be varied.

slope, interceptfloat, optional

Initial guess parameters of linear function. For more details, see: lmfit.models.LinearModel.

fit_slopeboolean, optional

Flag to control if slope will be varied.

tth_offfloat, optional

Offset between the reference two theta and the measured value.

kwargs

The necessary kwargs are passed to the loading functions defined by the source argument:

  • csv -> possible kwargs: folder, name_format.

  • spec -> possible kwargs: folder.

  • databroker -> possible kwargs: stream, query, use_db_v1.

Note that a warning will be printed if the an unnecessary kwarg is passed.

Returns:
pressurefloat

Calculated pressure in GPa.

See also

polartools.load_data.load_table()
polartools.load_data.load_scan()
polartools.load_data.load_csv()
polartools.load_data.load_databroker()
polartools.process_data.fit_bragg_peak()
polartools.pressure_calibration.calculate_pressure()
lmfit.models.LinearModel()
lmfit.models.PseudoVoigtModel()