Skip to content

Add pulse timings dataclass - #4497

Merged
clmould merged 14 commits into
mainfrom
add_pulse_timings_dataclass
Aug 12, 2026
Merged

Add pulse timings dataclass#4497
clmould merged 14 commits into
mainfrom
add_pulse_timings_dataclass

Conversation

@chris-ashe

@chris-ashe chris-ashe commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

This pull request refactors how pulse timing and cumulative time points are handled throughout the codebase by introducing and consistently applying the PulseTimings class. This change improves code clarity, reduces duplication, and centralizes pulse timing logic, making it easier to maintain and extend. The update affects plotting routines, model calculations, and output formatting for pulse-related data.

Pulse timing refactor and centralization:

  • Replaced manual cumulative time calculations in plotting functions (e.g., plot_current_profiles_over_time, plot_system_power_profiles_over_time, plot_cs_stress_time_profile) with usage of the new PulseTimings class, ensuring consistent time axis generation and annotation across all plots.

  • Updated model logic in physics.py and pfcoil.py to use PulseTimings for all derived pulse timing values, such as total pulse time, plasma-present time, and no-burn time, removing duplicated cumulative sum logic.

  • Modified power system models (power.py) to pass PulseTimings as an argument to the PF coil power calculation routines (pfpwr), ensuring all power calculations use unified pulse timing data.
    Output and labeling improvements:

  • Standardized the use of pulse time labels and cumulative time points in output routines and plot annotations, using properties from PulseTimings for axis tick labels and time column headers.

Cleanup and removal of legacy code:

  • Removed legacy time label arrays and manual cumulative time calculations from times_variables.py and related model files, reducing code redundancy.

Checklist

I confirm that I have completed the following checks:

  • My changes follow the PROCESS style guide
  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

@codecov-commenter

codecov-commenter commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.67677% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.22%. Comparing base (6dbb302) to head (246ec27).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
process/core/io/plot/summary.py 14.28% 18 Missing ⚠️
process/models/pfcoil.py 16.66% 5 Missing ⚠️
process/models/pulse.py 90.90% 5 Missing ⚠️
process/models/physics/physics.py 33.33% 2 Missing ⚠️
process/models/power.py 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4497      +/-   ##
==========================================
- Coverage   49.30%   49.22%   -0.08%     
==========================================
  Files         151      152       +1     
  Lines       29611    29842     +231     
==========================================
+ Hits        14599    14691      +92     
- Misses      15012    15151     +139     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chris-ashe
chris-ashe marked this pull request as ready for review August 4, 2026 12:31
@chris-ashe
chris-ashe requested a review from a team as a code owner August 4, 2026 12:31
@clmould clmould self-assigned this Aug 5, 2026
Comment thread process/models/power.py
Comment thread process/models/power.py Outdated
Comment thread process/models/power.py Outdated
Comment thread tests/unit/models/test_power.py Outdated
Comment thread process/models/power.py Outdated
Comment thread process/core/io/plot/summary.py Outdated
Comment thread process/models/pulse.py Outdated
return len(self.total_pulse_cumulative)

@property
def n_pulse_points_intervals_total(self) -> int:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be getting used anywhere ?

Comment thread process/models/pulse.py Outdated
Comment thread process/models/power.py Outdated
Comment thread process/models/pulse.py Outdated
…naming and enhance validation in PulseTimings dataclass
Comment thread process/models/pulse.py
Comment thread process/models/pulse.py Outdated
Comment thread process/models/power.py
chris-ashe and others added 2 commits August 11, 2026 10:08
Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>
@chris-ashe
chris-ashe requested a review from clmould August 11, 2026 09:08

@clmould clmould left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just 1 small change
Also could you fix the pre-commit failure too please?

Comment thread process/models/pulse.py Outdated
… and POINT_ABBREVIATIONS for improved clarity and consistency
@clmould
clmould merged commit f348c60 into main Aug 12, 2026
10 of 11 checks passed
@clmould
clmould deleted the add_pulse_timings_dataclass branch August 12, 2026 13:12
chris-ashe added a commit that referenced this pull request Aug 12, 2026
* Add PulseTimings dataclass for managing pulse timing parameters

* Enhance PulseTimings class with timing interval properties and refactor PFCoil to utilize it

* Refactor PulseTimings class to enhance timing calculations and add properties for PF coil active phases

* Refactor PFCoil power model to utilize PulseTimings dataclass for improved timing management

* Refactor plot functions to utilize PulseTimings dataclass for improved timing management

* Refactor Power model and test to utilize PulseTimings dataclass for improved pulse timing management

* Refactor TimesData and PulseTimings classes to remove unused labels and integrate point abbreviations for improved clarity in timing management

* Refactor Power model and test to utilize PulseTimings dataclass for timing management

* Refactor plot functions to utilize updated point labels from PulseTimings dataclass for improved clarity in timing representation

* Remove unused t_pulse_cumulative field from TimesData dataclass for cleaner code

* Refactor Power model and tests to standardize PulseTimings parameter naming and enhance validation in PulseTimings dataclass

* Enhance PulseTimings dataclass validation and remove unused property for clarity

* Update process/models/power.py

Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>

* Refactor PulseTimings dataclass to standardize naming of POINT_LABELS and POINT_ABBREVIATIONS for improved clarity and consistency

---------

Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants