Skip to main content

Python package for reading and analyzing Heat Flow Meter (HFM) data files

Project description

PyHFM - Heat Flow Meter Data Analysis

Python 3.10+ License: MIT

PyHFM is a Python package for reading and analyzing Heat Flow Meter (HFM) data files. It provides a clean, modern API for parsing HFM measurement data and extracting thermal conductivity and volumetric heat capacity measurements.

Features

  • Simple API: Clean read_hfm() function for easy data loading
  • Multiple Formats: Support for thermal conductivity and volumetric heat capacity measurements
  • Rich Metadata: Comprehensive metadata extraction and validation
  • Modern Data Stack: Built on PyArrow for efficient data handling
  • Type Safety: Full type annotations for better development experience
  • Comprehensive Testing: Extensive test suite for reliability
  • CLI Support: Command-line interface for quick data conversion

Installation

pip install pyhfm

For development installation:

git clone https://github.com/GraysonBellamy/pyhfm.git
cd pyhfm
pip install -e ".[dev,test]"

Quick Start

Basic Usage

import pyhfm

# Read HFM file and get PyArrow table
table = pyhfm.read_hfm("sample.tst")

# Convert to polars DataFrame for analysis
import polars as pl
df = pl.from_arrow(table)
print(df.head())

Access Metadata

# Get both metadata and data
metadata, table = pyhfm.read_hfm("sample.tst", return_metadata=True)

print(f"Sample: {metadata['sample_id']}")
print(f"Type: {metadata['type']}")
print(f"Setpoints: {metadata['number_of_setpoints']}")

Custom Configuration

# Override default settings
config = {"default_encoding": "utf-8"}
table = pyhfm.read_hfm("sample.tst", config=config)

Data Structure

PyHFM returns data in PyArrow tables with the following schemas:

Thermal Conductivity Measurements

Column Type Description
setpoint int32 Setpoint number
upper_temperature float64 Upper plate temperature
lower_temperature float64 Lower plate temperature
upper_thermal_conductivity float64 Upper thermal conductivity result
lower_thermal_conductivity float64 Lower thermal conductivity result

Volumetric Heat Capacity Measurements

Column Type Description
setpoint int32 Setpoint number
average_temperature float64 Average temperature
volumetric_heat_capacity float64 Volumetric heat capacity result

Command Line Interface

PyHFM includes a CLI for quick data conversion:

# Convert to CSV
pyhfm sample.tst --output sample.csv --format csv

# Convert to Parquet with metadata
pyhfm sample.tst --output sample.parquet --format parquet --metadata

# Print to stdout as JSON
pyhfm sample.tst --format json

Advanced Usage

Custom Parser

from pyhfm import HFMParser

# Create parser with custom configuration
parser = HFMParser(config={"default_encoding": "utf-16le"})
table = parser.parse_file("sample.tst")

Data Extraction

from pyhfm import DataExtractor

# Extract data from metadata
extractor = DataExtractor()
table = extractor.extract_data(metadata)

Error Handling

import pyhfm

try:
    table = pyhfm.read_hfm("sample.tst")
except pyhfm.HFMFileError as e:
    print(f"File error: {e}")
except pyhfm.HFMParsingError as e:
    print(f"Parsing error: {e}")
except pyhfm.HFMValidationError as e:
    print(f"Validation error: {e}")

Supported File Formats

  • HFM Test Files (.tst): Standard HFM output format
  • Encodings: UTF-16LE (default), UTF-8, and auto-detection
  • Measurements: Thermal conductivity and volumetric heat capacity

Architecture

PyHFM follows a modular architecture inspired by the pynetzsch package:

pyhfm/
   api/           # High-level user API
   core/          # Core parsing logic
   extractors/    # Data extraction components
   constants.py   # Configuration and data types
   exceptions.py  # Custom exception hierarchy
   __init__.py    # Public API exports

Development

Setup Development Environment

git clone https://github.com/GraysonBellamy/pyhfm.git
cd pyhfm
pip install -e ".[dev,test]"
pre-commit install

Run Tests

pytest

Code Quality

ruff check .          # Linting
ruff format .         # Formatting
mypy src/pyhfm        # Type checking

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for your changes
  5. Ensure all tests pass (pytest)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

v0.1.0 (2024-01-01)

  • Initial release
  • Support for thermal conductivity and volumetric heat capacity measurements
  • PyArrow-based data handling
  • Comprehensive metadata extraction
  • CLI interface
  • Full type annotations

Related Projects

  • pynetzsch - Python package for NETZSCH thermal analysis data

Support

If you encounter any issues or have questions, please:

  1. Check the documentation
  2. Search existing issues
  3. Create a new issue if needed

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

pyhfm-0.1.1.tar.gz (51.5 kB view details)

Uploaded Source

Built Distribution

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

pyhfm-0.1.1-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file pyhfm-0.1.1.tar.gz.

File metadata

  • Download URL: pyhfm-0.1.1.tar.gz
  • Upload date:
  • Size: 51.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyhfm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 03647d152a9eb43ca03db404c97eaecd81b5f01d875963ad03b9d1d617000038
MD5 3650f9a0a6c7fd3133e8f2343a326ea6
BLAKE2b-256 2b60148a437cd7d6689b60a5a0b8afaa68d5d11887692d7e1499a1d297091c73

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhfm-0.1.1.tar.gz:

Publisher: ci-cd.yml on GraysonBellamy/pyhfm

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

File details

Details for the file pyhfm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyhfm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyhfm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d940fbf33d43c1c291a2e45323a69e016d987019ef5322eb7ba7a711ea412074
MD5 917e125a3b05670dca1ca5881a50dfe6
BLAKE2b-256 19fa06216ee799523170ffc0511d55b569259406da1e3ccc799ef4ed06030ca2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhfm-0.1.1-py3-none-any.whl:

Publisher: ci-cd.yml on GraysonBellamy/pyhfm

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