conversions

Note

conversions is also available under nexus. For example, nx.conversions.DegToRad(degree) is also available as nx.DegToRad(degree).

Module for conversions of physical properties and units.

nexus.conversions.AngleToQ(angle, energy)

Converts the grazing scattering angle to absolute of the \(q\)-vector.

New in version 1.0.3.

Parameters:
  • angle (float or list) – angle(s) to be converted (rad).

  • energy (float) – X-ray energy (eV).

Returns:

absolute of the \(q\)-vector (1/m).

Return type:

float

nexus.conversions.AtToWt(composition)

Convert material composition given in at% to wt%.

in atomic composition: composition = ([‘Fe’, 2], [‘O’, 3]) for Fe 2 O 3

or in at%: composition = ([‘Fe’, 0.4], [‘O’, 0.6])

Parameters:

composition (list) – ([‘A’, x], [‘B’, y], …) where A, B, … are element strings and x, y, … is the fraction in atomic composition or at%.

Returns:

composition with x, y, … in wt%

Return type:

list

nexus.conversions.DegToMrad(degree)

Conversion from degree to milliradians.

Parameters:

degree (double) – angle in degree.

Returns:

angle in millirad.

Return type:

double

nexus.conversions.DegToRad(degree)

Conversion from degree to radians.

Parameters:

degree (double) – angle in degree.

Returns:

angle in rad.

Return type:

double

nexus.conversions.DegToUrad(degree)

Conversion from degree to microradians.

Parameters:

degree (double) – angle in degree.

Returns:

angle in microrad.

Return type:

double

nexus.conversions.EnergyToKvector(energy)

Conversion from energy to photon k-vector.

Parameters:

energy (double) – energy in eV.

Returns:

k-vector in 1/m.

Return type:

double

nexus.conversions.EnergyToKvectorZ(energy, angle)

Conversion from energy to photon k-vector along z direction in grazing incidence direction.

Parameters:
  • energy (double) – energy in eV.

  • angle (double) – angle in degree.

Returns:

k-vector along z direction in 1/m.

Return type:

double

nexus.conversions.EnergyToVelocity(energy, isotope)

Convert a Doppler detuning from energy to velocity.

Parameters:
  • energy (float or list or ndarray) – Energy in eV.

  • isotope (MoessbauerIsotope) – Moessbauer isotope of the experiment.

Returns:

Velocity detuning in mm/s.

Return type:

float or list or ndarray

nexus.conversions.EnergyToWavelength(energy)

Conversion from energy to photon wavelength.

Parameters:

energy (double) – energy in eV.

Returns:

wavelength in meter.

Return type:

double

nexus.conversions.FwhmToSigma(fwhm)

Returns sigma of a Gaussian from its Full Width Half Maximum (FWHM).

nexus.conversions.GammaToVelocity(energy, isotope)

Convert a Doppler detuning from energy in units of the linewidth to velocity.

Parameters:
  • energy (float or list or ndarray) – Energy in units of the linewidth (\(\Gamma\)).

  • isotope (MoessbauerIsotope) – Moessbauer isotope of the experiment.

Returns:

Velocity detuning in mm/s.

Return type:

float or list or ndarray

nexus.conversions.KvectorToEnergy(kvector)

Conversion from photon k-vector to energy.

Parameters:

kvector (double) – k-vector in 1/m.

Returns:

energy in eV.

Return type:

double

nexus.conversions.MagSphericalToVector(mag, theta, phi, angle='deg')

Calculates the magnetic field in Nexus frame (\(\sigma\), \(\pi\), k) to spherical coordinates.

New in version 1.0.2.

Parameters:
  • mag (float) – magnetic field \(\sigma\) component.

  • theta (float) – polar angle.

  • phi (float) – azimuthal angle.

  • angle (string) – Units of the input angles, “rad” or “deg”.

Returns:

\(\sigma\) component, \(\pi\) component, k component.

Return type:

float, float, float

nexus.conversions.MagVectorToSpherical(sigma, pi, k, angle='deg')

Calculates the magnetic field in spherical coordinates from an input vector in the Nexus frame (\(\sigma\), \(\pi\), k).

New in version 1.0.2.

Parameters:
  • sigma (float) – \(\sigma\) component.

  • pi (float) – \(\pi\) component.

  • k (float) – k component.

  • angle (string) – Units of the returned angles, “rad” or “deg”.

Returns:

magnitude, polar angle, azimuthal angle.

Return type:

float, float, float

nexus.conversions.MradToDeg(mrad)

Conversion from milliradians to degree.

Parameters:

mrad (double) – angle in millirad.

Returns:

angle in degree.

Return type:

double

nexus.conversions.QToAngle(q, energy)

Converts the absolute of the \(q\)-vector to the grazing scattering angle.

New in version 1.0.3.

Parameters:
  • q (float or list) – absolute of the \(q\)-vector(s) (1/m).

  • energy (float) – X-ray energy (eV).

Returns:

grazing scattering angle (rad).

Return type:

float

nexus.conversions.RadToDeg(rad)

Conversion from radians to degree.

Parameters:

rad (double) – angle in rad.

Returns:

angle in degree.

Return type:

double

nexus.conversions.SigmaToFwhm(sigma)

Returns the Full Width Half Maximum (FWHM) from Gaussian sigma value.

nexus.conversions.UradToDeg(urad)

Conversion from microradians to degree.

Parameters:

urad (double) – angle in microrad.

Returns:

angle in degree.

Return type:

double

nexus.conversions.VelocityToEnergy(velocity, isotope)

Convert a Doppler detuning from velocity to energy.

Parameters:
  • velocity (float or list or ndarray) – velocity in mm/s.

  • isotope (MoessbauerIsotope) – Moessbauer isotope of the experiment.

Returns:

Energy detuning in eV.

Return type:

float or list or ndarray

nexus.conversions.VelocityToGamma(velocity, isotope)

Convert a Doppler detuning from velocity to energy in units of the linewidth.

Parameters:
  • velocity (float or list or ndarray) – Velocity in mm/s.

  • isotope (MoessbauerIsotope) – Moessbauer isotope of the experiment.

Returns:

Energy detuning in units of the linewidth (\(\Gamma\)).

Return type:

float or list or ndarray

nexus.conversions.WavelengthToEnergy(wavelength)

Conversion from photon wavelength to energy.

Parameters:

wavelength (double) – wavelength in meter.

Returns:

energy in eV.

Return type:

double

nexus.conversions.WtToAt(composition)

Convert material composition given in wt% to at%.

in wt%: composition = ([‘Fe’, 0.699], [‘O’, 0.301]) for Fe 2 O 3

Parameters:

composition (list) – ([‘A’, x], [‘B’, y], …) where A, B, … are element strings and x, y, … is the fraction in wt%.

Returns:

composition with x, y, … in at%

Return type:

list

Examples

angle = 2100  # in microrad
print(nx.conversions.UradToDeg(angle))

angle = 40  # in degree
print(nx.DegToMrad(angle))
velocity = np.linspace(-10, 10, 201)  # mm/s

detuning = nx.conversions.VelocityToGamma(velocity, nx.moessbauer.Fe57)
comp = (['Fe', 2], ['O', 3])

comp = nx.conversions.AtToWt(comp)
print(comp)

comp = nx.conversions.WtToAt(comp)
print(comp)
comp = (['Fe', 0.4], ['O', 0.6])

comp = nx.converions.AtToWt(comp)
print(comp)

comp = nx.conversions.WtToAt(comp)
print(comp)