Skip to content

Configuration

Raphael Constantinis edited this page Jul 23, 2025 · 1 revision

Configuration

This page provides comprehensive instructions for customizing the entropic_measurement library, including settings, parameter options, and configuration files.

Overview

The entropic_measurement library offers flexible configuration options to adapt to different measurement scenarios and computational requirements. Configuration can be set through:

  • Configuration files
  • Environment variables
  • Direct parameter passing
  • Runtime configuration updates

Configuration Files

Default Configuration File

The library looks for configuration files in the following order:

  1. ./entropic_config.yaml (current directory)
  2. ~/.entropic_measurement/config.yaml (user home directory)
  3. /etc/entropic_measurement/config.yaml (system-wide)

Sample Configuration File

# entropic_config.yaml
measurement:
  precision: "high"  # Options: low, medium, high, ultra
  sample_rate: 1000   # Samples per second
  window_size: 1024   # Analysis window size
  overlap: 0.5        # Window overlap ratio (0.0-1.0)

processing:
  threads: "auto"     # Number of processing threads or 'auto'
  memory_limit: "1GB" # Maximum memory usage
  cache_size: 100     # Number of cached results

output:
  format: "json"      # Options: json, csv, hdf5, pickle
  precision: 6        # Decimal precision for numeric output
  compression: true   # Enable output compression
  
logging:
  level: "INFO"       # Options: DEBUG, INFO, WARNING, ERROR
  file: "entropic.log" # Log file path (optional)
  console: true       # Enable console logging

Environment Variables

Configuration can also be set using environment variables with the ENTROPIC_ prefix:

Core Settings

  • ENTROPIC_PRECISION: Set measurement precision (low/medium/high/ultra)
  • ENTROPIC_SAMPLE_RATE: Sampling rate in Hz
  • ENTROPIC_THREADS: Number of processing threads
  • ENTROPIC_MEMORY_LIMIT: Maximum memory usage (e.g., "512MB", "2GB")

Output Settings

  • ENTROPIC_OUTPUT_FORMAT: Output format (json/csv/hdf5/pickle)
  • ENTROPIC_OUTPUT_PRECISION: Numeric precision for output
  • ENTROPIC_COMPRESSION: Enable compression (true/false)

Logging Settings

  • ENTROPIC_LOG_LEVEL: Logging level (DEBUG/INFO/WARNING/ERROR)
  • ENTROPIC_LOG_FILE: Path to log file
  • ENTROPIC_LOG_CONSOLE: Enable console logging (true/false)

Example Environment Setup

# Linux/macOS
export ENTROPIC_PRECISION="high"
export ENTROPIC_SAMPLE_RATE=2000
export ENTROPIC_OUTPUT_FORMAT="hdf5"
export ENTROPIC_LOG_LEVEL="DEBUG"

# Windows
set ENTROPIC_PRECISION=high
set ENTROPIC_SAMPLE_RATE=2000
set ENTROPIC_OUTPUT_FORMAT=hdf5
set ENTROPIC_LOG_LEVEL=DEBUG

Runtime Configuration

Configuration Object

You can create and modify configuration at runtime:

from entropic_measurement import Config, EntropicMeasurement

# Create custom configuration
config = Config(
    precision='high',
    sample_rate=1500,
    window_size=2048,
    output_format='json'
)

# Initialize with configuration
measurement = EntropicMeasurement(config=config)

# Update configuration during runtime
config.update(precision='ultra', threads=8)

Direct Parameter Passing

# Pass parameters directly to measurement functions
result = measurement.analyze(
    data,
    precision='high',
    window_size=1024,
    overlap=0.75
)

Configuration Parameters

Measurement Parameters

Parameter Type Default Description
precision str "medium" Measurement precision level
sample_rate int 1000 Sampling rate in Hz
window_size int 1024 Analysis window size (power of 2)
overlap float 0.5 Window overlap ratio (0.0-1.0)
method str "fft" Analysis method (fft/welch/multitaper)

Processing Parameters

Parameter Type Default Description
threads int/str "auto" Number of processing threads
memory_limit str "512MB" Maximum memory usage
cache_size int 50 Number of cached results
parallel bool true Enable parallel processing

Output Parameters

Parameter Type Default Description
format str "json" Output format
precision int 4 Decimal precision
compression bool false Enable compression
metadata bool true Include metadata in output

Advanced Configuration

Custom Analysis Methods

# Register custom analysis method
config.register_method('custom_fft', CustomFFTAnalyzer)

# Use custom method
result = measurement.analyze(data, method='custom_fft')

Performance Tuning

# High-performance configuration
performance:
  vectorization: true     # Enable SIMD operations
  gpu_acceleration: false # Use GPU if available
  memory_mapping: true    # Use memory mapping for large files
  batch_processing: true  # Enable batch processing

Validation Settings

validation:
  strict_types: true      # Enforce strict type checking
  range_checks: true      # Validate parameter ranges
  warn_deprecated: true   # Warn about deprecated features

Configuration Validation

The library validates configuration parameters at startup:

# Validate configuration
try:
    config.validate()
except ConfigurationError as e:
    print(f"Configuration error: {e}")

Best Practices

  1. Use configuration files for consistent settings across runs
  2. Set environment variables for deployment-specific settings
  3. Profile your configuration to optimize performance
  4. Document custom configurations for reproducibility
  5. Use version control for configuration files

Troubleshooting

Common Issues

  • Invalid precision level: Ensure precision is one of: low, medium, high, ultra
  • Memory errors: Reduce window_size or cache_size for large datasets
  • Threading issues: Set threads=1 to disable parallel processing
  • Output format errors: Verify the output format is supported

Debug Mode

Enable debug logging to troubleshoot configuration issues:

import logging
logging.basicConfig(level=logging.DEBUG)

# Or via environment variable
# ENTROPIC_LOG_LEVEL=DEBUG

See Also

Clone this wiki locally