AtChem / AtChem2

Atmospheric chemistry box-model for the MCM
MIT License
59 stars 23 forks source link

Add support for kpp format #497

Closed rs028 closed 11 months ago

rs028 commented 1 year ago

This will let the model use chemical mechanisms in KPP format (issue #304).

Also includes minor and cosmetic changes to the Python scripts in build/ and tools/ (checked using pylint) and to some bash scripts.

This also changes the version number back to development towards the 1.3 release (1.3-dev).

codecov[bot] commented 1 year ago

Codecov Report

Merging #497 (25cd946) into master (457b3e4) will not change coverage. Report is 2 commits behind head on master. The diff coverage is 100.00%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/AtChem/AtChem2/pull/497/graphs/tree.svg?width=650&height=150&src=pr&token=4p5Cr68G8w&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem)](https://app.codecov.io/gh/AtChem/AtChem2/pull/497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem) ```diff @@ Coverage Diff @@ ## master #497 +/- ## ======================================= Coverage 66.66% 66.66% ======================================= Files 17 17 Lines 2049 2049 ======================================= Hits 1366 1366 Misses 683 683 ``` | Flag | Coverage Δ | | |---|---|---| | build | `52.70% <100.00%> (ø)` | | | tests | `66.83% <100.00%> (ø)` | | | unittests | `54.78% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/AtChem/AtChem2/pull/497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem) | Coverage Δ | | |---|---|---| | [src/atchem2.f90](https://app.codecov.io/gh/AtChem/AtChem2/pull/497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem#diff-c3JjL2F0Y2hlbTIuZjkw) | `87.68% <100.00%> (ø)` | | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/AtChem/AtChem2/pull/497?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/AtChem/AtChem2/pull/497?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem). Last update [457b3e4...25cd946](https://app.codecov.io/gh/AtChem/AtChem2/pull/497?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem).
codecov[bot] commented 1 year ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (4373dc9) 52.00% compared to head (7d1fdc1) 52.05%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #497 +/- ## ========================================== + Coverage 52.00% 52.05% +0.04% ========================================== Files 17 17 Lines 2096 2096 Branches 166 166 ========================================== + Hits 1090 1091 +1 + Misses 934 933 -1 Partials 72 72 ``` | [Files](https://app.codecov.io/gh/AtChem/AtChem2/pull/497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem) | Coverage Δ | | |---|---|---| | [src/atchem2.f90](https://app.codecov.io/gh/AtChem/AtChem2/pull/497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem#diff-c3JjL2F0Y2hlbTIuZjkw) | `78.53% <100.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/AtChem/AtChem2/pull/497/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AtChem)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

rs028 commented 1 year ago

The procedure involves a new script kpp_conversion.py which converts the mechanism in KPP format to a .fac file, which is then processed as usual. Possibly not the most efficient way to do it, but the easiest to implement.

This only works for the KPP files created by the MCM website. There is a large variability in the possible format of kpp files so it is hard to do better without specific examples.

Two new tests are also added to verify that the conversion is correct: a reference test with a normal fac mechanism and an identical (ie using same config) test using a kpp mechanism. They give the same results.

spco commented 11 months ago

I think this all makes sense. On formatting and style, I have thoughts we should use existing external tools rather than rolling our own if possible - will create a separate issue.

rs028 commented 11 months ago

@spco thanks a lot!