Interpolation Tool for 1d 2d and 3d functions
Project description
use pip install interp-tools
Python module for interpolating functions from one, two or three variables.
Examples of using the module:
Examle 1 for 1D interpolation python:
import numpy as np
function_dots = np.array([0, 1, 2, 3, 4, 5])
interpolator = interp_tools.Interp(
function_dots, 1, np.array([1])
)
for i in range(8):
print(f"x = {i / 5}, interp val = {interpolator.get_value(i / 5)}, real func val = {i / 5}")
# x = 0.0, interp val = 0.0, real func val = 0.0
# x = 0.2, interp val = 0.19999999999999998, real func val = 0.2
# x = 0.4, interp val = 0.39999999999999997, real func val = 0.4
# x = 0.6, interp val = 0.5999999999999999, real func val = 0.6
# x = 0.8, interp val = 0.7999999999999999, real func val = 0.8
# x = 1.0, interp val = 1.0, real func val = 1.0
# x = 1.2, interp val = 1.2, real func val = 1.2
# x = 1.4, interp val = 1.4, real func val = 1.4
Examle 2 for 1D interpolation python:
import interp_tools
import numpy as np
function_dots = np.zeros(100)
for x in range(100):
function_dots[x] = (x / 10) ** 2
interpolator = interp_tools.Interp(
function_dots, 1, np.array([0.1])
)
for i in range(5):
print(f"x = {i / 5}, interp val = {interpolator.get_value(i / 5)}, real func val = {((i / 5) ** 2) }")
# x = 0.0, interp val = 0.0, real func val = 0.0
# x = 0.2, interp val = 0.04000000000000001, real func val = 0.04000000000000001
# x = 0.4, interp val = 0.16000000000000003, real func val = 0.16000000000000003
# x = 0.6, interp val = 0.35999999999999993, real func val = 0.36
# x = 0.8, interp val = 0.6400000000000001, real func val = 0.6400000000000001
Example for 2D interpolation python:
import interp_tools
import numpy as np
function_dots = np.zeros([100, 100])
for x in range(100):
for y in range(100):
function_dots[x, y] = x * y / 100
interpolator = interp_tools.Interp(
function_dots, 2, np.array([0.1, 0.1])
)
for x in range(1, 4):
for y in range(1, 4):
print(f"x = {x / 5}, y = {y / 5}, interp val = {interpolator.get_value(x / 5, y / 5)}, real func val = {((x / 5) * (y / 5)) }")
#x = 0.2, y = 0.2, interp val = 0.04, real func val = 0.04000000000000001
# x = 0.2, y = 0.4, interp val = 0.08, real func val = 0.08000000000000002
# x = 0.2, y = 0.6, interp val = 0.11999999999999998, real func val = 0.12
# x = 0.4, y = 0.2, interp val = 0.08, real func val = 0.08000000000000002
# x = 0.4, y = 0.4, interp val = 0.16, real func val = 0.16000000000000003
# x = 0.4, y = 0.6, interp val = 0.23999999999999996, real func val = 0.24
# x = 0.6, y = 0.2, interp val = 0.11999999999999998, real func val = 0.12
# x = 0.6, y = 0.4, interp val = 0.23999999999999996, real func val = 0.24
# x = 0.6, y = 0.6, interp val = 0.34999999999999987, real func val = 0.36
Example of 3D interpolation python: import interp_tools import numpy as np
function_dots = np.zeros([100, 100, 100])
for x in range(100):
for y in range(100):
for z in range(100):
function_dots[x, y, z] = (x * y / 100 + z / 10)
interpolator = interp_tools.Interp(
function_dots, 3, np.array([0.1, 0.1, 0.1])
)
for x in range(1, 4):
for y in range(1, 4):
for z in range(1, 4):
print(f"x = {x / 5}, y = {y / 5}, z = {z / 5}, interp val = {interpolator.get_value(x / 5, y / 5, z / 5)}, real func val = {((x / 5) * (y / 5) + z / 5) }")
#x = 0.2, y = 0.2, z = 0.2, interp val = 0.24000000000000002, real func val = 0.24000000000000002
# x = 0.2, y = 0.2, z = 0.4, interp val = 0.44, real func val = 0.44000000000000006
# x = 0.2, y = 0.2, z = 0.6, interp val = 0.6399999999999999, real func val = 0.64
# x = 0.2, y = 0.4, z = 0.2, interp val = 0.28, real func val = 0.28
# x = 0.2, y = 0.4, z = 0.4, interp val = 0.48000000000000004, real func val = 0.48000000000000004
# x = 0.2, y = 0.4, z = 0.6, interp val = 0.6799999999999998, real func val = 0.6799999999999999
# x = 0.2, y = 0.6, z = 0.2, interp val = 0.32, real func val = 0.32
# x = 0.2, y = 0.6, z = 0.4, interp val = 0.52, real func val = 0.52
# x = 0.2, y = 0.6, z = 0.6, interp val = 0.7199999999999999, real func val = 0.72
# x = 0.4, y = 0.2, z = 0.2, interp val = 0.28, real func val = 0.28
# x = 0.4, y = 0.2, z = 0.4, interp val = 0.48000000000000004, real func val = 0.48000000000000004
# x = 0.4, y = 0.2, z = 0.6, interp val = 0.6799999999999998, real func val = 0.6799999999999999
# x = 0.4, y = 0.4, z = 0.2, interp val = 0.36, real func val = 0.36000000000000004
# x = 0.4, y = 0.4, z = 0.4, interp val = 0.56, real func val = 0.56
# x = 0.4, y = 0.4, z = 0.6, interp val = 0.7599999999999999, real func val = 0.76
# x = 0.4, y = 0.6, z = 0.2, interp val = 0.43999999999999995, real func val = 0.44
# x = 0.4, y = 0.6, z = 0.4, interp val = 0.64, real func val = 0.64
# x = 0.4, y = 0.6, z = 0.6, interp val = 0.84, real func val = 0.84
# x = 0.6, y = 0.2, z = 0.2, interp val = 0.32, real func val = 0.32
# x = 0.6, y = 0.2, z = 0.4, interp val = 0.52, real func val = 0.52
# x = 0.6, y = 0.2, z = 0.6, interp val = 0.7199999999999999, real func val = 0.72
# x = 0.6, y = 0.4, z = 0.2, interp val = 0.43999999999999995, real func val = 0.44
# x = 0.6, y = 0.4, z = 0.4, interp val = 0.64, real func val = 0.64
# x = 0.6, y = 0.4, z = 0.6, interp val = 0.84, real func val = 0.84
# x = 0.6, y = 0.6, z = 0.2, interp val = 0.5499999999999999, real func val = 0.56
# x = 0.6, y = 0.6, z = 0.4, interp val = 0.7499999999999998, real func val = 0.76
# x = 0.6, y = 0.6, z = 0.6, interp val = 0.95, real func val = 0.96
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interp_tools-2.0.1.tar.gz.
File metadata
- Download URL: interp_tools-2.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8086363f5392abd27549ea02325386e2b55a4743fa79e7454d22aed9346e35d
|
|
| MD5 |
4f195a1ec55b7e4b0e3151b0312961ae
|
|
| BLAKE2b-256 |
7f3e1ef012626a9ceb9e91ac049f084b8e8c05d632e77df836978b7d7e4a4442
|
File details
Details for the file interp_tools-2.0.1-py3-none-any.whl.
File metadata
- Download URL: interp_tools-2.0.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02974b405321f6f86015548056d0d8bd9c21ef87ebaf2740284ffe092d44fb4b
|
|
| MD5 |
67453b37f6ab4a58800cc2f25fe72504
|
|
| BLAKE2b-256 |
aee0242c16209cae88806215f20d48e88b412cb4a66375989bae6b564084eeef
|