Skip to content

Conversation

@cehalliwell
Copy link
Contributor

@cehalliwell cehalliwell commented Jan 8, 2026

Follows on from #1765

The power spectra is currently calculated and plotted in the main plot.py operator. However, this method does not allow aggregation of the power spectra (e.g. mean). The power spectra are calculated in a separate operator rather than in plot.py and the resulting power spectra plotted using the line series method in plot.py. After this, aggregation will be possible using the collapse operator.

Move the existing functions and code for calculating the power spectra into a separate operator, remove the existing power spectra code from plot.py and adjust the line series plotting code to allow for line plotting other than timeseries.

Contribution checklist

Aim to have all relevant checks ticked off before merging. See the developer's guide for more detail.

  • Documentation has been updated to reflect change.
  • New code has tests, and affected old tests have been updated.
  • All tests and CI checks pass.
  • Ensured the pull request title is descriptive.
  • Conda lock files have been updated if dependencies have changed.
  • Attributed any Generative AI, such as GitHub Copilot, used in this PR.
  • Marked the PR as ready to review.

@cehalliwell cehalliwell self-assigned this Jan 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2026

Coverage

@cehalliwell
Copy link
Contributor Author

As part of the restructuring, a wrapper is used for the power spectra code within power_spectrum operator. The field for which the power spectrum is to be calculated is split up into a cube for each model and time and power spectrum is then calculated for each before combining into one cube ahead of plotting. This is done to retain the model_name attribute for different models.

The generic function to plot a line other than a time series is called _plot_and_save_line_1D. It has been tested for power spectrum (called from plot_line_series with series_coordinate "frequency") but has not be tested for any other series_coordinate.

Microsoft Copilot was used to design the wrapper and tidy up _power_spectrum operator.

@cehalliwell
Copy link
Contributor Author

The tests from the original power spectrum code have been assessed and moved to test_power_spectrum, or within the plot_line_series code in test_plot or deleted as necessary. Extra tests have also been added for options in plot_line_series to check the options when series_coordinate is not time.

expand on explanatory text.
clarify description of internal function.
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.

3 participants