Skip to main content

A Python library for parsing RASP rocket motor data files

Project description

RASP Parser

PyPI version Python Support License: MIT Tests

A Python library for parsing rocket motor data files in RASP format (.eng files). RASP (Rocket Altitude Simulation Program) format is the standard for rocket motor data interchange used by flight simulators like OpenRocket, RockSim, and others.

Features

  • Parse RASP/ENG files with full validation
  • High-accuracy integration using cubic splines (when scipy available) or adaptive Simpson's rule
  • Comprehensive motor data including thrust curves, performance metrics, and motor specifications
  • Robust error handling with detailed error messages
  • Type hints for better IDE support
  • Zero required dependencies (scipy optional for enhanced accuracy)

Installation

# Basic installation
pip install rasp-parser

# With scipy for enhanced accuracy
pip install rasp-parser[scipy]

# Development installation
pip install rasp-parser[dev]

Quick Start

import rasp_parser

# Parse a single motor file
motor = rasp_parser.load_rasp_motor("Estes_D12.eng")

# Display motor information
print(motor)
# Output:
# RASP Motor: D12 by Estes
#   Class: D
#   Diameter: 24mm
#   Length: 70mm
#   Propellant Mass: 0.012kg
#   Total Mass: 0.024kg
#   Total Impulse: 8.8Ns
#   Peak Thrust: 17.3N
#   Burn Time: 1.6s
#   Thrust Points: 15

# Access motor properties
print(f"Motor class: {motor.impulse_class}")
print(f"Total impulse: {motor.total_impulse:.1f} Ns")
print(f"Specific impulse: {motor.specific_impulse:.1f} s")

# Get interpolated thrust at any time
thrust_at_0_5s = motor.get_interpolated_thrust(0.5)
print(f"Thrust at 0.5s: {thrust_at_0_5s:.1f} N")

# Load multiple motors from directory
motors = rasp_parser.load_rasp_motors("motor_database/")
print(f"Loaded {len(motors)} motors")

Motor Data Structure

@dataclass
class RASPMotor:
    designation: str          # Motor designation (e.g., "D12")
    diameter: float          # Diameter in mm
    length: float           # Length in mm  
    delays: str             # Available delays (e.g., "0-3-5-7")
    propellant_mass: float  # Propellant mass in kg
    total_mass: float       # Total motor mass in kg
    manufacturer: str       # Manufacturer name
    thrust_curve: List[ThrustCurvePoint]  # Time/thrust data points
    comments: List[str]     # Comments from file
    
    # Calculated properties
    total_impulse: float    # Integrated total impulse
    peak_thrust: float      # Maximum thrust
    burn_time: float        # Motor burn duration
    average_thrust: float   # Average thrust over burn time
    impulse_class: str      # Motor class (A, B, C, etc.)
    specific_impulse: float # Isp in seconds

Integration Methods

The library automatically selects the best integration method available:

  1. Cubic Spline Integration (when scipy available)

    • Most accurate for typical thrust curves
    • Handles sparse data well
    • Analytical integration of smooth spline
  2. Adaptive Simpson's Rule (fallback)

    • High accuracy without dependencies
    • 4th-order accuracy vs 2nd-order trapezoidal
  3. Trapezoidal Rule (final fallback)

    • For very sparse data (2 points)
# Check which integration method is active
print(f"Integration method: {rasp_parser.get_integration_method()}")

Validation

# Validate motor data
warnings = rasp_parser.validate_motor(motor)
if warnings:
    for warning in warnings:
        print(f"⚠️  {warning}")

# Strict validation (raises exception on issues)
try:
    rasp_parser.validate_motor(motor, strict=True)
    print("✅ Motor validation passed")
except rasp_parser.RASPValidationError as e:
    print(f"❌ Validation failed: {e}")

Advanced Usage

Custom Parsing

# Parse from string content
with open("motor.eng", "r") as f:
    content = f.read()

motor = rasp_parser.RASPParser.parse_string(content)

Error Handling

try:
    motor = rasp_parser.load_rasp_motor("missing_file.eng")
except rasp_parser.RASPFileNotFoundError:
    print("File not found")
except rasp_parser.RASPHeaderError as e:
    print(f"Invalid header: {e}")
except rasp_parser.RASPThrustCurveError as e:
    print(f"Invalid thrust data: {e}")

Working with Thrust Curves

# Access raw thrust curve data
for point in motor.thrust_curve:
    print(f"t={point.time:.3f}s, F={point.thrust:.1f}N")

# Generate smooth thrust curve using interpolation
import numpy as np
times = np.linspace(0, motor.burn_time, 100)
smooth_thrust = [motor.get_interpolated_thrust(t) for t in times]

RASP File Format

RASP files (.eng) contain rocket motor data in a simple text format:

; Comments start with semicolon
; Motor: Estes D12
D12 24 70 0-3-5-7 0.0125 0.0242 Estes
0.000 0.0
0.050 8.0
0.100 15.0
0.200 14.0
...
1.600 0.0

Header format: designation diameter length delays propellant_mass total_mass manufacturer

  • designation: Motor name (e.g., "D12")
  • diameter: Motor diameter in mm
  • length: Motor length in mm
  • delays: Available ejection delays in seconds
  • propellant_mass: Propellant mass in kg
  • total_mass: Total loaded motor mass in kg
  • manufacturer: Manufacturer code/name

Requirements

  • Python 3.8+
  • scipy (optional, for enhanced accuracy)

Contributing

Contributions are welcome. Please read CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE file.

Acknowledgments

  • Based on the RASP format originally developed by G. Harry Stine
  • Inspired by the rocketry community and flight simulation tools
  • Thanks to ThrustCurve.org for format documentation

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

rasp_parser-1.0.0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

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

rasp_parser-1.0.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file rasp_parser-1.0.0.tar.gz.

File metadata

  • Download URL: rasp_parser-1.0.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rasp_parser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b816663cce06119fb38dcb51b1c5fd8ad30a1d1636648b8a154f948d935eaae0
MD5 2c6433ad708fb011cf1fc7515d58e01b
BLAKE2b-256 3ee839d2c5aa34ef740122bc4a8c10c151c6d92534371594c794a34b8fb108ff

See more details on using hashes here.

File details

Details for the file rasp_parser-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rasp_parser-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rasp_parser-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93700de2eea4f775dc8cf8a7ef33a79a61265eec8148e65afae8547911bd3b46
MD5 d5f706ecb384a0a0aa2169b6c735576d
BLAKE2b-256 3af8a42cd19151cf267a2afcf06fc18af15a6f097dc140c2efd19e0f4228d624

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