-
Notifications
You must be signed in to change notification settings - Fork 1
Add interpolator backends and MIR interface #60
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #60 +/- ##
============================================
+ Coverage 52.55% 94.35% +41.79%
============================================
Files 10 12 +2
Lines 588 885 +297
Branches 16 32 +16
============================================
+ Hits 309 835 +526
+ Misses 276 39 -237
- Partials 3 11 +8 ☔ View full report in Codecov by Sentry. |
|
||
def interpolate(self, values, in_grid, out_grid, method, **kwargs): | ||
try: | ||
import mir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this mir-python? Or is this "from . import mir"?
docs/guide/interpolate.rst
Outdated
@@ -1,7 +1,7 @@ | |||
Interpolation | |||
============== | |||
|
|||
.. py:function:: interpolate(values, in_grid=None, out_grid=None, matrix_source=None, method='linear') | |||
.. py:function:: interpolate(values, in_grid=None, out_grid=None, matrix_source=None, method='linear', backend=None, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "backend" is now "interpolator"
docs/guide/interpolate.rst
Outdated
:param matrix_source: (experimental) the location of a user specified pre-generated matrix inventory. When it is None the default matrix inventory hosted on an ECMWF download server is used. | ||
:type matrix_source: str, None | ||
:backend: the backend to use for the interpolation. When it is None, the backends specified by the ``backend-order`` :ref:`config <configs>` option tried in the given order. | ||
:type backend: str, list of str, None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "backend" is now "interpolator"
I believe you've generalised the "method" into an "interpolator" which can be local or remote and so on, and interprets arbitrary arguments instead of specifically passing down directly options to mir. That's perfect! (Although, I cannot follow all of it) In any case I think somewhere you have "import mir" which is a little confusing as theres a "mir.py" in the same directory, I think that should import the mir-python module in, but here it does a "local" mir.py import? Just a clarification |
@pmaciel, thank you for the comments.
|
|
Ok thanks! So in my case that I'm using mir-python in my own branch, I should for the moment stay away from this one right? :-) (it's work on starting from gridspec) |
Yes! I have just changed the code in |
This PR adds the following changes:
Backends
A
Backend
is an object implementing theinterpolate()
method. There are built-in backends:"local-matrix": use a local matrix inventory from a user defined path. One object will be created per path. Paths can be added via the
local-matrix-directories
config option (set to None by default)."remote-matrix": use a remote matrix inventory from a user defined url. One object will be created per url. Urls can be added via the
remote-matrix-directories
config option (set to None by default)."system-matrix": the official remote matrix inventory with a hardcoded path
"mir": a MIR based interpolation. NOTE: this is not yet working!!!
Plugins
A backend can be implemented as a plugin.
Lazy object creation
An actual backend object is created lazily on first call of
interpolate()
on it.Backend order config
When calling
earthkit.regrid.interpolate()
it tries all the available backends in a user specified order until one is able to perform the interpolation. The order is defined by thebackends
config option. By default it is set to None meaning that the following hardcoded default order is used:E.g.
Explicit backend order
The backend order can be directly passed to
interpolate()
. In this case thebackends
config option is ignored. E.g.Breaking changes
The
matrix_source
keyword was removed frominterpolate()
.