This library provides an easy way to interface with dotTHz files in Python.
Install it
pip install pydotthzor
pip3 install pydotthzand then use like specified in the following example:
from pathlib import Path
import numpy as np
from pydotthz import DotthzFile, DotthzMetaData
if __name__ == "__main__":
# Sample data
time = np.linspace(0, 1, 100) # your time array
data = np.random.rand(100) # example 3D data array
# save the file
path1 = Path("test1.thz")
with DotthzFile(path1, "w") as file:
file.create_measurement("Measurement 1")
# create meta-data
metadata = DotthzMetaData()
metadata.user = "John Doe"
metadata.version = "1.00"
metadata.instrument = "Toptica TeraFlash Pro"
metadata.mode = "THz-TDS/Transmission"
file["Measurement 1"].set_metadata(metadata)
# for thzVer 1.00, we need to transpose the array!
# important: do not manipulate keys on the `dataset` field, otherwise it won't be written to the file.
file["Measurement 1"]["Sample"] = np.array([time, data]).TFurther examples (e.g. THz image scans) can be found in the examples directory.
Requires hdf5 to be installed.