Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ default_language_version:
files: pyMoist

repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
additional_dependencies: ["click==8.0.4"]

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.4.2
hooks:
- id: isort
description: Group and sort Python imports
Copy link

Choose a reason for hiding this comment

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

we should also be able to get rid of isort if we go with ruff

args: ["--profile", "black"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy
description: Perform static type analysis of Python code
name: mypy-pyMoist
args: [
--ignore-missing-imports,
Expand All @@ -35,31 +31,40 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
name: codespell
description: Check for spelling errors
entry: codespell
args: ["--ignore-words","GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSmoist_GridComp/pyMoist/ignored_codespell.txt"]

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: flake8
name: flake8
language_version: python3
args: [
"--exclude=docs",
"--ignore=W503,E302,E203,F841",
"--max-line-length=88"
]
exclude: |
(?x)^(
.*/__init__.py |
)$
- id: flake8
name: flake8 __init__.py files
files: "__init__.py"
# ignore unused import error in __init__.py files
args: [
"--exclude=docs",
"--ignore=W503,E302,E203,F841,F401",
"--max-line-length=88",]
- id: pydocstyle
name: pydocstyle
description: Check docstrings in Python code for compliance with conventions
entry: pydocstyle
types: [python]
args: ["--ignore=D101,D102,D103,D105,D107,D203,D213,D406,D407"]

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.0
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
THIRDPARTY
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def aer_activation_stencil(
None
"""
with computation(PARALLEL), interval(...):

# Compute nwfa
# Fortran AeroProps aero_kap is aero_hygroscopicity
nfaux = 0.0
Expand Down Expand Up @@ -194,9 +193,7 @@ def aer_activation_stencil(
) # [1/m]
gamma = (constants.RGASJMOL * tk) / (wpe * constants.WMOLMASS) + (
constants.WMOLMASS * constants.HEATVAP * constants.HEATVAP
) / (
constants.CPAIR * plo * constants.AMOLMASS * tk
) # [m^3/kg]
) / (constants.CPAIR * plo * constants.AMOLMASS * tk) # [m^3/kg]
dum = sqrt(alpha * wupdraft / g) # [1/m]
zeta = 2.0 * a * dum / 3.0 # [1]

Expand All @@ -208,18 +205,18 @@ def aer_activation_stencil(
sm = (2.0 / sqrt(bibar[0, 0, 0][n])) * (
a / (3.0 * rg[0, 0, 0][n])
) ** 1.5 # [1]
eta = dum ** 3 / (
eta = dum**3 / (
constants.TWOPI * constants.DENH2O * gamma * ni[0, 0, 0][n]
) # [1]
f1 = 0.5 * exp(2.50 * xlogsigm ** 2) # [1]
f1 = 0.5 * exp(2.50 * xlogsigm**2) # [1]
f2 = 1.0 + 0.25 * xlogsigm # [1]
smax = (
smax
+ (
f1 * (zeta / eta) ** 1.5
+ f2 * (sm ** 2 / (eta + 3.0 * zeta)) ** 0.75
+ f2 * (sm**2 / (eta + 3.0 * zeta)) ** 0.75
)
/ sm ** 2
/ sm**2
) # [1] - eq. (6)
n += 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def Erf(x: Float) -> Float:
"""
erf = 0.0
if x < 0.0e00:
erf = -1.0 * GammP(0.5, x ** 2)
erf = -1.0 * GammP(0.5, x**2)
else:
erf = GammP(0.5, x ** 2)
erf = GammP(0.5, x**2)
return erf
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def cloud_effective_radius_ice(
1.0e-3 * (radconstants.MAPL_TICE - TE) ** 1.5
)
BB = min(max(BB, -6.0), -2.0)
RADIUS = 377.4 + 203.3 * BB + 37.91 * BB ** 2 + 2.3696 * BB ** 3
RADIUS = 377.4 + 203.3 * BB + 37.91 * BB**2 + 2.3696 * BB**3
RADIUS = min(150.0e-6, max(5.0e-6, 1.0e-6 * RADIUS))
else:
# Ice cloud effective radius ----- [Sun, 2001]
TC = TE - radconstants.MAPL_TICE
ZFSR = 1.2351 + 0.0105 * TC
AA = 45.8966 * (WC ** 0.2214)
BB = 0.79570 * (WC ** 0.2535)
AA = 45.8966 * (WC**0.2214)
BB = 0.79570 * (WC**0.2535)
RADIUS = ZFSR * (AA + BB * (TE - 83.15))
RADIUS = min(150.0e-6, max(5.0e-6, 1.0e-6 * RADIUS * 0.64952))
return RADIUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def redist_clouds(
QV: FloatField,
TE: FloatField,
):

with computation(PARALLEL), interval(...):
# Constants from MAPL.h
alhlbcp = radconstants.ALHLBCP
Expand Down Expand Up @@ -95,7 +94,6 @@ def __init__(
stencil_factory: StencilFactory,
quantity_factory: QuantityFactory,
) -> None:

self._redist_clouds = stencil_factory.from_dims_halo(
func=redist_clouds,
compute_dims=[X_DIM, Y_DIM, Z_DIM],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[lint]
ignore = ["F841"]

[lint.per-file-ignores]
# Ignore `E402` (import violations) in all `__init__.py` files
"__init__.py" = ["F401"]