Regional power spectra using Discrete Cosine Transform (DCT)#1765
Regional power spectra using Discrete Cosine Transform (DCT)#1765cehalliwell merged 21 commits intomainfrom
Conversation
|
Power spectra calculated over regional (limited area) domain using Discrete Cosine Transform (DCT). This code is based on Denis et al 2002. The code calculates power spectrum on a single (surface, pressure or model) level for each specified time/level but does not yet allow aggregation or consider ensembles. Mean spectra over a specified time period for each level and/or mean spectra over a range of levels at a specified time may be future options. M365 Copilot was used to optimise the code and give code suggestions. |
|
Power Spectrum code changed so that the power spectrum is now calculated in _plot_and_save_power_spectrum_series rather than a separate operator. This is so results from multiple models can be plotted on the same plot. The unit tests for the power spectrum code have now been updated to reflect these changes. There are currently only 2 recipes: which allow plotting of power spectrum on model, pressure and surface levels. There is no method of aggregation at the moment. This might involve taking mean of spectra over times or levels but needs further investigation. |
daflack
left a comment
There was a problem hiding this comment.
This PR is looking good. I've got a few comments here, and some more specific ones in the code.
It is worth considering tests for the following: 3D data, a cubelist, no coordinate named time present (if allowing it, see comments in code), a multi-model run, a test to cover the other options of L2649, L2692, and L2702of plot.py if those if statements are needed.
It would be nice to include somewhere (either in the function description, or the recipe description) a quick guide to interpretation of power spectra.
You also need to update the conda lock files too: Actions -> Update conda lock files -> Run workflow, select your branch, and then merge in the PR that the bot creates into your PR.
Finally, it might be worth getting someone else to do a technical review of this PR as well, or discuss with @jfrost-mo whether the power spectra code should be separate from the plotting code. My only thought behind this is that for aggregation purposes it might be easier to have the calculation of the power spectra separate.
It's really great to see progress on this, and the output looks fantastic.
jfrost-mo
left a comment
There was a problem hiding this comment.
A couple minor comments but overall I think it looks good. Feel free to merge after addressing.
|
The tests will also need fixing, looks like just a rename required. |
Co-authored-by: James Frost <james.frost@metoffice.gov.uk>
Co-authored-by: James Frost <james.frost@metoffice.gov.uk>
Co-authored-by: James Frost <james.frost@metoffice.gov.uk>
Co-authored-by: James Frost <james.frost@metoffice.gov.uk>
Co-authored-by: James Frost <james.frost@metoffice.gov.uk>
I've taken over this review for David.

Follows on from #215
Calculate power spectra of 2D field in regional model using Discrete Fourier Transform (DCT)
Contribution checklist
Aim to have all relevant checks ticked off before merging. See the developer's guide for more detail.