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

Microphysics package with saturation adjustment #522

Merged
merged 43 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f8fde5d
empty microphysics package
halungge Jul 9, 2024
8b88e3d
Merge branch 'main' into microphysics_package
OngChia Jul 23, 2024
828df27
merge from graupel branch. Saturation adjustment component in progress
OngChia Jul 24, 2024
8daefcb
saturation adjustment component completed
OngChia Jul 25, 2024
60f2f14
introduce type_alias in saturation adjustment
OngChia Jul 26, 2024
251619e
Merge branch 'main' into microphysics_package
OngChia Jul 26, 2024
786e66b
embedded graupel scheme tested ok
OngChia Aug 8, 2024
d643cf6
remove graupel from this branch
OngChia Aug 9, 2024
de5feb0
merge main
OngChia Aug 12, 2024
9664b60
add documentation
OngChia Aug 12, 2024
cc9dd21
precommit and clean up
OngChia Aug 12, 2024
a2cde81
remove redundant comment in test_saturation_adjustment
OngChia Aug 12, 2024
0055274
change physics to subgrid_scale_physics and removed redundant code
OngChia Aug 12, 2024
e605ab7
fix wrong rename
OngChia Aug 12, 2024
0f3be83
precommit and fix documentation
OngChia Aug 12, 2024
b52a619
undo torus temporary fix and ammend satad documentation
OngChia Aug 13, 2024
99f8aeb
update installation requirement text and readme in model package
OngChia Aug 13, 2024
476c07e
Merge branch 'main' into microphysics_package
OngChia Aug 13, 2024
9e49d53
fix model install requirement
OngChia Aug 13, 2024
4f10bc8
Merge branch 'main' into microphysics_package
OngChia Aug 14, 2024
fe46f57
review changes
OngChia Aug 15, 2024
6728941
add original name in ICON for constants
OngChia Aug 15, 2024
3597c9f
add more docstring
OngChia Aug 16, 2024
9593e49
add diagnostic computation after saturation adjustment
OngChia Aug 19, 2024
c13bdbf
fix potential bugs in diagnostic calculations and add in diagnostic p…
OngChia Aug 20, 2024
587c514
new download link for wk experiment
OngChia Aug 20, 2024
4b7bd4d
merge main
OngChia Aug 21, 2024
cc5e0e2
split into two datatests for satad, fix bug, and add todo in diagnose…
OngChia Aug 21, 2024
80c58e2
precommit
OngChia Aug 21, 2024
a5c82fa
fix diagnostic stencil tests
OngChia Aug 21, 2024
615d798
move init_exner_pr
OngChia Aug 23, 2024
5591fe3
change import for diagnostic stencils and tests
OngChia Aug 23, 2024
84e6007
precommit
OngChia Aug 23, 2024
b765132
fix license issue in microphysics package
OngChia Aug 26, 2024
a6563ee
add docstring for edge_2_cell_vector_rbf_interpolation
OngChia Aug 26, 2024
f343e5a
set virtual temp in driver test cases and fix import
OngChia Aug 26, 2024
ef1b7eb
add todo for WK experiemnt grid
OngChia Aug 26, 2024
7ba8f3c
rm init_exner_pr stencil test
OngChia Aug 27, 2024
e4c9c2d
add satad input output attributes, and common model attributes
OngChia Aug 29, 2024
e40a3f3
Merge branch 'main' into microphysics_package
OngChia Aug 30, 2024
396a2c9
Merge branch 'main' into microphysics_package
OngChia Aug 30, 2024
22afdfe
merge main
OngChia Sep 3, 2024
3dc536a
use the new grid domain function in satad
OngChia Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ repos:
pass_filenames: false
always_run: true

- id: run-atmosphere-microphysics-precommit
name: Run Model Atmosphere Microphysics Pre-commit
entry: pre-commit run --config model/atmosphere/subgrid_scale_physics/microphysics/.pre-commit-config.yaml --all-files
language: system
pass_filenames: false
always_run: true

- id: run-tools-precommit
name: Run Tools Pre-commit
entry: pre-commit run --config tools/.pre-commit-config.yaml --all-files
Expand Down
2 changes: 1 addition & 1 deletion ci/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ test_model_datatests:
- tox -r -e run_model_tests -c model/ --verbose -- --backend=$BACKEND $COMPONENT
parallel:
matrix:
- COMPONENT: [atmosphere/diffusion/tests/diffusion_tests, atmosphere/dycore/tests/dycore_tests, common/tests, driver/tests]
- COMPONENT: [atmosphere/diffusion/tests/diffusion_tests, atmosphere/dycore/tests/dycore_tests, atmosphere/subgrid_scale_physics/microphysics/tests, common/tests, driver/tests]
BACKEND: [gtfn_cpu]
1 change: 1 addition & 0 deletions model/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ It includes the following packages:
- `atmosphere/dycore`: Contains implementations of the dynamical core of the ICON model
- `atmosphere/diffusion`: Contains the implementation of diffusion in the ICON model
- `atmosphere/advection`: Contains implementations of the advection component of the ICON model
- `atmosphere/subgrid_scale_physics/microphysics`: Contains implementations of the microphysics component of the ICON model
OngChia marked this conversation as resolved.
Show resolved Hide resolved
- `common`: Contains shared functionality that is required by multiple components.
- `driver`: Contains the driving code for the model

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[bumpversion]
current_version = 0.0.6
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))?
serialize =
{major}.{minor}.{patch}

[bumpversion:file:src/icon4py/model/atmosphere/subgrid_scale_physics/microphysics/__init__.py]
parse = \"(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))?\"
serialize =
{major}.{minor}.{patch}
44 changes: 44 additions & 0 deletions model/atmosphere/subgrid_scale_physics/microphysics/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[flake8]
# Some sane defaults for the code style checker flake8
max-line-length = 100
max-complexity = 15
doctests = true
extend-ignore =
# Do not perform function calls in argument defaults
B008,
# Public code object needs docstring
D1,
# Disable dargling errors by default
DAR,
# Whitespace before ':' (black formatter breaks this sometimes)
E203,
# Line too long (using Bugbear's B950 warning)
E501,
# Line break occurred before a binary operator
W503,
# import statement "abs" is shadowing a Python builtin
A004

exclude =
.eggs,
.gt_cache,
.ipynb_checkpoints,
.tox,
_local_,
build,
dist,
docs,
_external_src,
tests/_disabled,
setup.py

rst-roles =
py:mod, mod,
py:func, func,
py:data, data,
py:const, const,
py:class, class,
py:meth, meth,
py:attr, attr,
py:exc, exc,
py:obj, obj,
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# NOTE: pre-commit runs all hooks from the root folder of the repository,
# as regular git hooks do. Therefore, paths passed as arguments to the plugins
# should always be relative to the root folder.

default_stages: [commit, push]
default_language_version:
python: python3.10
minimum_pre_commit_version: 2.20.0
halungge marked this conversation as resolved.
Show resolved Hide resolved
files: "model/atmosphere/subgrid_scale_physics/microphysics/.*"

repos:
- repo: meta
hooks:
- id: check-hooks-apply
stages: [manual]
- id: check-useless-excludes
stages: [manual]

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.20.1
hooks:
# Run only manually because it deletes comments
- id: setup-cfg-fmt
name: format setup.cfg
stages: [manual]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.6.0
hooks:
- id: pretty-format-ini
args: [--autofix]
- id: pretty-format-toml
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix, --preserve-quotes, --indent, "2"]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
hooks:
- id: prettier
types_or: [markdown, json]

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.0
halungge marked this conversation as resolved.
Show resolved Hide resolved
hooks:
- id: insert-license
name: add license for all ICON4Py Python source files
types: [python]
args: [--comment-style, "|#|", --license-filepath, model/.license_header.txt, --fuzzy-match-generates-todo]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: local
hooks:
- id: mypy
name: mypy static type checker
entry: bash -c 'echo mypy temporarily disabled'
#entry: bash -c 'cd model/atmosphere/subgrid_scale_physics/microphysics; mypy src/' --
language: system
types_or: [python, pyi]
always_run: true
#pass_filenames: false
require_serial: true
stages: [commit]
9 changes: 9 additions & 0 deletions model/atmosphere/subgrid_scale_physics/microphysics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# icon4py-atmosphere-physics-microphysics

## Description

Port of ICON microphysics module 'saturation_adjustment' to gt4py.

## Installation instructions

Check the `README.md` at the root of the `model` folder for installation instructions.
139 changes: 139 additions & 0 deletions model/atmosphere/subgrid_scale_physics/microphysics/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=61.0", "wheel>=0.40.0"]

[project]
authors = [
{email = "[email protected]"},
{name = "ETH Zurich"}
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
OngChia marked this conversation as resolved.
Show resolved Hide resolved
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Atmospheric Science",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics"
]
dependencies = [
"gt4py>=1.0.1",
"icon4py-common>=0.0.5"
]
description = "ICON microphysics."
dynamic = ['version']
license = {file = "LICENSE"}
name = "icon4py-atmosphere-subgrid_scale_physics-microphysics"
readme = "README.md"
requires-python = ">=3.10"

[project.urls]
repository = "https://github.com/C2SM/icon4py"

[tool.coverage]

[tool.coverage.html]
directory = 'tests/_reports/coverage_html'

[tool.coverage.paths]
source = ['src/icon4py/model/']

[tool.coverage.report]
exclude_lines = [
'raise AssertionError', # Don't complain if tests don't hit defensive assertion code
'raise NotImplementedError', # Don't complain if tests don't hit defensive assertion code
'if 0:', # Don't complain if non-runnable code isn't run
'if __name__ == .__main__.:' # Don't complain if non-runnable code isn't run
]
ignore_errors = true

[tool.coverage.run]
branch = true
parallel = true
source_pkgs = ['microphysics']

[tool.mypy]
disallow_incomplete_defs = true
disallow_untyped_defs = true
exclude = [
'^tests/*.py'
]
ignore_missing_imports = false
implicit_reexport = true
install_types = true
non_interactive = true
show_column_numbers = true
show_error_codes = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true

[tool.pytest]

[tool.pytest.ini_options]
addopts = ['-p icon4py.model.common.test_utils.pytest_config']
testpaths = 'tests'

[tool.ruff]
extend-exclude = [
'.eggs',
'.gt_cache',
'.ipynb_checkpoints',
'.tox',
'_local_',
'build',
'dist',
'docs',
'_external_src',
'tests/_disabled',
'setup.py'
]
indent-width = 4
line-length = 100
respect-gitignore = true
show-fixes = true
# Assume Python 3.10
target-version = "py310"

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint]
extend-select = ['E', 'F', 'I', 'B', 'A', 'T10', 'ERA', 'NPY', 'RUF']
# # Rules sets:
# E: pycodestyle
# F: Pyflakes
# I: isort
# B: flake8-bugbear
# A: flake8-builtins
# T10: flake8-debugger
# ERA: eradicate
# NPY: NumPy-specific rules
# RUF: Ruff-specific rules
ignore = [
'E501', # Line too long (using Bugbear's B950 warning)
'RUF009' # Do not perform function call in dataclass defaults
]
ignore-init-module-imports = true

[tool.ruff.lint.isort]
combine-as-imports = true
known-first-party = ['icon4py.model']
known-third-party = [
'gt4py'
]
lines-after-imports = 2

[tool.ruff.lint.mccabe]
max-complexity = 15

[tool.setuptools.dynamic]
version = {attr = 'icon4py.model.atmosphere.subgrid_scale_physics.microphysics.__init__.__version__'}

[tool.setuptools.package-data]
'icon4py.model.atmosphere.subgrid_scale_physics.microphysics' = ['py.typed']
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r ../../../../base-requirements-dev.txt
-e ../../../common
-e .
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r ../../../../base-requirements.txt
../../../common
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ICON4Py - ICON inspired code in Python and GT4Py
halungge marked this conversation as resolved.
Show resolved Hide resolved
#
# Copyright (c) 2022, ETH Zurich and MeteoSwiss
# All rights reserved.
#
# This file is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or any later
# version. See the LICENSE.txt file at the top-level directory of this
# distribution for a copy of the license or check <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later

from typing import Final

from packaging import version as pkg_version


__all__ = [
"__author__",
"__copyright__",
"__license__",
"__version__",
"__version_info__",
]
__author__: Final = "ETH Zurich and individual contributors"
__copyright__: Final = "Copyright (c) 2014-2022 ETH Zurich"
__license__: Final = "GPL-3.0-or-later"
halungge marked this conversation as resolved.
Show resolved Hide resolved


__version__: Final = "0.0.6"
__version_info__: Final = pkg_version.parse(__version__)
Loading
Loading