PyMPDATA icon indicating copy to clipboard operation
PyMPDATA copied to clipboard

Add dedicated interpolate function

Open Sfonxu opened this issue 7 months ago • 5 comments

This PR is a first in series of PRs of API refactoring described in #510.

The aim is to replace repeated definitions of interpolate around the code to a single function in PyMPDATA.impl.

Current tasks:

  • [x] Replace interpolate as in shallow-water examples
  • [x] Make interpolate JIT-compilable
  • [ ] Look for other places where such functions are defined
  • [ ] Look into replacing interpolate in those places

Sfonxu avatar Jul 23 '25 09:07 Sfonxu

* [ ]  Look for other places where such functions are defined
* [ ]  Look into replacing interpolate in other places, such as `Shipway and Hill (2012)`

The interpolation happens only when advecting momentum. Shipway and Hill (2012) example features only vapour mass advection, so it is not relevant. Other locations where we can refactor the interpolation code are:

  • https://github.com/open-atmos/PyMPDATA/blob/a921acca90743d498c98e63971bf12b391fb0bf4/examples/PyMPDATA_examples/burgers_equation/burgers_equation.py#L40
  • https://github.com/open-atmos/PyMPDATA/blob/a921acca90743d498c98e63971bf12b391fb0bf4/examples/PyMPDATA_examples/Jaruga_et_al_2015/fig19.ipynb#L347
  • https://github.com/open-atmos/PyMPDATA/blob/a921acca90743d498c98e63971bf12b391fb0bf4/examples/PyMPDATA_examples/Jarecka_et_al_2015/simulation.py#L40

slayoo avatar Jul 23 '25 13:07 slayoo

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 92.93%. Comparing base (ed8d8c1) to head (559bd76). :warning: Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #612      +/-   ##
==========================================
+ Coverage   92.69%   92.93%   +0.23%     
==========================================
  Files          39       40       +1     
  Lines        1697     1754      +57     
==========================================
+ Hits         1573     1630      +57     
  Misses        124      124              

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

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jul 23 '25 13:07 codecov[bot]

It seems that, according to numba docs, the argument axis in np.diff is not supported.

Sfonxu avatar Jul 23 '25 13:07 Sfonxu

It seems that, according to numba docs, the argument axis in np.diff is not supported.

IIUC, usage of np.diff is anyhow out of question here as it allocates new memory

slayoo avatar Jul 24 '25 07:07 slayoo

Stale pull request message

github-actions[bot] avatar Oct 24 '25 10:10 github-actions[bot]