Skip to main content

regli DOI

REgular Grid Linear Interpolator, capable to deal with spectral library or similar model data.

This package implements the basic bilinear interpolation in multi-dimension. However, as commented in Numerical Recipes:

Bilinear interpolation is frequently “close enough for government work.” As the interpolating point wanders from grid square to grid square, the interpolated func- tion value changes continuously. However, the gradient of the interpolated function changes discontinuously at the boundaries of each grid square.

As a consequence, the interpolation model can not, in general, be used as a forward model and incorporated with Gradient-based optimization algorithms to estimate parameters.

author

Bo Zhang, bozhang@nao.cas.cn

home page

install

  • for the latest stable version: pip install -U regli
  • for the latest github version: pip install -U git+git://github.com/hypergravity/regli
  • for the Zenodo version: https://zenodo.org/record/3461514

test

from regli import test
test()

output:

regli.interp3 x 10000: 0.5675415992736816 sec
regli.interpn x 10000: 2.5326197147369385 sec
rgi x 10000: 5.4028871059417725 sec

doc

# import Regli
from regli import Regli
import numpy as np

# construct grid coordinates
x1 = np.linspace(-1, 1, 30)     
x2 = np.linspace(-1, 1, 30)
x3 = np.linspace(-1, 1, 30)

# initiate regli using coordinates
regli = Regli(x1, x2, x3)

# an arbitrary function of coordinates (for demo)
f = lambda _x1, _x2, _x3: _x1 + _x2 + _x3

# regli.flats stores flattened coordinates of ND grid
flats = regli.flats
# evaluate your function on flats
values = np.array([f(*_) for _ in flats]).reshape(-1, 1)
# set values for regli
regli.set_values(values)        

regli(pos)                      # use any of the 3 ways to interpolate
regli.interpn(pos)              # method 1 is equivalent to 2
regli.interp3(pos)              # this is accelerated for 3D

How to cite the code

BibTex:

@misc{https://doi.org/10.5281/zenodo.3461514,
  doi = {10.5281/zenodo.3461514},
  url = {https://zenodo.org/record/3461514},
  author = {Zhang, Bo},
  title = {hypergravity/regli: The Zenodo version},
  publisher = {Zenodo},
  year = {2019}
}

Please go to https://search.datacite.org/works/10.5281/zenodo.3461514 for other formats.

Metadata

Release files for regli 2023.829.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for regli 2023.829.0
File Size Uploaded
regli-2023.829.0.tar.gz 13.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for regli 2023.829.0
File Interpreter ABI Platform
regli-2023.829.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.9 kB

Release files / regli-2023.829.0.tar.gz

Download URL regli-2023.829.0.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8ea3623da13a021fd71ac8a1fbf18a9e0f295520c1109588e6b64f0c0a01dae5
BLAKE2b-256 checksum
How to use checksums
430e683638287e91a9af180747750485dc93fc31043f1fca23d2bfb886b01605
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / regli-2023.829.0-py3-none-any.whl

Download URL regli-2023.829.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25dc0d4fa9ffa3a607286476628f5ea611b1fc26f870f76235bdca5f24b0483a
BLAKE2b-256 checksum
How to use checksums
e5f0ef1ac7e6a7c309b201a33cb41dd9ea10847fd0b413d2d04fffa4c893ee18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

2023.829.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

1 release file

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

1 release file

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page