Skip to content

Conversation

@sunt05
Copy link

@sunt05 sunt05 commented Nov 27, 2025

Summary

Implements object-oriented interfaces for SUEWS output and forcing data, improving the simulation API ergonomics.

Changes

  • Add SUEWSForcing class for meteorological input with validation, analysis, and manipulation methods
  • Add SUEWSOutput class for simulation results with analysis and export capabilities
  • Update SUEWSSimulation.run() to return SUEWSOutput instead of raw DataFrame
  • Add SUEWSSimulation.from_output() for seamless continuation runs
  • Update tests to use new OOP interfaces

Design

Both classes provide intuitive attribute access (e.g., forcing.temperature), alongside professional APIs with full documentation. Methods follow pandas conventions for familiar usage.

@github-actions
Copy link

🤖 I've automatically formatted the code in this PR using:

  • Python: ruff v0.8.6
  • Fortran: fprettify v0.3.7

Please pull the latest changes before making further edits.

@sunt05 sunt05 force-pushed the sunt05/oop-output-forcing branch 2 times, most recently from a50409d to 5a5bc59 Compare November 27, 2025 12:51
sunt05 and others added 5 commits November 27, 2025 19:41
- Add SUEWSForcing and SUEWSOutput classes for object-oriented data handling
- Update SUEWSSimulation.run() to return SUEWSOutput instead of DataFrame
- Add from_output() classmethod for continuation runs
- Update forcing property to return SUEWSForcing wrapper
- Update tests to use new OOP interfaces
Co-authored-by: sunt05 <1802656+sunt05@users.noreply.github.com>
Add missing pandas-like properties to SUEWSForcing and SUEWSOutput
classes to ensure compatibility with existing test code:

SUEWSForcing:
- index: DatetimeIndex access
- loc: Label-based indexer
- iloc: Integer-based indexer

SUEWSOutput:
- empty: Check if output is empty
- columns: Column index access
- loc/iloc: Indexers for data access
- xs(): Cross-section method for MultiIndex
- Updated __getattr__ to check group names

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add deprecation warnings to methods superseded by pandas-compatible
properties:

SUEWSForcing:
- times -> use .index
- n_timesteps -> use len(forcing)
- to_dataframe() -> use .df

SUEWSOutput:
- n_grids -> use len(output.grids)
- n_timesteps -> use len(output.times)
- to_dataframe() -> use .df

All deprecated methods still work but emit DeprecationWarning to guide
users towards the preferred pandas-like API.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add deprecation warning to util.read_forcing() pointing users to
  SUEWSForcing.from_file()
- Extract internal _read_forcing_impl() for use by SUEWSForcing
  without triggering deprecation warnings
- Update SUEWSForcing.from_file/from_files to use internal function

This completes the deprecation of the functional API in favour of the
modern OOP interface.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@sunt05 sunt05 force-pushed the sunt05/oop-output-forcing branch from 5a5bc59 to a58c352 Compare November 27, 2025 19:42
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