Skip to content

Instantly share code, notes, and snippets.

@thomasaarholt
Created September 7, 2020 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasaarholt/39e4e51fe44c6f2655855d912cf8842d to your computer and use it in GitHub Desktop.
Save thomasaarholt/39e4e51fe44c6f2655855d912cf8842d to your computer and use it in GitHub Desktop.
import numpy as np
from scipy.constants import electron_mass, elementary_charge, c, hbar, h
def relativistic_wavelength(kV=300):
"Returns relativistic wavelength in meters"
V = 1e3 * kV
top = h * c
bottom = np.sqrt(
elementary_charge * V * (2 * electron_mass * c ** 2 + elementary_charge * V)
)
wavelength = top / bottom
return wavelength
def invnm_to_mrad(k, kV=300):
"""Converts reciprocal nm units to mrad units
"""
wavelength = relativistic_wavelength(kV)
k = k * 1 / (1e-9)
theta = np.arctan(k * wavelength)
return theta * 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment