Skip to content

Add MATLAB reference implementation and Octave validation#2

Open
maresb wants to merge 1 commit into
masterfrom
claude/pc-min-octave-c4nvdp
Open

Add MATLAB reference implementation and Octave validation#2
maresb wants to merge 1 commit into
masterfrom
claude/pc-min-octave-c4nvdp

Conversation

@maresb

@maresb maresb commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds Kerry Emanuel's original MATLAB potential-intensity algorithm (BE02/pcmin) as a reference implementation and introduces validation testing under GNU Octave to ensure the Python port produces consistent results.

Key Changes

  • Added matlab_scripts/ directory with the original MATLAB implementation:

    • pc_min.m: Kerry Emanuel's pcmin algorithm from Bister & Emanuel (2002)
    • run_pc_min.m: Validation driver that tests pc_min.m against reference values from sample data
    • README.md: Documentation describing the MATLAB scripts and their purpose
  • Updated CI/CD pipeline (.github/workflows/pytest.yaml):

    • Added new octave job to run MATLAB validation tests
    • Tests run on multiple OS platforms where Octave is available
  • Updated project configuration (pyproject.toml):

    • Added octave feature with Octave dependency
    • Configured platform restrictions (Octave not available on win-64)

Implementation Details

  • The run_pc_min.m script validates the MATLAB implementation against reference PMIN/VMAX/TO/LNB/IFL values stored in data/sample_data.nc
  • Uses only core Octave features (no toolboxes) to ensure broad compatibility and serve as a smoke test
  • The MATLAB implementation is kept as-is for reference and validation purposes, with the Python port being the primary implementation

https://claude.ai/code/session_01Ag9bDj6GuRN8fNsDULbBkQ

pc_min.m runs unmodified under Octave, so add a reproducible way to
exercise it without a MATLAB license:

- matlab_scripts/run_pc_min.m: a core-Octave driver that runs pc_min.m on
  five soundings from data/sample_data.nc and asserts the PMIN/VMAX/TO/LNB/IFL
  outputs match the reference values the original MATLAB code stored there.
  It exits non-zero on any drift, so it is safe to use in CI.
- pyproject.toml: an `octave` pixi feature/environment (Linux + macOS only;
  Octave is not packaged for win-64 on conda-forge) plus a `pc-min-octave`
  task that runs the driver.
- .github/workflows/pytest.yaml: a CI job running the task on ubuntu and macos.
- matlab_scripts/README.md: documents the scripts and how to run them.

pixi.lock is regenerated by the installed pixi (0.72.2), which also upgrades
it from lock-file format v6 to v7; existing environments keep their exact
locked package versions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ag9bDj6GuRN8fNsDULbBkQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants