THzTools is an open-source Python package for data analysis in terahertz time-domain spectroscopy (THz-TDS). As the name suggests, THz-TDS involves measurements of terahertz-frequency electromagnetic waveforms that are acquired as a function of time, which users typically represent as a function of frequency for analysis. THzTools makes it easier for researchers to use statistically optimal methods for doing this analysis, as described in L. Mohtashemi et al., Opt. Express 29, 4912 (2021).
This is beta software that is currently under development.
Information | Links |
---|---|
Project | |
Build | |
Documentation | https://dodge-research-group.github.io/thztools/ |
Cite | L. Mohtashemi et al., Opt. Express 29, 4912 (2021). (DOI) |
The original MATLAB code is available at Zenodo.
You can install THzTools with pip
:
pip install thztools
THzTools is also available through conda-forge
:
conda install -c conda-forge thztools
See the Getting started tutorial for additional information.
In the conventional approach to THz-TDS analysis, one transforms
the time-domain measurements into the frequency domain for further analysis.
This approach has well-known problems, however, which can be resolved by
using a maximum-likelihood estimation procedure in the time
domain. To support this mode of analysis, the THzTools
package provides functionality and documentation that are unavailable in
existing THz-TDS analysis software. It provides functions to simulate THz-TDS
measurements (eg, timebase
and wave
),
apply a frequency response function to a THz-TDS waveform (apply_frf
),
characterize the noise of a THz-TDS system (noisefit
),
and fit a parameterized frequency response function to a pair of input and
output waveforms (fit
).
With THzTools, you can:
- Simulate a terahertz waveform
- Simulate realistic time-domain noise for a waveform
- Apply a frequency response function (FRF) to a time-domain waveform
- Rescale and shift a waveform
- Estimate time-domain system noise parameters from a set of measured waveforms
- Fit a parameterized FRF to a pair of time-domain waveforms
For example, the following code creates an ideal waveform and applies a frequency response function to it.
import numpy as np
import thztools as thz
# Set the waveform parameters
n = 256 # Number of samples
dt = 0.05 # Sampling time [ps]
a = 0.5 # Scale factor
eta = 1.0 # Delay [ps]
# Simulate the waveform
t = thz.timebase(n, dt=dt)
mu = thz.wave(n, dt=dt)
# Define a frequency response function
def frfun(omega, _a, _eta):
return _a * np.exp(-1j * omega * _eta)
# Apply the frequency response function to the waveform
psi = thz.apply_frf(frfun, mu, dt=dt, args=(a, eta))
Below is a list of other software projects that address related tasks in THz-TDS analysis, with summaries taken from the project documentation.
- https://github.com/THzbiophotonics/Fit-TDS
- "Python code aiming at the retrieving of material parameter from a TeraHertz time domain spectroscopy (TDS) measurements from a fit in the time domain."
- https://github.com/puls-lab/phoeniks
- "A free and open-source (FOSS) Python class to extract the refractive index and absorption coefficient from time traces of a THz Time Domain Spectrometer (THz-TDS)."
- https://github.com/dotTHzTAG/CaTSper
- "The CaTSper tool extracts the frequency-dependent optical constants from terahertz time-domain waveforms." (uses MATLAB)
- https://github.com/YaleTHz/nelly
- "Nelly is a package for extracing refractice indices and conductivities from time-domain terahertz spectroscopy data." (uses MATLAB)
If you use THzTools, please consider citing the paper and/or the software package.
@article{Mohtashemi2021,
author = {Laleh Mohtashemi and Paul Westlund and Derek G. Sahota and
Graham B. Lea and Ian Bushfield and Payam Mousavi and J. Steven Dodge},
journal = {Opt. Express},
number = {4},
pages = {4912--4926},
publisher = {Optica Publishing Group},
title = {Maximum-likelihood parameter estimation in terahertz time-domain
spectroscopy},
volume = {29},
month = {Feb},
year = {2021},
url = {https://doi.org/10.1364/OE.417724},
doi = {10.1364/OE.417724},
}
@software{PosadaLoaiza2024,
author = {Posada Loaiza, Jonathan and Higuera-Quintero, Santiago and Noori,
Alireza and Mohtashemi, Laleh and Hall, R. P. and Yimam, Naod Ayalew and
Dodge, J. Steven},
license = {MIT},
month = oct,
title = {{THzTools}},
url = {https://github.com/dodge-research-group/thztools},
version = {0.5.5},
year = {2024}
}