Python package for reading and analyzing Heat Flow Meter (HFM) data files
Project description
PyHFM - Heat Flow Meter Data Analysis
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.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Ensure all tests pass (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - 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:
- Check the documentation
- Search existing issues
- Create a new issue if needed
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyhfm-0.1.0.tar.gz.
File metadata
- Download URL: pyhfm-0.1.0.tar.gz
- Upload date:
- Size: 44.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa248eef515abdc6721b55af1bca5076cb451f9836695560ab489a3da3fe4088
|
|
| MD5 |
5a61c0c8af50398864bd61f402c710f9
|
|
| BLAKE2b-256 |
df1fe3c34bd666f6194b0003277e1a317d502738e02e575afad610da81ab7ac8
|
File details
Details for the file pyhfm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyhfm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb1ffdb8983fbff220500eee6e7469dcdc396583c0b49304c6ca2d5dace48865
|
|
| MD5 |
b21a27cb790d77fe43c83c27d06c060f
|
|
| BLAKE2b-256 |
f0ffac6cc2e45fac3439f7ecfaeedf98775fc0bcdf152f582daf90d0dbc4dc63
|