Skip to content

Conversation

@sunt05
Copy link

@sunt05 sunt05 commented Dec 17, 2025

Summary

Decompose physics options (starting with netradiationmethod) into orthogonal dimensions with human-readable names, replacing opaque numeric codes. This provides a cleaner, more intuitive YAML configuration format whilst maintaining full backward compatibility.

Key Features

1. Nested Orthogonal Dimensions

# New format - explicit dimensions
netradiationmethod:
  scheme: narp        # obs | narp | spartacus
  ldown: air          # obs | cloud | air

emissionsmethod:
  heat: J11           # obs | L11 | J11 | J19
  co2: none           # none | rectangular | non_rectangular | conductance

2. Human-Readable Option Names

All physics options now accept intuitive string names (case-insensitive):

Format Type Examples
Model names ohm, anohm, estm, ehc, narp, spartacus
Author-year (Xyy) K09 (Kawai 2009), CN98 (Campbell & Norman 1998)
Descriptive fixed, variable, auto, model, obs
Binary yes, no

3. Full Backward Compatibility

Legacy formats remain fully supported:

# All these work:
netradiationmethod: 3                    # numeric code
netradiationmethod: {value: 3}           # RefValue wrapper
netradiationmethod: {scheme: narp, ldown: air}  # new nested format
storageheatmethod: ohm                   # string name
storageheatmethod: 1                     # numeric code

Changes

Core Implementation

  • physics_options.py: Base class PhysicsOptionConfig with CodeMapper for bidirectional code↔name mapping
  • NetRadiationMethodConfig, EmissionsMethodConfig: Multi-dimensional configs with orthogonal enums
  • Case-insensitive string name support with short aliases

Code Quality

  • Python 3.9 fix: Changed X | NoneOptional[X] for runtime compatibility
  • Ruff FA102 rule: Added to catch PEP 604 syntax violations in CI
  • Documentation: Added naming convention rules to .claude/rules/python/conventions.md

Documentation

  • Updated sample_config.yml with inline comments showing valid options
  • Added tabbed display in docs for nested/legacy format comparison

Test Results

All smoke tests passing on Python 3.9-3.14 across Linux, macOS, and Windows.

Related

@github-actions
Copy link

Preview Deployed

Content Preview URL
Site https://suews.io/preview/pr-1040/
Docs https://suews.io/preview/pr-1040/docs/

Note

This preview is ephemeral. It will be lost when:

  • Another PR with site/ or docs/ changes is pushed
  • Changes are merged to master
  • A manual workflow dispatch runs

To restore, push any commit to this PR.

sunt05 and others added 11 commits January 11, 2026 09:52
…GH#972)

Decompose netradiationmethod into orthogonal dimensions (physics + longwave)
instead of exposing numeric codes directly. This provides a cleaner, more
intuitive YAML configuration format whilst maintaining full backward compatibility.

- Add physics_options.py with RadiationPhysics, LongwaveSource enums and
  NetRadiationMethodConfig container
- Update ModelPhysics to use NetRadiationMethodConfig for netradiationmethod
- Add @field_validator for legacy form coercion
- Update DataFrame conversion methods for Fortran interface
- Add physics and longwave properties to NetRadiationMethod enum
- Update test assertions to use .int_value property

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The new physics_options module was missing from meson.build, causing
ModuleNotFoundError in CI builds and wheel tests.
…acy formats (GH#972)

- Add extensible tabbed documentation for dimensional config fields
- Display recommended nested format (physics/longwave dimensions) and
  deprecated legacy numeric codes side by side
- Fix GrassProperties title conflict causing RST heading ambiguity
- Extract enum options from docstrings for cleaner documentation
- Exclude inline nested models from separate file generation

The tabbed interface provides cleaner UX with formal deprecation warning
for legacy codes while showcasing the new orthogonal dimension structure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…#972)

- Add PhysicsOptionConfig ABC with shared `ref`, `__int__`, interface
- Add CodeMapper for bidirectional dimension-to-code mapping
- Rename netradiationmethod field `model` → `scheme` for clarity
- Reorder emissionsmethod fields: `heat` first, `co2` second
- Update docs: "Legacy (Deprecated)" → "Legacy" with softer wording
- Remove unnecessary wrapper functions (use mappers directly)
- Consolidate tests into test_data_model.py

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…H#972)

- Add _coerce_enum_value() helper for case-insensitive enum lookup
- Add field validators for all single-dimensional physics options:
  storageheatmethod, ohmincqf, roughlenmommethod, roughlenheatmethod,
  stabilitymethod, smdmethod, waterusemethod, rslmethod, faimethod,
  rsllevel, gsmodel, snowuse, stebbsmethod, rcmethod
- Support formats: integer, string (any case), dict with value key
- Example: storageheatmethod: 5 | EHC | ehc | {value: "ehc"}

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…H#972)

- Use nested format for multi-dimensional options:
  - netradiationmethod: {scheme: narp, ldown: air}
  - emissionsmethod: {heat: J11, co2: none}
- Use string names for single-dimensional options:
  - storageheatmethod: ohm_without_qf (was value: 1)
  - stabilitymethod: campbell_norman (was value: 3)
  - etc.
- Add inline comments explaining the two conventions
- More readable and self-documenting for users

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add user-friendly short aliases following conventions:
- Xyy format: author initial + two-digit year (e.g., K09, CN98, W16)
- yes/no for binary options (ohmincqf, snowuse)
- Simple keywords for others (ohm, model, auto, off)

Short aliases added for all single-dimensional physics options:
- storageheatmethod: obs, ohm, S17, O05, ehc, L25, stebbs
- ohmincqf: no, yes
- roughlenheatmethod: B82, K09, VG00, K07, auto
- stabilitymethod: H88, CN98, BH71
- gsmodel: J11, W16
- And more...

Update sample_config.yml to demonstrate short aliases.
Both full names and short aliases remain valid input.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change aliases to use recognisable model/method names where they exist:
- storageheatmethod: anohm, estm, ehc, dyohm (not S17, O05, L25)
- roughlenheatmethod: kawai, kanda, brutsaert (not K09, K07, B82)
- stabilitymethod: campbell, hoegstrom, businger (not CN98, H88, BH71)
- gsmodel: jarvi, ward (not J11, W16)
- roughlenmommethod: macdonald, lambdap (not M98, GO99)

Model names are more intuitive and recognisable to users than
author-year codes. Xyy format should only be used when no model name.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…dels (GH#972)

Alias convention:
- Explicit model names: ohm, anohm, estm, ehc, dyohm, stebbs, narp, most, rst
- Author methods (Xyy): K09, CN98, W16, J11, B82, K07, H88, B71, M98, GO99
- Generic terms: fixed, variable, auto, model, obs, yes, no, off

Examples:
- roughlenheatmethod: K09 (Kawai 2009)
- stabilitymethod: CN98 (Campbell & Norman 1998)
- gsmodel: W16 (Ward 2016)
- storageheatmethod: ohm (explicit model name)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…H#972)

The `X | None` union syntax (PEP 604) requires Python 3.10+.
Changed to Optional[X] for Python 3.9 support.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive documentation for the physics option alias system:

In model.py:
- Detailed comment block explaining the 5 input format types
- Examples for each format type
- Note on case-insensitivity

In sample_config.yml:
- Header explaining the naming convention
- Inline comments showing valid values for each option
- Clear separation between multi-dimensional and single-dimensional options

Format types documented:
1. Numeric codes (legacy): storageheatmethod: 1
2. Model names: ohm, anohm, estm, ehc, narp, most, rst
3. Author-year (Xyy): K09, CN98, W16, J11
4. Descriptive: fixed, variable, auto, model, obs
5. Binary: yes/no

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sunt05 sunt05 force-pushed the sunt05/gh972-investigation branch from 57bb161 to a0b8140 Compare January 11, 2026 09:52
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.

Feat: Sub-options for model physics options

2 participants