Skip to main content
THzTools logo.

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 Project Status: Active – The project has reached a stable, usable state and is being actively developed. GitHub PyPI - Status PyPI - Version Anaconda-Server Badge PyPI - Python Version Ruff Common Changelog Contributor Covenant All Contributors DOI pyOpenSci Peer-Reviewed DOI
Build Docs Tests codecov
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.

Installation

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.

Usage

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:

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))

Related software

Below is a list of other software projects that address related tasks in THz-TDS analysis, with summaries taken from the project documentation.

Citation

If you use THzTools, please consider citing the Optics Express paper that describes the maximum-likelihood methodology and/or the Journal of Open Source Software (JOSS) paper that describes the software.

Optics Express

@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},
}

JOSS

@article{loaiza2024,
  title = {{{THzTools}}: Data Analysis Software for Terahertz Time-Domain Spectroscopy},
  shorttitle = {{{THzTools}}},
  author = {Loaiza, Jonathan Posada and {Higuera-Quintero}, Santiago and Noori, Alireza and Mohtashemi, Laleh and Hall, R. P. and Yimam, Naod Ayalew and Dodge, J. Steven},
  year = {2024},
  journal = {Journal of Open Source Software},
  volume = {9},
  number = {104},
  pages = {7542},
  doi = {10.21105/joss.07542}
}

Contributors

J. Steven Dodge
J. Steven Dodge

💻 📖 💡 🤔 🚇 🚧 🧑‍🏫 📆 👀 🔧 ⚠️
Alireza Noori
Alireza Noori

🐛 💻 📖 🤔 🚧 🧑‍🏫 👀 ⚠️
Randon Hall
Randon Hall

💻 📖 ⚠️
jonathanpl20
jonathanpl20

💻 📖 🤔 ⚠️
cmhchan
cmhchan

💻 📖 ⚠️
WesleyXu09
WesleyXu09

📖
AugustenFairbairn
AugustenFairbairn

💻 📖 ⚠️
Rab912
Rab912

💻 📖 ⚠️
japneet-sandhu
japneet-sandhu

⚠️
KaiBlomquist
KaiBlomquist

🚧
Alejandro-Gutierrez-Physics
Alejandro-Gutierrez-Physics

🚧

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thztools-0.6.1.tar.gz (47.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thztools-0.6.1-py3-none-any.whl (33.7 kB view details)

Uploaded Python 3

File details

Details for the file thztools-0.6.1.tar.gz.

File metadata

  • Download URL: thztools-0.6.1.tar.gz
  • Upload date:
  • Size: 47.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for thztools-0.6.1.tar.gz
Algorithm Hash digest
SHA256 eeac6c37b35a821bfca3e36631273b4677a3d5540ed9d3276a12032564c37dc5
MD5 e788997ed82253d201b4c60167875216
BLAKE2b-256 8e249f208751a60e320de614c0fb06433ef615cda0280bae473fae9525c11d9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for thztools-0.6.1.tar.gz:

Publisher: release.yaml on dodge-research-group/thztools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thztools-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: thztools-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 33.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for thztools-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 71c7305a34e317f7098dad8e07482988b10cf92ad08e83b13f3f315d61af5309
MD5 3de51ee4d61f0324c5defe0da06bcee4
BLAKE2b-256 0da2291e70a3df54ab8a000efd12bd761eb13b7b549256bfcb6de01f2655d891

See more details on using hashes here.

Provenance

The following attestation bundles were made for thztools-0.6.1-py3-none-any.whl:

Publisher: release.yaml on dodge-research-group/thztools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 files

0.6.0

2 files

0.5.5.post0

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.0.5

2 files

0.0.2.post0

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page