Skip to main content

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

Reason this release was yanked:

timedate_filenames fix does not work, use 1.0.2 or later

Project description

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

This tool is inspired by the identically-named camp2ascii written 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

Usage

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

The following command calls the CLI:

camp2ascii -i ./64293_20Hz*.dat -odir ./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, toa5_to_pandas
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([
    (
        toa5_to_pandas(path)
        .resample("5min")
        .mean()
    )
    for path in out_files
])
data = data.sort_index()
data.plot(y="sonic_temp", style='o')

plt.show()

The above code snipped uses toa5_to_pandas, but you can also do pd.read_csv(path, skiprows=[0, 2, 3], na_values=["NAN"], parse_dates=["TIMESTAMP"], index_col="TIMESTAMP"). However, since integers in python cannot be NAN (but can in TOA5 files) and due to how NANs are stored in TOA5 files (as "NAN", in quotes), pandas has trouble correctly identifying certain datatypes. toa5_to_pandas will generally work better for this purpose.

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-1.0.1.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

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

camp2ascii-1.0.1-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for camp2ascii-1.0.1.tar.gz
Algorithm Hash digest
SHA256 707919ee0ac18cf58bd12acd3c5526d66c76990cf6d9e204f86129ff756421a7
MD5 1a37483cc38eb6d285a742b2c8682815
BLAKE2b-256 a7edf9fbf8bfd7befa2049e4e06b77b68aea618dc0b394ddb4587ca9f819019f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for camp2ascii-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1bd98515064eae9f92eae9a252ea705d86b0004e0cb594d885a7fe1f25576a5d
MD5 f5b7306ebae894142a9ef6dffb2d802f
BLAKE2b-256 6169fcebf5504f52ec970635f443929c9b1169e692d9c3d92774d3b705aaea49

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