Initial support for aerosols in PROTEUS, improve chemistry plot, and fix broken links in readme#665
Initial support for aerosols in PROTEUS, improve chemistry plot, and fix broken links in readme#665
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a configurable switch for AGNI aerosol radiative effects via the PROTEUS config system, updates the AGNI demo configuration accordingly, and fixes broken README documentation links to match the current Diátaxis docs structure.
Changes:
- Add
atmos_clim.aerosols_enabledconfiguration option and wire it into AGNI initialization. - Detect available aerosol species from the FWL data directory and pass them to AGNI (initially with zero MMR).
- Update README documentation links to the correct
/How-to,/Explanations,/Reference, and/Communitypages.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/proteus/config/_atmos_clim.py |
Adds aerosols_enabled to AtmosClim config and reuses existing validators. |
src/proteus/atmos_clim/agni.py |
Detects aerosol species and passes flag_aerosol/aerosol_species into AGNI.atmosphere.setup_b. |
input/demos/agni.toml |
Adds aerosol/cloud toggles to the demo configuration (currently placed in the wrong table). |
README.md |
Fixes documentation links to match the current docs site structure. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #665 +/- ##
==========================================
+ Coverage 69.08% 70.23% +1.15%
==========================================
Files 98 98
Lines 10123 10207 +84
Branches 1401 1421 +20
==========================================
+ Hits 6993 7169 +176
+ Misses 2791 2749 -42
+ Partials 339 289 -50
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…netcdf. Update chemistry plot. Add colours
|
@timlichtenberg I think this is now ready for review. Not sure why the codecov report says some lines are uncovered, because the function is clearly being called and I have confirmed this manually by adding |
There was a problem hiding this comment.
Awesome work! When fully integrated this will open a whole new category of applications. A few things to address before merging, most important is a potential crash when plotting output from runs without aerosols.
-
KeyErroronatm_profile['aerosols']incpl_chem_atmosphere.py: the aerosol loop accesses this key unconditionally, butread_ncdf_profileonly populates it when the NetCDF has aerosol data. The cloud block right above correctly guards withif 'cloud_mmr' in atm_profile.keys(), but the aerosol block does not. This will crash on any pre-aerosol run output. Should beatm_profile.get('aerosols', []). -
num_aerosolsstarts at 1, not 0. This inflates the legend column count. If there are no aerosols and no cloud, it still counts 1. Should start at 0 and increment separately when the cloud is plotted. -
fig.textwithtransform=ax1.transAxes: this works by accident because (0.02, 0.98) inax1axes coords happens to land in the right spot. Should beax1.text(...)instead. If the layout changes this will silently break. -
aer_mmrreading incommon.py: the guard checks'aer_mmr' in ds.variablesbut then unconditionally readsds.variables['aerosols']for species names. If the file has one but not the other, this crashes. Addand 'aerosols' in ds.variables.keys()to the guard. -
No OSF fallback for scattering data. All other entries in
DATA_SOURCE_MAPhave both Zenodo and OSF IDs. I know we move to other sources, but should we add it until then?
|
Thanks, Tim, your comments are very useful. It's exciting to introduce this functionality and I look forward to developing it further with some schemes for calculating MMR profiles from the chemistry.
|
|
Nice! |
Another Code review found 3 more issues
PROTEUS/src/proteus/config/_atmos_clim.py Lines 19 to 21 in 24a9aae
PROTEUS/tests/plot/test_cpl_chem_atmosphere.py Lines 78 to 80 in 24a9aae PROTEUS/src/proteus/plot/cpl_chem_atmosphere.py Lines 171 to 176 in 24a9aae
PROTEUS/tests/plot/test_cpl_chem_atmosphere.py Lines 345 to 348 in 24a9aae PROTEUS/src/proteus/plot/cpl_chem_atmosphere.py Lines 251 to 261 in 24a9aae |
- Fix warn_if_dummy validator tests to pass attribute.name correctly - Fix plot tests: mock legend handles matching actual gas species - Fix plot tests: assert on fig_mock.savefig instead of plt.savefig - Fix time annotation test: assert on ax1_mock.text not fig_mock.text - Remove incorrect ax2_temp xlabel assertion (label is not set in code) Resolves all 3 issues identified in PR#665 review comments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
The above commit should fix the issues with the tests. The main changes are: update the mock-function calls to ensure that the correct number of gas labels/lines are returned, check that fig.savefig is called (which it is) rather than plt.savefig, and corrects issue with the dummy atmos_clim validator. I have also made sure to run these tests with This should address the issues in your last review @timlichtenberg One thing it made me realise: there's no functionality to check that all config options are parsed correctly. For example, a user might write |
|
Thanks, again, for catching these issues! Merging this now. |
Description
This PR aims to introduce aerosol support via PROTEUS. We will need to re-visit it via future PRs, when some kind of microphysical/chemical scheme is implemented in AGNI to derive aerosol mixing ratio profiles.
Validation of changes
PROTEUS runs fine and makes the new plot (see below). Note that the aerosol profiles are at MMR=0 because AGNI does not yet have a scheme for calculating these profiles. Also added tests for these new features (manually and using Copilot), which pass on my laptop and on the github runners.
Checklist
Relevant people
@timlichtenberg