Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add age of air diagnostic functionality #480

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open

Add age of air diagnostic functionality #480

wants to merge 76 commits into from

Conversation

jwarner8
Copy link
Contributor

@jwarner8 jwarner8 commented Apr 10, 2024

Adding capability to run the age of air diagnostic on data, linked to issue #269

Copy link
Contributor

github-actions bot commented Apr 10, 2024

Coverage

@jwarner8
Copy link
Contributor Author

Tests to do include;

  • Test calc distance with some known values.
  • Test shape is correctly rejecting if not all equal, also if time coord not hourly.
  • Check if time decreasing will fail correctly.
  • Check pressure level not found fails correctly.
  • check all variables present (need to add this in function directly).

@jwarner8
Copy link
Contributor Author

.yaml is going to look something like 1. read cubes, 2. filter cubes (u,v,w,p), might need some additional filtering to only get pressure level data, otherwise it might start returning 10m winds and we don't want/use this. Better to do this filtering in dedicated operators than start finding ways around this within the age of air operator itself. Run the age of air diagnostic, and then produce contourf plot; tbd (and data)

Copy link
Member

@jfrost-mo jfrost-mo left a comment

Choose a reason for hiding this comment

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

Some vague review comments. I've not properly read through and understood the code yet though. I'll do that a bit later.

src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
@jwarner8
Copy link
Contributor Author

Some vague review comments. I've not properly read through and understood the code yet though. I'll do that a bit later.

thanks! There is a lot more to add yet, this is mostly initial commits for copy/pasting code into CSET. So best to hold of any review, as code needs a lot of tidying up/documentation, plus all the testing and cylc/yaml additions

@jfrost-mo
Copy link
Member

Got a bit eager, but its great to see it coming along. I'll mark this PR as a draft for now.

@jfrost-mo jfrost-mo marked this pull request as draft April 11, 2024 09:11
@jfrost-mo jfrost-mo added enhancement New feature or request science Scientific capabilities labels Apr 11, 2024
@jwarner8
Copy link
Contributor Author

jwarner8 commented Apr 17, 2024

Meta

  • Create new template variable, with description. Q: what is sort-key.
  • If age of air turned on, create a new variety of options; plev; list, list of pressure levels to run code on. Includevertical; bool, cyclic; bool.
  • These variables (plev, includevertical, cyclic) need passing to yaml. Q: how to we get menu's to appear if diagnostic turned on.

YAML

  • Will inherit plev, includevertical, cyclic from those selected in the GUI (and thus rose-suite.conf). For the filter cubes, if includevertical is false, we don't need vertical velocity fields. Q: how to make the YAML not look for this STASH if option selected? Can we put logic in YAML? Or would it be better to have two YAML (vertical and no vertical)?
  • To plot, we can use standard contour plot and timeseries plot functionality already in CSET.

Cycling

  • Will run AOA task on each forecast intialisation, and loop through each plev specified in rose-suite.conf. For example for 2 forecasts, with only ageofair diagnostic turned on, and plev= [250,500,850], run-time would look like;

20240417T0000Z
task: ageofair_250
task: ageofair_500
task: ageofair_850
20240417T1200Z
task: ageofair_250
task: ageofair_500
task: ageofair_850

So all pressure levels run in parallel.

@jwarner8
Copy link
Contributor Author

Only thing left to do now is build the cylc workflow, tests etc. all done.

@jwarner8 jwarner8 marked this pull request as ready for review May 1, 2024 20:56
@jwarner8 jwarner8 requested a review from jfrost-mo May 1, 2024 20:57
@jwarner8 jwarner8 self-assigned this May 1, 2024
@jwarner8
Copy link
Contributor Author

jwarner8 commented May 1, 2024

Now ready for first stage technical review (quite a big changelog)
A TODO is how to visualise the result, 2D plots for each leadtime, but also want a timeseries (collapse latitude,longitude)

Copy link
Member

@jfrost-mo jfrost-mo left a comment

Choose a reason for hiding this comment

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

Thanks James, this seems like a really useful operator.

The largest thing is going to be updating the recipe to accommodate the changes we have made in CSET over the past couple months. It would probably be worth rebasing your changes on the latest version of the main branch to make that easier. (git rebase main, then fix a bunch of conflicts...)

I've noted a bunch of specific points, but the general design and approach are sound.

cset-workflow/includes/aoa_diag.cylc Outdated Show resolved Hide resolved
cset-workflow/meta/rose-meta.conf Outdated Show resolved Hide resolved
src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
tests/operators/test_ageofair.py Show resolved Hide resolved
src/CSET/operators/ageofair.py Show resolved Hide resolved
src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
@jfrost-mo jfrost-mo requested review from daflack and jfrost-mo May 23, 2024 13:23
cset-workflow/includes/aoa_diag.cylc Outdated Show resolved Hide resolved
cset-workflow/meta/rose-meta.conf Outdated Show resolved Hide resolved
cset-workflow/meta/rose-meta.conf Outdated Show resolved Hide resolved
cset-workflow/meta/rose-meta.conf Outdated Show resolved Hide resolved
cset-workflow/meta/rose-meta.conf Outdated Show resolved Hide resolved
tests/operators/test_ageofair.py Outdated Show resolved Hide resolved
tests/operators/test_ageofair.py Outdated Show resolved Hide resolved
tests/operators/test_ageofair.py Outdated Show resolved Hide resolved
@jfrost-mo
Copy link
Member

Note that there are other suggestions that GitHub has hidden under "hidden conversations". You might be better off looking through the Files tab for them.

@jwarner8 jwarner8 added the full_review Requires a technical, scientific, and portability review label May 30, 2024
@jwarner8
Copy link
Contributor Author

I think the design of this operator needs some consideration with how it will work with the current default of CSET of cycling through valid-time. The operator expects to be run once, for a given initialisation, and passed all the data for that forecast. I don't really know how compatible this is with the current architecture, because each calculation at each forecast time depends on the preceding data.

@jfrost-mo
Copy link
Member

For now this can be worked around by running the operator within the collate step. We are currently discussing a longer term change to cycling on data time, which would alleviate this.

@jwarner8
Copy link
Contributor Author

jwarner8 commented Jul 4, 2024

Update 04/07 - dependency on ability for regrid to handle cubelists (which will make the yaml much nicer as we need to repeat regridding for multiple variables). Links #720 #721

@jfrost-mo jfrost-mo marked this pull request as draft August 15, 2024 07:53
@jwarner8
Copy link
Contributor Author

jwarner8 commented Dec 10, 2024

Ready for final review. Only thing not implemented is the realise_data, as this throws up AttributeError: 'Cube' object has no attribute 'realise_data'. I am using standard names in the recipe x_wind, y_wind but suggestions of how I implement any existing lookup table welcome. I am also getting low coverage due to calls within multiprocessing - which might be related to how pytest-cov generates the coverage report (https://stackoverflow.com/questions/61143858/how-to-measure-coverage-when-using-multirpocessing-via-pytest).

Copy link
Contributor

@daflack daflack left a comment

Choose a reason for hiding this comment

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

One minor change in documentation: a bit of legacy documentation was still left over. Otherwise, from a scientific perspective it looks good.

src/CSET/operators/ageofair.py Outdated Show resolved Hide resolved
@jwarner8
Copy link
Contributor Author

Coverage near 100% now, so ready for final check before merge. Thanks all for time reviewing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request full_review Requires a technical, scientific, and portability review science Scientific capabilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants