Validation¶
Validation infrastructure: running the official GOTM test cases, comparing output against Fortran reference NetCDF files, and rendering HTML reports.
Per-case execution and validation logic for pyGOTM validation.
- pygotm.validation.runner.run_case(case_name, runs_dir, *, cases_root=None)[source]¶
Run a compiled parity case, write NetCDF, return (path, elapsed_s).
- pygotm.validation.runner.summary_case(result)[source]¶
Return a lightweight case summary without per-variable result rows.
- Return type:
CaseResult- Parameters:
result (CaseResult)
- pygotm.validation.runner.strip_case_plots(result)[source]¶
Return per-variable results without embedded Plotly HTML payloads.
- Return type:
CaseResult- Parameters:
result (CaseResult)
- pygotm.validation.runner.validate_case(case_name, runs_dir, *, skip_run=False, debug_turbulence=False, cases_root=None)[source]¶
Run (optionally) and validate a single GOTM case.
- pygotm.validation.runner.validate_case_to_html(case_name, runs_dir, output_dir, *, generated_at, hardware, skip_run=False, debug_turbulence=False, cases_root=None)[source]¶
Run or compare one case, write its HTML page, and return JSON-safe data.
NetCDF comparison utilities for pyGOTM validation using Frechet distance.
- class pygotm.validation.compare.VarResult(name, section, status, color, reference_at_worst, calculated_at_worst, d_raw, d_norm, plot_html, metric_mode='d_norm', score=None, peak_d_norm=None)[source]¶
Bases:
objectPer-variable result for Frechet validation.
- Parameters:
name (str)
section (Literal['pygotm', 'pyfabm'])
status (Literal['PASS', 'MARGINAL', 'DISCREPANT', 'BROKEN'])
color (Literal['green', 'yellow', 'orange', 'red'])
reference_at_worst (float)
calculated_at_worst (float)
d_raw (float)
d_norm (float)
plot_html (str | None)
metric_mode (Literal['d_norm', 'd_rel'])
score (float | None)
peak_d_norm (float | None)
- exception pygotm.validation.compare.ValidationError[source]¶
Bases:
ExceptionRaised for unrecoverable comparison failures.
- pygotm.validation.compare.compare_nc(py_path, ref_path, case_name, config=FrechetConfig(pass_tol=0.01, marginal_tol=0.05, discrepant_tol=0.2, frechet_abs_tol=1e-12, frechet_rel_tol=1e-06, frechet_k=200, robust=False, q_low=0.1, q_high=99.9, pyfabm_robust=True, pyfabm_q_low=0.1, pyfabm_q_high=99.9, peak_frechet_k=400, switch_oom=2.0, eps_floor=1e-12, default_magnitude_floor=1e-06))[source]¶
Compare py_path against ref_path using Frechet distance.
Reference-case discovery and NetCDF opening helpers for validation.
- class pygotm.validation.reference.ValidationCase(name, directory, yaml_path, reference_path)[source]¶
Bases:
objectResolved metadata for one GOTM reference case and YAML input file.
- pygotm.validation.reference.discover_reference_cases(*, cases_root=None)[source]¶
Resolve all declared reference cases in canonical order.
- Return type:
- Parameters:
cases_root (Path | None)
- pygotm.validation.reference.numeric_variable_names(dataset)[source]¶
Return numeric data variables in dataset order.
- pygotm.validation.reference.open_reference_dataset(case)[source]¶
Open the Fortran reference NetCDF for case.
- Return type:
- Parameters:
case (ValidationCase)
- pygotm.validation.reference.open_validation_dataset(path)[source]¶
Open a validation NetCDF with the same backend fallback as references.
- pygotm.validation.reference.resolve_reference_case(case_name, *, yaml_file=None, cases_root=None)[source]¶
Resolve a named reference case to its YAML and Fortran NetCDF paths.
- Return type:
- Parameters:
Render validation HTML reports directly from existing NetCDF outputs.
Usage¶
python -m pygotm.validation.render_report python -m pygotm.validation.render_report –cases couette,channel python -m pygotm.validation.render_report –all –workers 4 python -m pygotm.validation.render_report –report-dir validation/report