Skip to main content

This Python Package allows interfacing with dotThz files.

Project description

Interface with dotThz files using Python

PEP8 PyPI PyPI - Downloads

This crate provides an easy way to interface with dotThz files in Python.

Install it

pip install pydotthz

or

pip3 install pydotthz

and then use like specified in the following example:

from pathlib import Path
import numpy as np

from dotthz import DotthzFile, DotthzMeasurement, DotthzMetaData

if __name__ == "__main__":
    # Sample data
    time = np.linspace(0, 1, 100)  # your time array
    data = np.random.rand(100)  # example 3D data array

    measurement = DotthzMeasurement()
    # for thzVer 1.00, we need to transpose the array!
    datasets = {"Sample": np.array([time, data]).T}
    measurement.datasets = datasets

    # create meta-data
    meta_data = DotthzMetaData()
    meta_data.user = "John Doe"
    meta_data.version = "1.00"
    meta_data.instrument = "Toptica TeraFlash Pro"
    meta_data.mode = "THz-TDS/Transmission"

    measurement.meta_data = meta_data

    # save the file
    path1 = Path("test1.thz")
    with DotthzFile(path1, "w") as file:
        file.write_measurement("Measurement 1", measurement)
    del file  # optional, not required as the file is already closed

    # create and save a second file
    path2 = Path("test2.thz")
    with DotthzFile(path2, "w") as file:
        file.write_measurement("Measurement 2", measurement)
    del file  # optional, not required as the file is already closed

    # open the first file again in append mode and the second in read mode
    with DotthzFile(path1, "a") as file1, DotthzFile(path2) as file2:
        measurements = file2.get_measurements()
        for name, measurement in measurements.items():
            file1.write_measurement(name, measurement)
    del file1  # optional, not required as the file is already closed

    with DotthzFile(path1, "r") as file1:
        # read the first measurement
        key = list(file1.get_measurements().keys())[0]
        print(file1.get_measurements().get(key).meta_data)
        print(file1.get_measurements().get(key).datasets)

Requires hdf5 to be installed.

Project details


Download files

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

Source Distribution

pydotthz-0.2.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

pydotthz-0.2.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pydotthz-0.2.0.tar.gz.

File metadata

  • Download URL: pydotthz-0.2.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pydotthz-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f93490cc67dc959ffc6a067a73968bfddf7f5d5923928f0acfd4f8a4dd32ff2a
MD5 0e987adb1ed8874bb851718c75944f48
BLAKE2b-256 b590d857064fe022dcd17f438567048d9a6a6c06e047f5add260a894f9c19298

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydotthz-0.2.0.tar.gz:

Publisher: publish.yml on hacknus/pydotthz

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

File details

Details for the file pydotthz-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pydotthz-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pydotthz-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c2d750d00eb8dcb2a03cd2cf6087e645786ee076990b9f7009d3f0f6929a514
MD5 ef9ad4bf375e37b955e689990f6e78c1
BLAKE2b-256 97ec48014f1d7882cef62fd362222632ca581ce9fe8c0fc298e2c42ce9c25bb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydotthz-0.2.0-py3-none-any.whl:

Publisher: publish.yml on hacknus/pydotthz

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page