Skip to main content

Convert Campbell Scientific TOB1/TOB2/TOB3 files to ASCII (TOA5).

Project description

Python program to convert Campbell Scientific TOB files to ASCII (TOA5) files.

This is a Python port of the same tool, originally written in C by Mathias Bavay: https://git.wsl.ch/bavay/camp2ascii

Installation

You can install camp2ascii using pip:

pip install "camp2ascii[progress]"

or, to install without the progress bar dependency:

pip install camp2ascii

Alternatively, you can clone the repository (or just the camp2ascii.py file) into your working directory.

Usage

camp2ascii can be used as a command line tool or as a python module.

If you installed camp2ascii using pip, the following command calls the CLI:

camp2ascii ./64293_20Hz*.dat -o ./ascii_files -pbar

Without, pip, you can call

python /path/to/camp2ascii.py ./64293_20Hz*.dat -o ./ascii_files -pbar

This will attempt to convert all files matching the glob string ./64293_Metdata*.dat from TOB (binary) format to TOA5 (ASCII) format, outputting the resulting files to the ./ascii_files directory. A progress bar will be displayed.

To use the python API:

import pandas as pd
import matplotlib.pyplot as plt
# if you installed without pip
# import sys
# sys.path.append("/path/to/working/directory/")
from camp2ascii import camp2ascii
from pathlib import Path
# convert to ascii as before
out_files = camp2ascii("./64293_20Hz*.dat", "./ascii_files", pbar=True)
# read in data using pandas, summarize to 30 minute averages, and plot sonic temperature
data = pd.concat([
    (
        pd.read_csv(path, na_values="NAN", parse_dates=["TIMESTAMP"], index_col="TIMESTAMP", skiprows=[0, 2, 3])
        .resample("5min")
        .mean()
    )
    for path in out_files
])
data = data.sort_index()
data.plot(y="sonic_temp", style='o')

plt.show()

N.B. Note that much of this port was done with the help of AI coding tools, and is currently in alpha. I have yet to implement rigorous testing or to fully clean up the AI-generated code.

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

camp2ascii-0.1.2.tar.gz (46.6 kB view details)

Uploaded Source

Built Distribution

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

camp2ascii-0.1.2-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

Details for the file camp2ascii-0.1.2.tar.gz.

File metadata

  • Download URL: camp2ascii-0.1.2.tar.gz
  • Upload date:
  • Size: 46.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for camp2ascii-0.1.2.tar.gz
Algorithm Hash digest
SHA256 65938d97889f69f4c6f02188fad927b3afdc9b592164e36755abf7493613228f
MD5 356f98132f62b90cf665b0f56e0da525
BLAKE2b-256 22f85e42165525f1e87dea23b979cce445a85465cf7467f516cbe7d7654216a0

See more details on using hashes here.

File details

Details for the file camp2ascii-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: camp2ascii-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 35.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for camp2ascii-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 827f092f7982b5a65934fb03d05566522fe9abb78521ec51d1e52b157f943b87
MD5 b58d674a8fd20f82d9d4fc57babb0358
BLAKE2b-256 e0f476a318eeda5d1a13742f1b93b7daa5c78d56efbebcd8af851a3318ddad0f

See more details on using hashes here.

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