pytsg
pytsg is a lightweight, open-source utility that provides a simple way to load and access TSG file packages from Python. With a single function call, a TSG package can be imported into an easy-to-use Python object for further analysis and processing.
The Spectral Geologist (TSG) is an industry-standard application for hyperspectral data analysis developed by CSIRO.
Installation
pip install pytsg
# To use zarr when loading large imagery/cras files
pip install pytsg[bigfile]
Usage
The TSG dataset will typically have the following file structure:
HOLENAME/
├── HOLENAME_tsg.bip
├── HOLENAME_tsg.tsg
├── HOLENAME_tsg_cras.bip
├── HOLENAME_tsg_hires.dat
├── HOLENAME_tsg_mir.bip
├── HOLENAME_tsg_mir.tsg
├── HOLENAME_tsg_tir.bip
└── HOLENAME_tsg_tir.tsg
You can load the TSG dataset using read_tsg and then interact with the data:
from matplotlib import pyplot as plt
import pytsg
data = pytsg.read_tsg("example_data/PE257D")
plt.plot(data.nir.wavelength, data.nir.spectra[0:10, :].T)
plt.plot(data.tir.wavelength, data.tir.spectra[0:10, :].T)
plt.xlabel("Wavelength nm")
plt.ylabel("Reflectance")
plt.title("pytsg reads tsg files")
plt.show()
If you would prefer to load just the individual files you can do that also:
# read bip files containing the spectra
import pytsg
nir = pytsg.read_spectra("ETG0187_tsg.tsg", "ETG0187_tsg.bip", "nir")
tir = pytsg.read_spectra("ETG0187_tsg_tir.tsg", "ETG0187_tsg_tir.bip", "tir")
# read cras files containing the imagery
cras = pytsg.read_cras("ETG0187_tsg_cras.bip")
# read hires dat file containing the LiDAR/profilometer data
lidar = pytsg.read_lidar("ETG0187_tsg_hires.dat")
Thanks
Thanks to CSIRO and in particular Andrew Rodger for his assistance in decoding the file structures.
Supported by the Geoscience Open Maintainers Collective
This project is supported by the Geoscience Open Maintainers Collective, an initiative of Geoscience Data Integrations (GDI), the open data and software division of the Geological Survey of Western Australia (GSWA). The Collective provides targeted developer support to open geoscience software projects; working alongside maintainers to share the maintenance load and help keep community tools stable, usable, and accessible.
Metadata
Release files for pytsg 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytsg-1.0.0.tar.gz | 20.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytsg-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.3 kB
Release files / pytsg-1.0.0.tar.gz
| Download URL | pytsg-1.0.0.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29eea409fbfa1c525844fae6d33678a154c7f2a79a6d66557ebdf4800f63d5ab
|
|
BLAKE2b-256 checksum How to use checksums |
ca99c9c24c4f336c9a657b1e4aed93d1d9d19223b0a4926eb1d6c0d1c24e7b5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pytsg-1.0.0-py3-none-any.whl
| Download URL | pytsg-1.0.0-py3-none-any.whl |
|---|---|
| Size | 23.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d95b8b411a13cc26047e8d7496c4bffe184797616281bdf093f1fd717e44ea62
|
|
BLAKE2b-256 checksum How to use checksums |
34348e9a220688bbee7f3acdb892d424e279ccd67a9801c6f66b503d16a6d550
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|