Skip to content

Commit

Permalink
Merge pull request #25 from ecmwf/develop
Browse files Browse the repository at this point in the history
Merge develop into main for release 0.2.0
  • Loading branch information
sandorkertesz authored Nov 4, 2024
2 parents 9a4f462 + ef58809 commit b65e573
Show file tree
Hide file tree
Showing 27 changed files with 452 additions and 309 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ on:
# Trigger the workflow on push to master or develop, except tag creation
push:
branches:
- 'main'
- 'develop'
- "main"
- "develop"
tags-ignore:
- '**'
- "**"
paths-ignore:
- "docs/**"
- "README.md"

# Trigger the workflow on pull request
pull_request:
paths-ignore:
- "docs/**"
- "README.md"

# Trigger the workflow manually
workflow_dispatch:

# Trigger after public PR approved for CI
pull_request_target:
types: [labeled]
paths-ignore:
- "docs/**"
- "README.md"

jobs:
# Run CI including downstream packages on self-hosted runners
Expand All @@ -28,10 +37,9 @@ jobs:
with:
earthkit-meteo: ecmwf/earthkit-meteo@${{ github.event.pull_request.head.sha || github.sha }}
codecov_upload: true
python_qa: true
python_qa: false
secrets: inherit


# Build downstream packages on HPC
downstream-ci-hpc:
name: downstream-ci-hpc
Expand Down
14 changes: 1 addition & 13 deletions .github/workflows/legacy-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ defaults:
shell: bash -l {0}

jobs:
pre-commit:
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/[email protected]

documentation:
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
runs-on: ubuntu-latest
Expand All @@ -48,7 +36,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@v12
uses: mamba-org/setup-micromamba@v1
with:
environment-file: tests/environment-unit-tests.yml
environment-name: DEVELOP
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/python-pill-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Code Quality checks for PRs

on:
push:
pull_request:
types: [opened, synchronize, reopened]

jobs:
quality:
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-precommit-run.yml@v2
with:
skip-hooks: "no-commit-to-branch"
56 changes: 36 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: trailing-whitespace # Trailing whitespace checker
- id: end-of-file-fixer # Ensure files end in a newline
- id: check-json
- id: check-yaml
- id: check-yaml # Check YAML files for syntax errors only
args: [--unsafe, --allow-multiple-documents]
- id: check-toml
# - id: check-added-large-files
- id: debug-statements
# - id: check-added-large-files
- id: debug-statements # Check for debugger imports and py37+ breakpoint()
- id: mixed-line-ending
- id: no-commit-to-branch # Prevent committing to main / master
- id: check-merge-conflict # Check for files that contain merge conflict
exclude: /README\.rst$|^docs/.*\.rst$
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args:
- -l 110
- --force-single-line-imports
- --profile black
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.8.0
hooks:
- id: black
args: [--line-length=110]
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc
additional_dependencies: [black==23.3.0]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
exclude: xr_engine_profile_rst\.py
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
exclude: '(dev/.*|.*_)\.py$'
args:
- --line-length=110
- --fix
- --exit-non-zero-on-fix
- --preview
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.14
hooks:
Expand All @@ -37,11 +53,11 @@ repos:
hooks:
- id: pretty-format-yaml
args: [--autofix, --preserve-quotes]
- id: pretty-format-toml
args: [--autofix]
- repo: https://github.com/PyCQA/pydocstyle.git
rev: 6.1.1
hooks:
- id: pydocstyle
additional_dependencies: [toml]
exclude: tests|docs
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.0
hooks:
- id: sphinx-lint
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.2.4"
hooks:
- id: pyproject-fmt
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"autoapi.extension",
"sphinx_issues",
]

# autodoc configuration
Expand All @@ -62,6 +63,9 @@
napoleon_numpy_docstring = True
napoleon_preprocess_types = True

# Path to GitHub repo {group}/{project} (note that `group` is the GitHub user or organization)
issues_github_path = "ecmwf/earthkit-meteo"

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand Down
1 change: 1 addition & 0 deletions docs/release_notes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Release notes
.. toctree::
:maxdepth: 1

version_0.2_updates
version_0.1_updates
15 changes: 15 additions & 0 deletions docs/release_notes/version_0.2_updates.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Version 0.2 Updates
/////////////////////////


Version 0.2.0
===============

New features
+++++++++++++++

- Added the ``eps`` and ``out`` keywords arguments to control zero humidity in the following methods (:pr:`23`):

- :py:meth:`dewpoint_from_specific_humidity <meteo.thermo.array.dewpoint_from_specific_humidity>`
- :py:meth:`dewpoint_from_relative_humidity <meteo.thermo.array.dewpoint_from_relative_humidity>`
- :py:meth:`temperature_from_saturation_vapour_pressure <meteo.thermo.array.temperature_from_saturation_vapour_pressure>`
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ sphinx-rtd-theme
nbsphinx
setuptools
sphinx-autoapi
sphinx-issues
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
- sphinx-autoapi
- sphinx_rtd_theme
- sphinxcontrib-apidoc
- sphinx-issues
- nbformat
- nbconvert
- nbsphinx
Expand Down
58 changes: 28 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,58 +1,56 @@
[build-system]
requires = ["setuptools>=61", "setuptools-scm>=8.0"]
requires = [ "setuptools>=61", "setuptools-scm>=8" ]

[project]
name = "earthkit-meteo"
description = "Meteorological computations"
readme = "README.md"
license = { text = "Apache License Version 2.0" }
authors = [
{name = "European Centre for Medium-Range Weather Forecasts (ECMWF)", email = "[email protected]"}
{ name = "European Centre for Medium-Range Weather Forecasts (ECMWF)", email = "[email protected]" },
]
requires-python = ">=3.8"

classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Operating System :: OS Independent"
]
dynamic = [ "version" ]
dependencies = [
"numpy"
"numpy",
]
description = "Meteorological computations"
dynamic = ["version"]
license = {text = "Apache License Version 2.0"}
name = "earthkit-meteo"
readme = "README.md"
requires-python = ">= 3.8"

[project.optional-dependencies]
test = [
optional-dependencies.test = [
"pytest",
"pytest-cov"
"pytest-cov",
]
urls.Documentation = "https://earthkit-meteo.readthedocs.io/"
urls.Homepage = "https://github.com/ecmwf/earthkit-meteo/"
urls.Issues = "https://github.com/ecmwf/earthkit-meteo.issues"
urls.Repository = "https://github.com/ecmwf/earthkit-meteo/"

[project.urls]
Documentation = "https://earthkit-meteo.readthedocs.io/"
Homepage = "https://github.com/ecmwf/earthkit-meteo/"
Issues = "https://github.com/ecmwf/earthkit-meteo.issues"
Repository = "https://github.com/ecmwf/earthkit-meteo/"
[tool.setuptools.packages.find]
include = [ "earthkit.meteo" ]
where = [ "src/" ]

[tool.coverage.run]
branch = "true"
[tool.setuptools_scm]
version_file = "src/earthkit/meteo/_version.py"

[tool.isort]
profile = "black"

[tool.coverage.run]
branch = "true"

[tool.pydocstyle]
add_ignore = ["D1", "D200", "D205", "D400", "D401"]
add_ignore = [ "D1", "D200", "D205", "D400", "D401" ]
convention = "numpy"

[tool.setuptools.packages.find]
include = ["earthkit.meteo"]
where = ["src/"]

[tool.setuptools_scm]
version_file = "src/earthkit/meteo/_version.py"
14 changes: 6 additions & 8 deletions src/earthkit/meteo/extreme/array/cpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ def cpf(clim, ens, sort_clim=True, sort_ens=True):
idx = (qv_f < qv_c) & (qv_c_2 < qv_c)

# intersection between two lines
tau_i = (
tau_c * (qv_c_2[idx] - qv_f[idx])
+ tau_c_2 * (qv_f[idx] - qv_c[idx])
) / (qv_c_2[idx] - qv_c[idx])
tau_i = (tau_c * (qv_c_2[idx] - qv_f[idx]) + tau_c_2 * (qv_f[idx] - qv_c[idx])) / (
qv_c_2[idx] - qv_c[idx]
)

# populate matrix, no values below 0
cpf[idx] = np.maximum(tau_i, 0)
Expand All @@ -85,10 +84,9 @@ def cpf(clim, ens, sort_clim=True, sort_ens=True):

idx = (qv_f > qv_c) & (qv_c_2 > qv_c) & (~mask)

tau_i = (
tau_c * (qv_c_2[idx] - qv_f[idx])
+ tau_c_2 * (qv_f[idx] - qv_c[idx])
) / (qv_c_2[idx] - qv_c[idx])
tau_i = (tau_c * (qv_c_2[idx] - qv_f[idx]) + tau_c_2 * (qv_f[idx] - qv_c[idx])) / (
qv_c_2[idx] - qv_c[idx]
)

# populate matrix, no values above 1
cpf[idx] = np.minimum(tau_i, 1)
Expand Down
14 changes: 3 additions & 11 deletions src/earthkit/meteo/extreme/array/efi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def efi(clim, ens, eps=-0.1):
EFI values
"""
# locate missing values
missing_mask = np.logical_or(
np.sum(np.isnan(clim), axis=0), np.sum(np.isnan(ens), axis=0)
)
missing_mask = np.logical_or(np.sum(np.isnan(clim), axis=0), np.sum(np.isnan(ens), axis=0))

# Compute fraction of the forecast below climatology
nclim, npoints = clim.shape
Expand Down Expand Up @@ -65,9 +63,7 @@ def efi(clim, ens, eps=-0.1):
mask = clim[icl + 1, :] > eps
dEFI = np.where(
mask,
(2.0 * frac[icl, :] - 1.0) * acosdiff[icl]
+ acoef[icl] * dFdp[icl, :]
- proddiff[icl],
(2.0 * frac[icl, :] - 1.0) * acosdiff[icl] + acoef[icl] * dFdp[icl, :] - proddiff[icl],
0.0,
)
defimax = np.where(mask, -acosdiff[icl] - proddiff[icl], 0.0)
Expand All @@ -77,11 +73,7 @@ def efi(clim, ens, eps=-0.1):
efi /= efimax
else:
for icl in range(nclim - 1):
dEFI = (
(2.0 * frac[icl, :] - 1.0) * acosdiff[icl]
+ acoef[icl] * dFdp[icl, :]
- proddiff[icl]
)
dEFI = (2.0 * frac[icl, :] - 1.0) * acosdiff[icl] + acoef[icl] * dFdp[icl, :] - proddiff[icl]
efi += dEFI
efi *= 2.0 / np.pi
##################################
Expand Down
Loading

0 comments on commit b65e573

Please sign in to comment.